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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ludovic Kiefer
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):
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
()
if
delivery_after_generation_script_id
:
related_simulation_movement_path_list
=
\
[
x
.
getPath
()
for
x
in
movement_list
]
if
delivery_after_generation_script_id
not
in
[
""
,
None
]:
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
()
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,22 +1436,23 @@ 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
old_value
==
kw
[
key
]:
not_modified_list
.
append
(
key
)
continue
if
update
:
# We keep in a thread var the previous values
# this can be useful for interaction workflow to implement lookups
# 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
not
keep_existing
or
not
hasProperty
(
key
):
if
keep_existing
and
hasProperty
(
key
):
continue
if
restricted
:
accessor_name
=
'set'
+
UpperCase
(
key
)
if
accessor_name
in
restricted_method_set
:
...
...
@@ -1471,8 +1472,6 @@ class Base( CopyContainer,
modified_object_dict
[
id
(
o
)]
=
o
else
:
self
.
setId
(
kw
[
'id'
],
reindex
=
reindex_object
)
else
:
not_modified_list
.
append
(
key
)
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