diff --git a/product/ERP5/Document/BaseVariantMovementGroup.py b/product/ERP5/Document/BaseVariantMovementGroup.py index 5475da335e196f949229a4798a8bfbf981202205..63cd720198b05d2edd1bc1b8e7138ee9adeebd45 100644 --- a/product/ERP5/Document/BaseVariantMovementGroup.py +++ b/product/ERP5/Document/BaseVariantMovementGroup.py @@ -44,13 +44,6 @@ class BaseVariantMovementGroup(MovementGroup): property_dict['_base_category_list'] = category_list return property_dict - def test(self, object, property_dict): - category_list = object.getVariationBaseCategoryList() - if category_list is None: - category_list = [] - category_list.sort() - return property_dict['_base_category_list'] == category_list - - def testToUpdate(self, object, property_dict, **kw): + def test(self, object, property_dict, **kw): # This movement group does not affect updating. return True, {} diff --git a/product/ERP5/Document/CategoryMovementGroup.py b/product/ERP5/Document/CategoryMovementGroup.py index 44a64ea6c8a405439f8cf1e08d35a207785850d4..5427de8e64bd43e7548ba5747e97e3e3bc0d3a5e 100644 --- a/product/ERP5/Document/CategoryMovementGroup.py +++ b/product/ERP5/Document/CategoryMovementGroup.py @@ -41,7 +41,8 @@ class CategoryMovementGroup(PropertyMovementGroup): def _getPropertyDict(self, movement, **kw): property_dict = {} for prop in self.getTestedPropertyList(): - property_dict['%s_list' % prop] = movement.getPropertyList(prop, None) + property_dict['%s_list' % prop] = sorted( + movement.getPropertyList(prop, None)) return property_dict def test(self, object, property_dict, property_list=None, **kw): @@ -51,7 +52,7 @@ class CategoryMovementGroup(PropertyMovementGroup): else: target_property_list = self.getTestedPropertyList() for prop in target_property_list: - if sorted(property_dict['%s_list' % prop]) != \ + if property_dict['%s_list' % prop] != \ sorted(object.getPropertyList(prop, None)): - return False - return True + return False, property_dict + return True, property_dict diff --git a/product/ERP5/Document/CausalityAssignmentMovementGroup.py b/product/ERP5/Document/CausalityAssignmentMovementGroup.py index 958c4dd31f15073798a631efc59d0089e79c39a3..f36c6af94ee75f9587a59b0bdca6d229434cdfb3 100644 --- a/product/ERP5/Document/CausalityAssignmentMovementGroup.py +++ b/product/ERP5/Document/CausalityAssignmentMovementGroup.py @@ -47,7 +47,7 @@ class CausalityAssignmentMovementGroup(MovementGroup): self._addCausalityToEdit(movement, property_dict) return [[movement_list, property_dict]] - def testToUpdate(self, movement, property_dict, **kw): + def test(self, movement, property_dict, **kw): # We can always update. return True, property_dict diff --git a/product/ERP5/Document/CausalityMovementGroup.py b/product/ERP5/Document/CausalityMovementGroup.py index 39d9600db57d86a5b960213bc12eb8dbb91b7084..884a96cd6675aabf268616e86851bd1ec4b0ba66 100644 --- a/product/ERP5/Document/CausalityMovementGroup.py +++ b/product/ERP5/Document/CausalityMovementGroup.py @@ -42,7 +42,7 @@ class CausalityMovementGroup(MovementGroup): property_dict['_explanation'] = explanation_relative_url return property_dict - def testToUpdate(self, movement, property_dict, **kw): + def test(self, movement, property_dict, **kw): # we don't care the difference of explanation url when updating #return True, property_dict return True, {} diff --git a/product/ERP5/Document/MovementGroup.py b/product/ERP5/Document/MovementGroup.py index a3a1836764c641425a19ff5f8da06bea4c84400c..7369ef3d4a88cd06db185b69d43c7538c2ec2c06 100644 --- a/product/ERP5/Document/MovementGroup.py +++ b/product/ERP5/Document/MovementGroup.py @@ -54,6 +54,10 @@ class MovementGroup(XMLObject): # This method should be defined in sub classes. raise NotImplementedError + def test(self, object, property_dict, **kw): + # This method should be defined in sub classes. + raise NotImplementedError + def _separate(self, movement_list): # By default, we separate movements by _getPropertyDict() values. # You can override this method in each MovementGroup class. @@ -75,12 +79,3 @@ class MovementGroup(XMLObject): return sorted([[sorted(x[0], lambda a,b:cmp(a.getId(), b.getId())), x[1]] \ for x in self._separate(movement_list)], lambda a,b: cmp(a[0][0].getId(), b[0][0].getId())) - - def test(self, object, property_dict, **kw): - raise NotImplementedError - - def testToUpdate(self, object, property_dict, **kw): - if self.test(object, property_dict, **kw): - return True, property_dict - else: - return False, property_dict diff --git a/product/ERP5/Document/OrderBuilder.py b/product/ERP5/Document/OrderBuilder.py index 1fdc226d5b08c3b80ce04f4c60b9a40cc58bf38c..993f1ed2bbfc81d68344418bc9e3aa07039ab64d 100644 --- a/product/ERP5/Document/OrderBuilder.py +++ b/product/ERP5/Document/OrderBuilder.py @@ -235,12 +235,12 @@ class OrderBuilder(XMLObject, Amount, Predicate): my_root_group.append(movement_list) return my_root_group - def _testToUpdate(self, instance, movement_group_list, + def _test(self, instance, movement_group_list, divergence_list): result = True new_property_dict = {} for movement_group in movement_group_list: - tmp_result, tmp_property_dict = movement_group.testToUpdate( + tmp_result, tmp_property_dict = movement_group.test( instance, divergence_list) if tmp_result == False: result = tmp_result @@ -266,7 +266,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): instance_list.sort(lambda a,b:cmp(b.getId()==original_id, a.getId()==original_id)) for instance_to_update in instance_list: - result, property_dict = self._testToUpdate( + result, property_dict = self._test( instance_to_update, movement_group_list, divergence_list) if result == True: instance = instance_to_update diff --git a/product/ERP5/Document/OrderMovementGroup.py b/product/ERP5/Document/OrderMovementGroup.py index 1e3d69afa35f566a17968e7a2f931384d02e5bc1..b97b8d5db5bc797b9dd8c67222f8bd849b3781fd 100644 --- a/product/ERP5/Document/OrderMovementGroup.py +++ b/product/ERP5/Document/OrderMovementGroup.py @@ -44,7 +44,7 @@ class OrderMovementGroup(MovementGroup): property_dict['causality'] = order_relative_url return property_dict - def testToUpdate(self, movement, property_dict, **kw): + def test(self, movement, property_dict, **kw): if movement.getCausality() == property_dict['causality']: return True, property_dict else: diff --git a/product/ERP5/Document/ParentExplanationMovementGroup.py b/product/ERP5/Document/ParentExplanationMovementGroup.py index 9daca66ebfb33ca76e335ae8d90489336a2af68c..d356a1fb4acaf0b8881d8ae44ec47a836ca1e413 100644 --- a/product/ERP5/Document/ParentExplanationMovementGroup.py +++ b/product/ERP5/Document/ParentExplanationMovementGroup.py @@ -45,6 +45,9 @@ class ParentExplanationMovementGroup(MovementGroup): property_dict['parent_explanation_value'] = parent_explanation_value return property_dict - def test(self, object, property_dict, property_list=None, **kw): - return object.getParentExplanationValue() == \ - property_dict['parent_explanation_value'] + def test(self, object, property_dict, **kw): + if object.getParentExplanationValue() == \ + property_dict['parent_explanation_value']: + return True, property_dict + else: + return False, property_dict diff --git a/product/ERP5/Document/PropertyMovementGroup.py b/product/ERP5/Document/PropertyMovementGroup.py index b5817bcd49dbda6628c63282ea7bf4308e0728d0..2f469538f9f1b31ba87eb31f44fac558d316ac36 100644 --- a/product/ERP5/Document/PropertyMovementGroup.py +++ b/product/ERP5/Document/PropertyMovementGroup.py @@ -52,5 +52,5 @@ class PropertyMovementGroup(MovementGroup): target_property_list = self.getTestedPropertyList() for prop in target_property_list: if property_dict[prop] != object.getProperty(prop, None): - return False - return True + return False, property_dict + return True, property_dict diff --git a/product/ERP5/Document/QuantitySignMovementGroup.py b/product/ERP5/Document/QuantitySignMovementGroup.py index a47abe9bb86b7c65478e19adf77ae2b92e7dcd03..e27e175495568ab18bb2674085dc09f2c3dc6a79 100644 --- a/product/ERP5/Document/QuantitySignMovementGroup.py +++ b/product/ERP5/Document/QuantitySignMovementGroup.py @@ -65,17 +65,6 @@ class QuantitySignMovementGroup(MovementGroup): ] def test(self, object, property_dict, **kw): - quantity = object.getQuantity() - sign1 = property_dict['quantity_sign'] - sign2 = cmp(quantity, 0) - if sign2 == 0: - return 1 - if sign1 == 0: - property_dict['quantity_sign'] = sign2 - return 1 - return sign1 == sign2 - - def testToUpdate(self, object, property_dict, **kw): if object.getQuantitySign() == property_dict['quantity_sign']: return True, property_dict else: diff --git a/product/ERP5/Document/RequirementMovementGroup.py b/product/ERP5/Document/RequirementMovementGroup.py index 996748307aa2fd467924119d4d5a43d67ed3e62f..b0fc91ec8c58f1ebed0907a236e51233cd9e72fe 100644 --- a/product/ERP5/Document/RequirementMovementGroup.py +++ b/product/ERP5/Document/RequirementMovementGroup.py @@ -38,7 +38,7 @@ class RequirementMovementGroup(MovementGroup): def _getPropertyDict(self, movement, **kw): return {'requirement':self._getRequirementList(movement)} - def testToUpdate(self, movement, property_dict, **kw): + def test(self, movement, property_dict, **kw): # We can always update return True, property_dict diff --git a/product/ERP5/Document/RootAppliedRuleCausalityMovementGroup.py b/product/ERP5/Document/RootAppliedRuleCausalityMovementGroup.py index faf1c1c230e3a862312f08038efb4915f997316d..99c4ff0c2763635f24fc4e507fe793f4b86ed82b 100644 --- a/product/ERP5/Document/RootAppliedRuleCausalityMovementGroup.py +++ b/product/ERP5/Document/RootAppliedRuleCausalityMovementGroup.py @@ -44,7 +44,7 @@ class RootAppliedRuleCausalityMovementGroup(MovementGroup): property_dict['root_causality_value_list'] = [root_causality_value] return property_dict - def testToUpdate(self, movement, property_dict, **kw): + def test(self, movement, property_dict, **kw): # We can always update return True, property_dict diff --git a/product/ERP5/Document/SplitMovementGroup.py b/product/ERP5/Document/SplitMovementGroup.py index becdb685d797b215562a3d16066801bc9b8cb008..02aa9422fa702d1188eeb0a9ca354a342831de16 100644 --- a/product/ERP5/Document/SplitMovementGroup.py +++ b/product/ERP5/Document/SplitMovementGroup.py @@ -38,7 +38,7 @@ class SplitMovementGroup(MovementGroup): def _getPropertyDict(self, movement, **kw): return {} - def testToUpdate(self, object, property_dict, **kw): + def test(self, object, property_dict, **kw): return True, property_dict def _separate(self, movement_list): diff --git a/product/ERP5/Document/TitleMovementGroup.py b/product/ERP5/Document/TitleMovementGroup.py index 00e23558493b3f42bbfe7d246464796f6fedb573..5f6823fa5f1e1267c5b36bbc2f7627869aab51e0 100644 --- a/product/ERP5/Document/TitleMovementGroup.py +++ b/product/ERP5/Document/TitleMovementGroup.py @@ -41,9 +41,6 @@ class TitleMovementGroup(MovementGroup): return property_dict def test(self, object, property_dict, **kw): - return self._getTitle(object) == property_dict['title'] - - def testToUpdate(self, object, property_dict, **kw): # If title is different, we want to update existing object instead # of creating a new one. return True, property_dict diff --git a/product/ERP5/Document/VariantMovementGroup.py b/product/ERP5/Document/VariantMovementGroup.py index bce59757698690bd4293dd5db823d67de4b3c0ae..b0ae4dd9d6dcd5e55fb3c38b0f56d1114928dcc0 100644 --- a/product/ERP5/Document/VariantMovementGroup.py +++ b/product/ERP5/Document/VariantMovementGroup.py @@ -49,4 +49,7 @@ class VariantMovementGroup(MovementGroup): if category_list is None: category_list = [] category_list.sort() - return property_dict['variation_category_list'] == category_list + if property_dict['variation_category_list'] == category_list: + return True, property_dict + else: + return False, property_dict diff --git a/product/ERP5/MovementGroup.py b/product/ERP5/MovementGroup.py index 08fe72de01201266d8db7cbdaf3af69fe53b9657..7b8a6756069cf8f30772c52b58dd4923a0cb3a44 100644 --- a/product/ERP5/MovementGroup.py +++ b/product/ERP5/MovementGroup.py @@ -132,7 +132,7 @@ class MovementGroupNode: else: return movement - def testToUpdate(self, movement, divergence_list): + def test(self, movement, divergence_list): # Try to check if movement is updatable or not. # # 1. if Divergence has no scope: update anyway. @@ -155,7 +155,7 @@ class MovementGroupNode: if not len(related_divergence_list): return True, {} property_list = [x.tested_property for x in related_divergence_list] - return self._movement_group.testToUpdate(movement, self._property_dict, + return self._movement_group.test(movement, self._property_dict, property_list=property_list) else: return True, {}