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,17 +261,11 @@ class BPMRule(Predicate, XMLObject): ...@@ -260,17 +261,11 @@ 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: for prop in self.getMatchingPropertyList():
# applied rule is root, use order link to find movement if prevision.get(prop) != movement.getProperty(prop):
if movement.getOrder() == prevision.get('order_list', [''])[0]: break
p_matched_list.append(movement)
else: else:
# applied rule is not root one, match p_matched_list.append(movement)
for prop in self.getMatchingPropertyList():
if prevision.get(prop) != movement.getProperty(prop):
break
else:
p_matched_list.append(movement)
# Movements exist, we'll try to make them match the prevision # Movements exist, we'll try to make them match the prevision
if p_matched_list != []: if p_matched_list != []:
...@@ -279,35 +274,42 @@ class BPMRule(Predicate, XMLObject): ...@@ -279,35 +274,42 @@ 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'):
q_diff = prevision.get('quantity') - m_quantity # special case - quantity
# try to find a movement that can be edited if movement.isPropertyForced('quantity'):
for movement in p_matched_list: # TODO: support compensation if not prevent_compensation
if movement in (mutable_movement_list \ LOG('%s:%s' % (self.getRelativeUrl(), movement.getRelativeUrl()), 100,
+ deletable_movement_list): 'Quantity forced to stay as %s, even if wanted %s' % (m_quantity, prevision.get('quantity')))
# mark as requiring modification # DivergenceDecision mangle
prop_dict = modify_dict.setdefault(movement.getId(), {}) pass
#prop_dict['quantity'] = movement.getCorrectedQuantity() + \
prop_dict['quantity'] = movement.getQuantity() + \
q_diff
break
else: else:
# no modifiable movement was found, need to compensate by quantity q_diff = prevision.get('quantity') - m_quantity
raise NotImplementedError('Need to generate quantity compensation') # try to find a movement that can be edited
for movement in p_matched_list:
if movement in (mutable_movement_list \
+ deletable_movement_list):
# mark as requiring modification
prop_dict = modify_dict.setdefault(movement.getId(), {})
#prop_dict['quantity'] = movement.getCorrectedQuantity() + \
prop_dict['quantity'] = movement.getQuantity() + \
q_diff
break
else:
# no modifiable movement was found, need to compensate by quantity
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