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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Douglas
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
Hide 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):
if
old_delivery
is
None
:
# from scratch
new_delivery_id
=
str
(
delivery_module
.
generateNewId
())
delivery
=
delivery_module
.
newContent
(
portal_type
=
self
.
getDeliveryPortalType
(),
id
=
new_delivery_id
,
created_by_builder
=
1
,
activate_kw
=
activate_kw
)
delivery
=
super
(
SimulatedDeliveryBuilder
,
self
).
_createDelivery
(
delivery_module
,
movement_list
,
activate_kw
)
else
:
# from duplicated original delivery
cp
=
tryMethodCallWithTemporaryPermission
(
...
...
@@ -383,10 +380,8 @@ class SimulatedDeliveryBuilder(BuilderMixin):
old_delivery_line
=
None
if
old_delivery_line
is
None
:
# from scratch
new_delivery_line_id
=
str
(
delivery
.
generateNewId
())
delivery_line
=
delivery
.
newContent
(
portal_type
=
self
.
getDeliveryLinePortalType
(),
id
=
new_delivery_line_id
,
variation_category_list
=
[],
activate_kw
=
activate_kw
)
else
:
...
...
product/ERP5/mixin/builder.py
View file @
8063c50a
...
...
@@ -164,7 +164,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
"""
delivery_module_before_building_script_id
=
\
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
())
getattr
(
delivery_module
,
delivery_module_before_building_script_id
)()
...
...
@@ -369,13 +369,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
Create a new delivery in case where a builder may not update
an existing one.
"""
new_delivery_id
=
str
(
delivery_module
.
generateNewId
())
delivery
=
delivery_module
.
newContent
(
return
delivery_module
.
newContent
(
portal_type
=
self
.
getDeliveryPortalType
(),
id
=
new_delivery_id
,
created_by_builder
=
1
,
activate_kw
=
activate_kw
)
return
delivery
def
_processDeliveryGroup
(
self
,
delivery_module
,
movement_group_node
,
collect_order_list
,
movement_group_node_list
=
None
,
...
...
@@ -453,13 +450,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
Create a new delivery line in case where a builder may not update
an existing one.
"""
new_delivery_line_id
=
str
(
delivery
.
generateNewId
())
delivery_line
=
delivery
.
newContent
(
return
delivery
.
newContent
(
portal_type
=
self
.
getDeliveryLinePortalType
(),
id
=
new_delivery_line_id
,
created_by_builder
=
1
,
activate_kw
=
activate_kw
)
return
delivery_line
def
_processDeliveryLineGroup
(
self
,
delivery
,
movement_group_node
,
collect_order_list
,
movement_group_node_list
=
None
,
...
...
@@ -686,42 +680,33 @@ class BuilderMixin(XMLObject, Amount, Predicate):
delivery_movement
.
_edit
(
force_update
=
1
,
**
property_dict
)
@
UnrestrictedMethod
def
callAfterBuildingScript
(
self
,
delivery_list
,
movement_list
=
None
,
**
kw
):
def
callAfterBuildingScript
(
self
,
delivery_list
,
movement_list
=
()
,
**
kw
):
"""
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
=
\
self
.
getDeliveryAfterGenerationScriptId
()
related_simulation_movement_path_list
=
\
[
x
.
getPath
()
for
x
in
movement_list
]
if
delivery_after_generation_script_id
not
in
[
""
,
None
]:
if
delivery_after_generation_script_id
:
related_simulation_movement_path_list
=
\
[
x
.
getPath
()
for
x
in
movement_list
]
for
delivery
in
delivery_list
:
script
=
getattr
(
delivery
,
delivery_after_generation_script_id
)
# BBB: Only Python Scripts were used in the past, and they might not
# accept an arbitrary argument. So to keep compatibility,
# check if it can take the new parameter safely, only when
# the callable object is a Python Script.
safe_to_pass_parameter
=
True
meta_type
=
getattr
(
script
,
'meta_type'
,
None
)
if
meta_type
==
'Script (Python)'
:
# check if the script accepts related_simulation_movement_path_list
safe_to_pass_parameter
=
False
for
param
in
script
.
params
().
split
(
','
):
param
=
param
.
split
(
'='
,
1
)[
0
].
strip
()
if
param
==
'related_simulation_movement_path_list'
\
or
param
.
startswith
(
'**'
):
safe_to_pass_parameter
=
True
break
if
safe_to_pass_parameter
:
script
(
related_simulation_movement_path_list
=
related_simulation_movement_path_list
)
else
:
script
()
else
:
script
()
continue
script
(
related_simulation_movement_path_list
=
related_simulation_movement_path_list
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getMovementGroupList'
)
...
...
product/ERP5Type/Base.py
View file @
8063c50a
...
...
@@ -1436,43 +1436,42 @@ class Base( CopyContainer,
# We only change if the value is different
# This may be very long...
if
force_update
:
update
=
True
old_value
=
None
else
:
try
:
old_value
=
getProperty
(
key
,
evaluate
=
0
)
except
TypeError
:
old_value
=
getProperty
(
key
)
update
=
old_value
!=
kw
[
key
]
if
update
:
# We keep in a thread var the previous values
# this can be useful for interaction workflow to implement lookup
s
# XXX If iteraction workflow script is triggered by edit and call
s
# 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
not
keep_existing
or
not
hasProperty
(
key
):
if
restricted
:
accessor_name
=
'set'
+
UpperCase
(
key
)
if
accessor_name
in
restricted_method_set
:
# will raise Unauthorized when not allowed
guarded_getattr
(
self
,
accessor_name
)
modified_property_dict
[
key
]
=
old_value
if
key
!=
'id'
:
modified_object_list
=
_setProperty
(
key
,
kw
[
key
])
# BBB: if the setter does not return anything, assume
# that self has been modified.
if
modified_object_list
is
None
:
modified_object_list
=
(
self
,)
for
o
in
modified_object_list
:
# XXX using id is not quite nice, but getUID causes a
# problem at the bootstrap of an ERP5 site. Therefore,
# objects themselves cannot be used as keys.
modified_object_dict
[
id
(
o
)]
=
o
else
:
self
.
setId
(
kw
[
'id'
],
reindex
=
reindex_object
)
if
old_value
==
kw
[
key
]:
not_modified_list
.
append
(
key
)
continue
# We keep in a thread var the previous value
s
# this can be useful for interaction workflow to implement lookup
s
# XXX If iteraction workflow script is triggered by edit and calls
# 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
keep_existing
and
hasProperty
(
key
)
:
continue
if
restricted
:
accessor_name
=
'set'
+
UpperCase
(
key
)
if
accessor_name
in
restricted_method_set
:
# will raise Unauthorized when not allowed
guarded_getattr
(
self
,
accessor_name
)
modified_property_dict
[
key
]
=
old_value
if
key
!=
'id'
:
modified_object_list
=
_setProperty
(
key
,
kw
[
key
])
# BBB: if the setter does not return anything, assume
# that self has been modified.
if
modified_object_list
is
None
:
modified_object_list
=
(
self
,)
for
o
in
modified_object_list
:
# XXX using id is not quite nice, but getUID causes a
# problem at the bootstrap of an ERP5 site. Therefore,
# objects themselves cannot be used as keys.
modified_object_dict
[
id
(
o
)]
=
o
else
:
not_modified_list
.
append
(
key
)
self
.
setId
(
kw
[
'id'
],
reindex
=
reindex_object
)
return
not_modified_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