Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Iliya Manolov
erp5
Commits
8063c50a
Commit
8063c50a
authored
Apr 23, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code simplification
parent
aa3a313d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
63 deletions
+42
-63
product/ERP5/Document/SimulatedDeliveryBuilder.py
product/ERP5/Document/SimulatedDeliveryBuilder.py
+2
-7
product/ERP5/mixin/builder.py
product/ERP5/mixin/builder.py
+11
-26
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+29
-30
No files found.
product/ERP5/Document/SimulatedDeliveryBuilder.py
View file @
8063c50a
...
@@ -348,11 +348,8 @@ class SimulatedDeliveryBuilder(BuilderMixin):
...
@@ -348,11 +348,8 @@ class SimulatedDeliveryBuilder(BuilderMixin):
if
old_delivery
is
None
:
if
old_delivery
is
None
:
# from scratch
# from scratch
new_delivery_id
=
str
(
delivery_module
.
generateNewId
())
new_delivery_id
=
str
(
delivery_module
.
generateNewId
())
delivery
=
delivery_module
.
newContent
(
delivery
=
super
(
SimulatedDeliveryBuilder
,
self
).
_createDelivery
(
portal_type
=
self
.
getDeliveryPortalType
(),
delivery_module
,
movement_list
,
activate_kw
)
id
=
new_delivery_id
,
created_by_builder
=
1
,
activate_kw
=
activate_kw
)
else
:
else
:
# from duplicated original delivery
# from duplicated original delivery
cp
=
tryMethodCallWithTemporaryPermission
(
cp
=
tryMethodCallWithTemporaryPermission
(
...
@@ -383,10 +380,8 @@ class SimulatedDeliveryBuilder(BuilderMixin):
...
@@ -383,10 +380,8 @@ class SimulatedDeliveryBuilder(BuilderMixin):
old_delivery_line
=
None
old_delivery_line
=
None
if
old_delivery_line
is
None
:
if
old_delivery_line
is
None
:
# from scratch
# from scratch
new_delivery_line_id
=
str
(
delivery
.
generateNewId
())
delivery_line
=
delivery
.
newContent
(
delivery_line
=
delivery
.
newContent
(
portal_type
=
self
.
getDeliveryLinePortalType
(),
portal_type
=
self
.
getDeliveryLinePortalType
(),
id
=
new_delivery_line_id
,
variation_category_list
=
[],
variation_category_list
=
[],
activate_kw
=
activate_kw
)
activate_kw
=
activate_kw
)
else
:
else
:
...
...
product/ERP5/mixin/builder.py
View file @
8063c50a
...
@@ -164,7 +164,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -164,7 +164,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
"""
"""
delivery_module_before_building_script_id
=
\
delivery_module_before_building_script_id
=
\
self
.
getDeliveryModuleBeforeBuildingScriptId
()
self
.
getDeliveryModuleBeforeBuildingScriptId
()
if
delivery_module_before_building_script_id
not
in
[
""
,
None
]
:
if
delivery_module_before_building_script_id
:
delivery_module
=
getattr
(
self
.
getPortalObject
(),
self
.
getDeliveryModule
())
delivery_module
=
getattr
(
self
.
getPortalObject
(),
self
.
getDeliveryModule
())
getattr
(
delivery_module
,
delivery_module_before_building_script_id
)()
getattr
(
delivery_module
,
delivery_module_before_building_script_id
)()
...
@@ -369,13 +369,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -369,13 +369,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
Create a new delivery in case where a builder may not update
Create a new delivery in case where a builder may not update
an existing one.
an existing one.
"""
"""
new_delivery_id
=
str
(
delivery_module
.
generateNewId
())
return
delivery_module
.
newContent
(
delivery
=
delivery_module
.
newContent
(
portal_type
=
self
.
getDeliveryPortalType
(),
portal_type
=
self
.
getDeliveryPortalType
(),
id
=
new_delivery_id
,
created_by_builder
=
1
,
created_by_builder
=
1
,
activate_kw
=
activate_kw
)
activate_kw
=
activate_kw
)
return
delivery
def
_processDeliveryGroup
(
self
,
delivery_module
,
movement_group_node
,
def
_processDeliveryGroup
(
self
,
delivery_module
,
movement_group_node
,
collect_order_list
,
movement_group_node_list
=
None
,
collect_order_list
,
movement_group_node_list
=
None
,
...
@@ -453,13 +450,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -453,13 +450,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
Create a new delivery line in case where a builder may not update
Create a new delivery line in case where a builder may not update
an existing one.
an existing one.
"""
"""
new_delivery_line_id
=
str
(
delivery
.
generateNewId
())
return
delivery
.
newContent
(
delivery_line
=
delivery
.
newContent
(
portal_type
=
self
.
getDeliveryLinePortalType
(),
portal_type
=
self
.
getDeliveryLinePortalType
(),
id
=
new_delivery_line_id
,
created_by_builder
=
1
,
created_by_builder
=
1
,
activate_kw
=
activate_kw
)
activate_kw
=
activate_kw
)
return
delivery_line
def
_processDeliveryLineGroup
(
self
,
delivery
,
movement_group_node
,
def
_processDeliveryLineGroup
(
self
,
delivery
,
movement_group_node
,
collect_order_list
,
movement_group_node_list
=
None
,
collect_order_list
,
movement_group_node_list
=
None
,
...
@@ -686,42 +680,33 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -686,42 +680,33 @@ class BuilderMixin(XMLObject, Amount, Predicate):
delivery_movement
.
_edit
(
force_update
=
1
,
**
property_dict
)
delivery_movement
.
_edit
(
force_update
=
1
,
**
property_dict
)
@
UnrestrictedMethod
@
UnrestrictedMethod
def
callAfterBuildingScript
(
self
,
delivery_list
,
movement_list
=
None
,
**
kw
):
def
callAfterBuildingScript
(
self
,
delivery_list
,
movement_list
=
()
,
**
kw
):
"""
"""
Call script on each delivery built.
Call script on each delivery built.
"""
"""
if
not
len
(
delivery_list
):
return
# Parameter initialization
if
movement_list
is
None
:
movement_list
=
[]
delivery_after_generation_script_id
=
\
delivery_after_generation_script_id
=
\
self
.
getDeliveryAfterGenerationScriptId
()
self
.
getDeliveryAfterGenerationScriptId
()
if
delivery_after_generation_script_id
:
related_simulation_movement_path_list
=
\
related_simulation_movement_path_list
=
\
[
x
.
getPath
()
for
x
in
movement_list
]
[
x
.
getPath
()
for
x
in
movement_list
]
if
delivery_after_generation_script_id
not
in
[
""
,
None
]:
for
delivery
in
delivery_list
:
for
delivery
in
delivery_list
:
script
=
getattr
(
delivery
,
delivery_after_generation_script_id
)
script
=
getattr
(
delivery
,
delivery_after_generation_script_id
)
# BBB: Only Python Scripts were used in the past, and they might not
# BBB: Only Python Scripts were used in the past, and they might not
# accept an arbitrary argument. So to keep compatibility,
# accept an arbitrary argument. So to keep compatibility,
# check if it can take the new parameter safely, only when
# check if it can take the new parameter safely, only when
# the callable object is a Python Script.
# the callable object is a Python Script.
safe_to_pass_parameter
=
True
meta_type
=
getattr
(
script
,
'meta_type'
,
None
)
meta_type
=
getattr
(
script
,
'meta_type'
,
None
)
if
meta_type
==
'Script (Python)'
:
if
meta_type
==
'Script (Python)'
:
# check if the script accepts related_simulation_movement_path_list
# check if the script accepts related_simulation_movement_path_list
safe_to_pass_parameter
=
False
for
param
in
script
.
params
().
split
(
','
):
for
param
in
script
.
params
().
split
(
','
):
param
=
param
.
split
(
'='
,
1
)[
0
].
strip
()
param
=
param
.
split
(
'='
,
1
)[
0
].
strip
()
if
param
==
'related_simulation_movement_path_list'
\
if
param
==
'related_simulation_movement_path_list'
\
or
param
.
startswith
(
'**'
):
or
param
.
startswith
(
'**'
):
safe_to_pass_parameter
=
True
break
break
if
safe_to_pass_parameter
:
script
(
related_simulation_movement_path_list
=
related_simulation_movement_path_list
)
else
:
else
:
script
()
script
()
continue
script
(
related_simulation_movement_path_list
=
related_simulation_movement_path_list
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getMovementGroupList'
)
'getMovementGroupList'
)
...
...
product/ERP5Type/Base.py
View file @
8063c50a
...
@@ -1436,22 +1436,23 @@ class Base( CopyContainer,
...
@@ -1436,22 +1436,23 @@ class Base( CopyContainer,
# We only change if the value is different
# We only change if the value is different
# This may be very long...
# This may be very long...
if
force_update
:
if
force_update
:
update
=
True
old_value
=
None
old_value
=
None
else
:
else
:
try
:
try
:
old_value
=
getProperty
(
key
,
evaluate
=
0
)
old_value
=
getProperty
(
key
,
evaluate
=
0
)
except
TypeError
:
except
TypeError
:
old_value
=
getProperty
(
key
)
old_value
=
getProperty
(
key
)
update
=
old_value
!=
kw
[
key
]
if
old_value
==
kw
[
key
]:
not_modified_list
.
append
(
key
)
continue
if
update
:
# We keep in a thread var the previous values
# We keep in a thread var the previous values
# this can be useful for interaction workflow to implement lookups
# this can be useful for interaction workflow to implement lookups
# XXX If iteraction workflow script is triggered by edit and calls
# XXX If iteraction workflow script is triggered by edit and calls
# edit itself, this is useless as the dict will be overwritten
# edit itself, this is useless as the dict will be overwritten
# If the keep_existing flag is set to 1, we do not update properties which are defined
# If the keep_existing flag is set to 1, we do not update properties which are defined
if
not
keep_existing
or
not
hasProperty
(
key
):
if
keep_existing
and
hasProperty
(
key
):
continue
if
restricted
:
if
restricted
:
accessor_name
=
'set'
+
UpperCase
(
key
)
accessor_name
=
'set'
+
UpperCase
(
key
)
if
accessor_name
in
restricted_method_set
:
if
accessor_name
in
restricted_method_set
:
...
@@ -1471,8 +1472,6 @@ class Base( CopyContainer,
...
@@ -1471,8 +1472,6 @@ class Base( CopyContainer,
modified_object_dict
[
id
(
o
)]
=
o
modified_object_dict
[
id
(
o
)]
=
o
else
:
else
:
self
.
setId
(
kw
[
'id'
],
reindex
=
reindex_object
)
self
.
setId
(
kw
[
'id'
],
reindex
=
reindex_object
)
else
:
not_modified_list
.
append
(
key
)
return
not_modified_list
return
not_modified_list
unmodified_key_list
=
setChangedPropertyList
(
unordered_key_list
)
unmodified_key_list
=
setChangedPropertyList
(
unordered_key_list
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment