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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
705e0beb
Commit
705e0beb
authored
Jun 17, 2024
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AppliedRule._checkExpand: add parameters to filter objects + better reporting
parent
831cf1a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
8 deletions
+25
-8
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.AppliedRule.py
...mplateItem/portal_components/document.erp5.AppliedRule.py
+25
-8
No files found.
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.AppliedRule.py
View file @
705e0beb
...
...
@@ -28,6 +28,8 @@
##############################################################################
from
collections
import
deque
from
difflib
import
unified_diff
from
pprint
import
pformat
import
sys
import
transaction
import
zope.interface
...
...
@@ -390,7 +392,7 @@ class AppliedRule(XMLObject, ExplainableMixin):
return
{
k
:
sum
(
v
.
values
(),
[])
for
k
,
v
in
deleted
},
delivery_set
simulation_tool
.
_delObject
(
self
.
getId
())
def
_checkExpand
(
self
):
def
_checkExpand
(
self
,
ignore_nul_movements
=
False
,
filter
=
None
):
"""Check that expand() would not fail nor do major changes to the subobjects
Transaction is aborted after 'expand' is called.
...
...
@@ -405,12 +407,19 @@ class AppliedRule(XMLObject, ExplainableMixin):
while
object_list
:
document
=
object_list
.
popleft
()
portal_type
=
document
.
getPortalType
()
document_dict
=
{
'portal_type'
:
portal_type
}
for
property_
in
property_dict
[
portal_type
]:
document_dict
[
property_
]
=
document
.
getProperty
(
property_
)
rule_dict
[
document
.
getRelativeUrl
()]
=
document_dict
object_list
+=
document
.
objectValues
()
document_dict
=
{
property
:
document
.
getProperty
(
property
)
for
property
in
property_dict
[
portal_type
]}
if
ignore_nul_movements
and
portal_type
==
'Simulation Movement'
and
\
not
(
document_dict
[
'quantity'
]
and
document
.
getPrice
()):
if
document
.
isDeletable
():
continue
del
document_dict
[
'quantity'
]
document_dict
[
'portal_type'
]
=
portal_type
if
filter
is
None
or
filter
(
initial_rule_dict
,
document
,
document_dict
):
rule_dict
[
document
.
getRelativeUrl
()]
=
document_dict
object_list
+=
document
.
objectValues
()
return
rule_dict
initial_rule_dict
=
None
initial_rule_dict
=
fillRuleDict
()
try
:
self
.
expand
(
"immediate"
)
...
...
@@ -420,7 +429,15 @@ class AppliedRule(XMLObject, ExplainableMixin):
msg
=
''
.
join
(
ExceptionFormatter
.
format_exception
(
*
sys
.
exc_info
())[
1
:])
else
:
final_rule_dict
=
fillRuleDict
()
msg
=
"%r != %r"
%
(
initial_rule_dict
,
final_rule_dict
)
\
if
initial_rule_dict
!=
final_rule_dict
else
None
if
initial_rule_dict
==
final_rule_dict
:
msg
=
None
else
:
diff
=
unified_diff
(
pformat
(
initial_rule_dict
,
width
=
1000
).
splitlines
(),
pformat
(
final_rule_dict
,
width
=
1000
).
splitlines
(),
lineterm
=
''
)
next
(
diff
)
next
(
diff
)
msg
=
'
\
n
'
.
join
(
diff
)
transaction
.
abort
()
return
msg
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