diff --git a/product/ERP5/Document/DeliveryLine.py b/product/ERP5/Document/DeliveryLine.py index 87958999b64d4e276725c0b8ea9314cf372f3a18..714c21549a53ccdc02e19ab0477c04ed9cf81ce5 100644 --- a/product/ERP5/Document/DeliveryLine.py +++ b/product/ERP5/Document/DeliveryLine.py @@ -485,8 +485,6 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated, # gather delivery relations from simulation movements. delivery_dict = {} for s_m in simulation_movement_list: - for decision in decision_list: - s_m.appendDecision(decision) delivery_path = s_m.getDelivery() delivery_dict[delivery_path] = \ delivery_dict.get(delivery_path, []) + \ @@ -513,9 +511,6 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated, solve_result_list = [] # accept + split for decision in [q for q in decision_list if q.decision != 'adopt']: - for simulation_movement in self.getDeliveryRelatedValueList( - portal_type='Simulation Movement'): - simulation_movement.appendDecision(decision) if decision.decision == 'accept': # accepting - in case of passed DeliverySolver use it, otherwise # simply copy values to simulation @@ -532,5 +527,4 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated, adopt_decision_list = [q for q in decision_list \ if q.decision == 'adopt'] if adopt_decision_list: - # XXX/FIXME appendDecision in this case self._updatePropertyFromSimulation(adopt_decision_list) diff --git a/product/ERP5/Document/Rule.py b/product/ERP5/Document/Rule.py index a8529e058e6e97878957dd379206b13e2d315056..01f068b3453c05244fef8e102a4ffc048ea4f4ba 100644 --- a/product/ERP5/Document/Rule.py +++ b/product/ERP5/Document/Rule.py @@ -372,26 +372,19 @@ class Rule(Predicate, XMLObject): m_quantity += movement.getQuantity() 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()), WARNING, - 'Quantity forced to stay as %s, even if wanted %s' % (m_quantity, prevision.get('quantity'))) - # DivergenceSolutionDecision mangle - pass + 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.getQuantity() + \ + q_diff + break else: - 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.getQuantity() + \ - q_diff - break - else: - # no modifiable movement was found, need to compensate by quantity - raise NotImplementedError('Need to generate quantity compensation') + # 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 \ diff --git a/product/ERP5/Document/SimulationMovement.py b/product/ERP5/Document/SimulationMovement.py index b3ffa39e2e34cdbcd9aa1ae934f2429f8b9b968a..6544aa3856b595173c7a8e30f49bc5c318ea1d19 100644 --- a/product/ERP5/Document/SimulationMovement.py +++ b/product/ERP5/Document/SimulationMovement.py @@ -571,38 +571,6 @@ class SimulationMovement(Movement, PropertyRecordableMixin): return False return True - security.declareProtected( Permissions.ModifyPortalContent, - 'appendDecision') - def appendDecision(self, decision): - """Appends decision, optionally initialises""" - property = decision.divergence.tested_property - if getattr(aq_base(self), 'divergence_solution_history', None) is None: - # initialise divergence history mapping - self.divergence_solution_history = PersistentMapping() - if self.divergence_solution_history.get(property, None) is None: - self.divergence_solution_history[property] = WorkflowHistoryList() - self.divergence_solution_history[property].append(decision) - - security.declareProtected( Permissions.AccessContentsInformation, - 'isPropertyForced') - def isPropertyForced(self, property): - """Check if property was forced by user""" - divergence_solution_history = getattr(aq_base(self), - 'divergence_solution_history', None) - if divergence_solution_history is None: - return False - - for decision in divergence_solution_history.get(property, [])[::-1]: - # fuzzy logic: - # * if there was accept decision with force - force - # * but if there was accept without force after - do not force - # To be discussed. - if decision.decision == 'accept': - if decision.force_property: - return True - return False - return False - def getSolverProcessValueList(self, movement=None, validation_state=None): """ Returns the list of solver processes which are diff --git a/product/ERP5/TargetSolver/SplitAndDefer.py b/product/ERP5/TargetSolver/SplitAndDefer.py index 6d7edc5aade0636983e6b269575cdf6ffcfc511b..c109dbf049bbfc163529392e3140f84f0c0803da 100644 --- a/product/ERP5/TargetSolver/SplitAndDefer.py +++ b/product/ERP5/TargetSolver/SplitAndDefer.py @@ -55,7 +55,6 @@ class SplitAndDefer(CopyToTarget): applied_rule = simulation_movement.getParentValue() rule = applied_rule.getSpecialiseValue() expandable_property_list = [] - forced_property_list = [] if getattr(rule, 'getExpandablePropertyList', None) is not None: expandable_property_list = rule.getExpandablePropertyList() @@ -86,24 +85,12 @@ class SplitAndDefer(CopyToTarget): if prop not in movement_dict: # XXX: better way to filter out movement_dict.update(**{ prop: simulation_movement.getProperty(prop)}) - if simulation_movement.isPropertyForced(prop): - # set same forcing on fresh movement - XXX might be good, - # might be wrong - forced_property_list.append(prop) new_movement = applied_rule.newContent(**movement_dict) new_movement.recordProperty('start_date') new_movement.recordProperty('stop_date') new_movement.edit(start_date=self.start_date, stop_date=self.stop_date) new_movement.activate(**self.additional_parameters).expand() - # XXX: start and stop date have to be forced on movement too - forced_property_list.extend(['start_date', 'stop_date']) - for prop in forced_property_list: - fake_divergence = DivergenceMessage() - fake_divergence.tested_property = prop - decision = DivergenceSolutionDecision(fake_divergence, 'accept', None, None, - True) - new_movement.appendDecision(decision) else: new_movement = applied_rule.newContent( portal_type="Simulation Movement",