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
142
Merge Requests
142
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
009dd3c7
Commit
009dd3c7
authored
Oct 25, 2024
by
Jérome Perrin
1
Browse files
Options
Browse Files
Download
Plain Diff
simulation: introduce Rule.getSimulationMovementSimulationState
See merge request
!2001
parents
22d3da6e
5e21f77f
Pipeline
#37713
failed with stage
in 0 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
42 deletions
+58
-42
bt5/erp5_simplified_invoicing/TestTemplateItem/portal_components/test.erp5.testBPMCore.py
...stTemplateItem/portal_components/test.erp5.testBPMCore.py
+10
-3
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.SimulationMovement.py
...tem/portal_components/document.erp5.SimulationMovement.py
+4
-36
product/ERP5/bootstrap/erp5_core/InterfaceTemplateItem/portal_components/interface.erp5.IRule.py
...aceTemplateItem/portal_components/interface.erp5.IRule.py
+7
-2
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.RuleMixin.py
...xinTemplateItem/portal_components/mixin.erp5.RuleMixin.py
+37
-1
No files found.
bt5/erp5_simplified_invoicing/TestTemplateItem/portal_components/test.erp5.testBPMCore.py
View file @
009dd3c7
...
...
@@ -291,7 +291,10 @@ class TestBPMDummyDeliveryMovementMixin(TestBPMMixin):
# first level rule with simulation movement
self
.
applied_rule
=
self
.
portal
.
portal_simulation
.
newContent
(
portal_type
=
'Applied Rule'
,
causality_value
=
order
)
portal_type
=
'Applied Rule'
,
causality_value
=
order
,
specialise_value
=
self
.
portal
.
portal_rules
.
new_order_root_simulation_rule
,
)
def
setTestClassProperty
(
prefix
,
property_name
,
document
):
if
prefix
:
...
...
@@ -316,7 +319,9 @@ class TestBPMDummyDeliveryMovementMixin(TestBPMMixin):
# second level rule with simulation movement
document
=
setTestClassProperty
(
prefix
,
'delivery_rule'
,
document
.
newContent
(
portal_type
=
'Applied Rule'
))
portal_type
=
'Applied Rule'
,
specialise_value
=
self
.
portal
.
portal_rules
.
new_delivery_simulation_rule
,
))
document
=
setTestClassProperty
(
prefix
,
'delivery_simulation_movement'
,
document
.
newContent
(
portal_type
=
'Simulation Movement'
,
...
...
@@ -329,7 +334,9 @@ class TestBPMDummyDeliveryMovementMixin(TestBPMMixin):
# third level rule with simulation movement
document
=
setTestClassProperty
(
prefix
,
'invoicing_rule'
,
document
.
newContent
(
portal_type
=
'Applied Rule'
))
portal_type
=
'Applied Rule'
,
specialise_value
=
self
.
portal
.
portal_rules
.
new_invoice_simulation_rule
,
))
document
=
setTestClassProperty
(
prefix
,
'invoicing_simulation_movement'
,
document
.
newContent
(
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.SimulationMovement.py
View file @
009dd3c7
...
...
@@ -36,8 +36,6 @@ from Products.ERP5Type.Utils import ensure_list
from
erp5.component.document.Movement
import
Movement
from
erp5.component.module.ExpandPolicy
import
policy_dict
,
TREE_DELIVERED_CACHE_KEY
from
zLOG
import
LOG
,
WARNING
from
Products.ERP5.mixin.property_recordable
import
PropertyRecordableMixin
from
erp5.component.mixin.ExplainableMixin
import
ExplainableMixin
from
erp5.component.interface.IExpandable
import
IExpandable
...
...
@@ -82,22 +80,6 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
- delivered (the movement is now archived in a delivery)
The simulation worklow uses some variables, which are
set by the template
- is_order_required
- is_delivery_required
XX
- is_problem_checking_required ?
Other flag
(forzen flag)
NEW: we do not use DCWorklow so that the simulation process
can be as much as possible independent of a Zope / CMF implementation.
"""
meta_type
=
'ERP5 Simulation Movement'
portal_type
=
'Simulation Movement'
...
...
@@ -144,13 +126,8 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
def
getSimulationState
(
self
,
id_only
=
1
):
"""Returns the current state in simulation
Inherit from delivery or parent (using a conversion table to make orders
planned when parent is confirmed).
In the case of simulation coming from an item, the simulation state is
delegated to the item.
Inherit from delivery when built, otherwise, let the rule decide.
XXX: movements in zero stock rule can not acquire simulation state
"""
delivery
=
self
.
getDeliveryValue
()
if
delivery
is
not
None
:
...
...
@@ -161,18 +138,9 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
return
order
.
getSimulationState
()
applied_rule
=
self
.
getParentValue
()
parent
=
applied_rule
.
getParentValue
()
try
:
if
isinstance
(
parent
,
SimulationMovement
):
return
parent_to_movement_simulation_state
[
parent
.
getSimulationState
()]
getState
=
applied_rule
.
getCausalityValue
()
\
.
aq_explicit
.
getSimulationMovementSimulationState
except
(
AttributeError
,
KeyError
):
LOG
(
'SimulationMovement.getSimulationState'
,
WARNING
,
'Could not acquire simulation state from %s'
%
self
.
getRelativeUrl
(),
error
=
True
)
else
:
return
getState
(
self
)
rule
=
applied_rule
.
getSpecialiseValue
()
if
rule
is
not
None
:
return
rule
.
getSimulationMovementSimulationState
(
self
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getTranslatedSimulationStateTitle'
)
...
...
product/ERP5/bootstrap/erp5_core/InterfaceTemplateItem/portal_components/interface.erp5.IRule.py
View file @
009dd3c7
...
...
@@ -41,7 +41,7 @@ class IRule(IMovementCollectionUpdater):
"""
Create a new applied rule in the context.
An applied rule is an instan
c
iation of a Rule. The applied rule is
An applied rule is an instan
t
iation of a Rule. The applied rule is
linked to the Rule through the `specialise` relation.
context -- usually, a parent simulation movement of the
...
...
@@ -56,7 +56,7 @@ class IRule(IMovementCollectionUpdater):
applied rule.
At expand time, we must replace or compensate certain
properties. However, if some properties were overwriten
properties. However, if some properties were overwrit
t
en
by a decision (ie. a resource if changed), then we
should not try to compensate such a decision. The principles
of compensation are implemented through
...
...
@@ -73,3 +73,8 @@ class IRule(IMovementCollectionUpdater):
Available policies: immediate, deferred, vertical_time_bound
"""
def
getSimulationMovementSimulationState
(
simulation_movement
):
"""
Compute the simulation state of this simulation movement.
"""
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.RuleMixin.py
View file @
009dd3c7
...
...
@@ -26,16 +26,22 @@
#
##############################################################################
import
logging
import
zope.interface
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type.Core.Predicate
import
Predicate
from
erp5.component.module.ExpandPolicy
import
policy_dict
from
erp5.component.document.SimulationMovement
import
SimulationMovement
,
parent_to_movement_simulation_state
from
erp5.component.interface.IRule
import
IRule
from
erp5.component.interface.IDivergenceController
import
IDivergenceController
from
erp5.component.interface.IMovementCollectionUpdater
import
IMovementCollectionUpdater
logger
=
logging
.
getLogger
(
__name__
)
def
_compare
(
tester_list
,
prevision_movement
,
decision_movement
):
for
tester
in
tester_list
:
if
not
tester
.
compare
(
prevision_movement
,
decision_movement
):
...
...
@@ -108,7 +114,7 @@ class RuleMixin(Predicate):
policy_dict
[
expand_policy
](
**
kw
).
expand
(
self
,
applied_rule
)
def
_expandNow
(
self
,
maybe_expand
,
applied_rule
):
# Update moveme
-
nts
# Update movements
# NOTE-JPS: it is OK to make rounding a standard parameter of rules
# although rounding in simulation is not recommended at all
self
.
updateMovementCollection
(
applied_rule
,
...
...
@@ -127,6 +133,36 @@ class RuleMixin(Predicate):
"""
return
not
movement
.
getDelivery
()
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getSimulationMovementSimulationState'
)
def
getSimulationMovementSimulationState
(
self
,
simulation_movement
):
"""
Compute the simulation state of this simulation movement.
Inherit from parent movement, using a conversion table to make
orders planned when parent is confirmed.
In the case of simulation coming from an item, the simulation state is
delegated to the item.
This method can be overridden in custom rule class to generate movements
with a different simulation state.
"""
applied_rule
=
simulation_movement
.
getParentValue
()
parent_simulation_movement
=
applied_rule
.
getParentValue
()
try
:
if
isinstance
(
parent_simulation_movement
,
SimulationMovement
):
return
parent_to_movement_simulation_state
[
parent_simulation_movement
.
getSimulationState
()]
getSimulationMovementSimulationState
=
applied_rule
.
getCausalityValue
()
\
.
aq_explicit
.
getSimulationMovementSimulationState
except
(
AttributeError
,
KeyError
):
logger
.
warning
(
'getSimulationState: Could not acquire simulation state from %s'
,
simulation_movement
,
exc_info
=
True
)
else
:
return
getSimulationMovementSimulationState
(
simulation_movement
)
# Implementation of IDivergenceController # XXX-JPS move to IDivergenceController only mixin for
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'isDivergent'
)
...
...
Jérome Perrin
@jerome
mentioned in merge request
!2001 (merged)
·
Oct 28, 2024
mentioned in merge request
!2001 (merged)
mentioned in merge request !2001
Toggle commit 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