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
Léo-Paul Géneau
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 @@
...
@@ -28,6 +28,8 @@
##############################################################################
##############################################################################
from
collections
import
deque
from
collections
import
deque
from
difflib
import
unified_diff
from
pprint
import
pformat
import
sys
import
sys
import
transaction
import
transaction
import
zope.interface
import
zope.interface
...
@@ -390,7 +392,7 @@ class AppliedRule(XMLObject, ExplainableMixin):
...
@@ -390,7 +392,7 @@ class AppliedRule(XMLObject, ExplainableMixin):
return
{
k
:
sum
(
v
.
values
(),
[])
for
k
,
v
in
deleted
},
delivery_set
return
{
k
:
sum
(
v
.
values
(),
[])
for
k
,
v
in
deleted
},
delivery_set
simulation_tool
.
_delObject
(
self
.
getId
())
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
"""Check that expand() would not fail nor do major changes to the subobjects
Transaction is aborted after 'expand' is called.
Transaction is aborted after 'expand' is called.
...
@@ -405,12 +407,19 @@ class AppliedRule(XMLObject, ExplainableMixin):
...
@@ -405,12 +407,19 @@ class AppliedRule(XMLObject, ExplainableMixin):
while
object_list
:
while
object_list
:
document
=
object_list
.
popleft
()
document
=
object_list
.
popleft
()
portal_type
=
document
.
getPortalType
()
portal_type
=
document
.
getPortalType
()
document_dict
=
{
'portal_type'
:
portal_type
}
document_dict
=
{
property
:
document
.
getProperty
(
property
)
for
property_
in
property_dict
[
portal_type
]:
for
property
in
property_dict
[
portal_type
]}
document_dict
[
property_
]
=
document
.
getProperty
(
property_
)
if
ignore_nul_movements
and
portal_type
==
'Simulation Movement'
and
\
rule_dict
[
document
.
getRelativeUrl
()]
=
document_dict
not
(
document_dict
[
'quantity'
]
and
document
.
getPrice
()):
object_list
+=
document
.
objectValues
()
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
return
rule_dict
initial_rule_dict
=
None
initial_rule_dict
=
fillRuleDict
()
initial_rule_dict
=
fillRuleDict
()
try
:
try
:
self
.
expand
(
"immediate"
)
self
.
expand
(
"immediate"
)
...
@@ -420,7 +429,15 @@ class AppliedRule(XMLObject, ExplainableMixin):
...
@@ -420,7 +429,15 @@ class AppliedRule(XMLObject, ExplainableMixin):
msg
=
''
.
join
(
ExceptionFormatter
.
format_exception
(
*
sys
.
exc_info
())[
1
:])
msg
=
''
.
join
(
ExceptionFormatter
.
format_exception
(
*
sys
.
exc_info
())[
1
:])
else
:
else
:
final_rule_dict
=
fillRuleDict
()
final_rule_dict
=
fillRuleDict
()
msg
=
"%r != %r"
%
(
initial_rule_dict
,
final_rule_dict
)
\
if
initial_rule_dict
==
final_rule_dict
:
if
initial_rule_dict
!=
final_rule_dict
else
None
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
()
transaction
.
abort
()
return
msg
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