Commit 730b9bb2 authored by Łukasz Nowak's avatar Łukasz Nowak

- implement draft of stable expand which is using divergence_history on...

 - implement draft of stable expand which is using divergence_history on movement to know when property is forced or not


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28491 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7204c691
...@@ -35,6 +35,7 @@ from Products.ERP5.Document.Predicate import Predicate ...@@ -35,6 +35,7 @@ from Products.ERP5.Document.Predicate import Predicate
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Acquisition import aq_base from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from zLOG import LOG
class BPMRule(Predicate, XMLObject): class BPMRule(Predicate, XMLObject):
""" """
...@@ -260,12 +261,6 @@ class BPMRule(Predicate, XMLObject): ...@@ -260,12 +261,6 @@ class BPMRule(Predicate, XMLObject):
for prevision in prevision_list: for prevision in prevision_list:
p_matched_list = [] p_matched_list = []
for movement in non_matched_list: for movement in non_matched_list:
if 'order_list' in prevision:
# applied rule is root, use order link to find movement
if movement.getOrder() == prevision.get('order_list', [''])[0]:
p_matched_list.append(movement)
else:
# applied rule is not root one, match
for prop in self.getMatchingPropertyList(): for prop in self.getMatchingPropertyList():
if prevision.get(prop) != movement.getProperty(prop): if prevision.get(prop) != movement.getProperty(prop):
break break
...@@ -279,6 +274,14 @@ class BPMRule(Predicate, XMLObject): ...@@ -279,6 +274,14 @@ class BPMRule(Predicate, XMLObject):
for movement in p_matched_list: for movement in p_matched_list:
m_quantity += movement.getQuantity()#getCorrectedQuantity() m_quantity += movement.getQuantity()#getCorrectedQuantity()
if m_quantity != prevision.get('quantity'): if m_quantity != prevision.get('quantity'):
# special case - quantity
if movement.isPropertyForced('quantity'):
# TODO: support compensation if not prevent_compensation
LOG('%s:%s' % (self.getRelativeUrl(), movement.getRelativeUrl()), 100,
'Quantity forced to stay as %s, even if wanted %s' % (m_quantity, prevision.get('quantity')))
# DivergenceDecision mangle
pass
else:
q_diff = prevision.get('quantity') - m_quantity q_diff = prevision.get('quantity') - m_quantity
# try to find a movement that can be edited # try to find a movement that can be edited
for movement in p_matched_list: for movement in p_matched_list:
...@@ -294,20 +297,19 @@ class BPMRule(Predicate, XMLObject): ...@@ -294,20 +297,19 @@ class BPMRule(Predicate, XMLObject):
# no modifiable movement was found, need to compensate by quantity # no modifiable movement was found, need to compensate by quantity
raise NotImplementedError('Need to generate quantity compensation') raise NotImplementedError('Need to generate quantity compensation')
# Check the date
for movement in p_matched_list: for movement in p_matched_list:
if movement in (mutable_movement_list \ if movement in (mutable_movement_list \
+ deletable_movement_list): + deletable_movement_list):
prop_dict = modify_dict.setdefault(movement.getId(), {}) prop_dict = modify_dict.setdefault(movement.getId(), {})
for prop in ('start_date', 'stop_date'):
#XXX should be >= 15
if prevision.get(prop) != movement.getProperty(prop):
prop_dict[prop] = prevision.get(prop)
break
for k, v in prevision.items(): for k, v in prevision.items():
if k not in ('quantity', 'start_date', 'stop_date') and \ if k not in ('quantity',) and v != movement.getProperty(k):
v != movement.getProperty(k): # TODO: acceptance range
if movement.isPropertyForced(k):
# support compensation if not prevent_compensation
LOG('%s:%s' % (self.getRelativeUrl(), movement.getRelativeUrl()), 100,
'Property %s forced to stay as %r, even if wanted %r' % (k, movement.getProperty(k), v))
# DivergenceDecision mangle
continue
prop_dict.setdefault(k, v) prop_dict.setdefault(k, v)
# update movement lists # update movement lists
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment