Commit 3518b976 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_trade: fix DuplicateInventoryConstraint

parent fb2d2f65
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
############################################################################## ##############################################################################
from Products.ERP5Type.mixin.constraint import ConstraintMixin from Products.ERP5Type.mixin.constraint import ConstraintMixin
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery
class DuplicateInventoryConstraint(ConstraintMixin): class DuplicateInventoryConstraint(ConstraintMixin):
""" """
...@@ -61,7 +63,7 @@ class DuplicateInventoryConstraint(ConstraintMixin): ...@@ -61,7 +63,7 @@ class DuplicateInventoryConstraint(ConstraintMixin):
def _checkConsistency(self, obj, fixit = 0): def _checkConsistency(self, obj, fixit = 0):
""" """
Implement here the consistency checker Implement here the consistency checker
whenever fixit is not 0, object data should be updated to whenever fixit is not 0, object data should be updated to -----> NON
satisfy the constraint satisfy the constraint
""" """
...@@ -105,14 +107,16 @@ class DuplicateInventoryConstraint(ConstraintMixin): ...@@ -105,14 +107,16 @@ class DuplicateInventoryConstraint(ConstraintMixin):
variation_text=variation_text, variation_text=variation_text,
from_date=date, at_date=date, from_date=date, at_date=date,
default_stock_table='stock', default_stock_table='stock',
uid = NegatedQuery(SimpleQuery(uid=movement.getUid())),
node=node) node=node)
for inventory in inventory_list: for inventory in inventory_list:
movement = getObjectFromUid(inventory.stock_uid) other_movement = getObjectFromUid(inventory.stock_uid)
if movement.getPortalType().find('Inventory') >= 0: if other_movement.getPortalType().find('Inventory') >= 0:
errors.append(self._generateDuplicateError(portal, obj, resource, errors.append(self._generateDuplicateError(portal, obj, resource,
variation_text)) variation_text))
# Now we must reindex with some particular tags # Now we must reindex with some particular tags
activate_kw = {'tag': tag} if fixit:
movement.reindexObject(activate_kw=activate_kw) activate_kw = {'tag': tag}
movement.reindexObject(activate_kw=activate_kw)
return errors return errors
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