Commit 40aeb240 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_trade: fix DuplicateInventoryConstraint

parent e9728049
......@@ -26,6 +26,8 @@
##############################################################################
from Products.ERP5Type.mixin.constraint import ConstraintMixin
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery
class DuplicateInventoryConstraint(ConstraintMixin):
"""
......@@ -61,7 +63,7 @@ class DuplicateInventoryConstraint(ConstraintMixin):
def _checkConsistency(self, obj, fixit = 0):
"""
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
"""
......@@ -105,13 +107,15 @@ class DuplicateInventoryConstraint(ConstraintMixin):
variation_text=variation_text,
from_date=date, at_date=date,
default_stock_table='stock',
uid = NegatedQuery(SimpleQuery(uid=movement.getUid())),
node=node)
for inventory in inventory_list:
movement = getObjectFromUid(inventory.stock_uid)
if movement.getPortalType().find('Inventory') >= 0:
other_movement = getObjectFromUid(inventory.stock_uid)
if other_movement.getPortalType().find('Inventory') >= 0:
errors.append(self._generateDuplicateError(portal, obj, resource,
variation_text))
# Now we must reindex with some particular tags
if fixit:
activate_kw = {'tag': tag}
movement.reindexObject(activate_kw=activate_kw)
......
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