[Erp5-report] r28491 - /erp5/trunk/products/ERP5/Document/BPMRule.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Aug 20 14:07:44 CEST 2009
Author: luke
Date: Thu Aug 20 14:07:42 2009
New Revision: 28491
URL: http://svn.erp5.org?rev=28491&view=rev
Log:
- implement draft of stable expand which is using divergence_history on movement to know when property is forced or not
Modified:
erp5/trunk/products/ERP5/Document/BPMRule.py
Modified: erp5/trunk/products/ERP5/Document/BPMRule.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BPMRule.py?rev=28491&r1=28490&r2=28491&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BPMRule.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BPMRule.py [utf8] Thu Aug 20 14:07:42 2009
@@ -35,6 +35,7 @@
from Products.ERP5Type.XMLObject import XMLObject
from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName
+from zLOG import LOG
class BPMRule(Predicate, XMLObject):
"""
@@ -260,17 +261,11 @@
for prevision in prevision_list:
p_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)
+ for prop in self.getMatchingPropertyList():
+ if prevision.get(prop) != movement.getProperty(prop):
+ break
else:
- # applied rule is not root one, match
- for prop in self.getMatchingPropertyList():
- if prevision.get(prop) != movement.getProperty(prop):
- break
- else:
- p_matched_list.append(movement)
+ p_matched_list.append(movement)
# Movements exist, we'll try to make them match the prevision
if p_matched_list != []:
@@ -279,35 +274,42 @@
for movement in p_matched_list:
m_quantity += movement.getQuantity()#getCorrectedQuantity()
if m_quantity != prevision.get('quantity'):
- q_diff = prevision.get('quantity') - m_quantity
- # 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
+ # 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:
- # no modifiable movement was found, need to compensate by quantity
- raise NotImplementedError('Need to generate quantity compensation')
-
- # Check the date
+ q_diff = prevision.get('quantity') - m_quantity
+ # 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')
+
for movement in p_matched_list:
if movement in (mutable_movement_list \
+ deletable_movement_list):
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():
- if k not in ('quantity', 'start_date', 'stop_date') and \
- v != movement.getProperty(k):
+ if k not in ('quantity',) and 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)
# update movement lists
More information about the Erp5-report
mailing list