Commit 419cb62b authored by Sebastien Robin's avatar Sebastien Robin

make DuplicateInventoryConstraint a new style constraint

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43548 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 480daf6c
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Constraint_view</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
# #
############################################################################## ##############################################################################
from Products.ERP5Type.Constraint import Constraint from Products.ERP5Type.mixin.constraint import ConstraintMixin
from zLOG import LOG from zLOG import LOG
class DuplicateInventory(Constraint): class DuplicateInventoryConstraint(ConstraintMixin):
""" """
We want to check here that there is not 2 or more inventories with: We want to check here that there is not 2 or more inventories with:
- the same resource - the same resource
...@@ -36,7 +36,7 @@ class DuplicateInventory(Constraint): ...@@ -36,7 +36,7 @@ class DuplicateInventory(Constraint):
- the same node - the same node
""" """
def generateDuplicateError(self, portal, obj, resource, variation_text): def _generateDuplicateError(self, portal, obj, resource, variation_text):
""" """
Use a single method in order to generate the message Use a single method in order to generate the message
""" """
...@@ -59,7 +59,7 @@ class DuplicateInventory(Constraint): ...@@ -59,7 +59,7 @@ class DuplicateInventory(Constraint):
mapping={'variation_title' : variation_title, mapping={'variation_title' : variation_title,
'resource_title' : resource_title}) 'resource_title' : resource_title})
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
...@@ -98,7 +98,7 @@ class DuplicateInventory(Constraint): ...@@ -98,7 +98,7 @@ class DuplicateInventory(Constraint):
resource_and_variation_list.append((resource,variation_text)) resource_and_variation_list.append((resource,variation_text))
tag = '%s_%s_%s' % (date_string, resource, variation_text) tag = '%s_%s_%s' % (date_string, resource, variation_text)
if countMessageWithTag(tag) > 0 : if countMessageWithTag(tag) > 0 :
errors.append(self.generateDuplicateError(portal, obj, resource, errors.append(self._generateDuplicateError(portal, obj, resource,
variation_text)) variation_text))
# Call sql request in order to see if there is another inventory # Call sql request in order to see if there is another inventory
# for this node, resource, variation_text and date # for this node, resource, variation_text and date
...@@ -110,7 +110,7 @@ class DuplicateInventory(Constraint): ...@@ -110,7 +110,7 @@ class DuplicateInventory(Constraint):
for inventory in inventory_list: for inventory in inventory_list:
movement = getObjectFromUid(inventory.stock_uid) movement = getObjectFromUid(inventory.stock_uid)
if movement.getPortalType().find('Inventory') >= 0: if 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} activate_kw = {'tag': tag}
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Base Type" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_property_domain_dict</string> </key>
<value>
<dictionary>
<item>
<key> <string>short_title</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>content_icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Duplicate Inventory Constraint</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Base Type</string> </value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>DuplicateInventoryConstraint</string> </value>
</item>
<item>
<key> <string>type_interface</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TranslationInformation" module="Products.ERP5Type.TranslationProviderBase"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>domain_name</string> </key>
<value> <string>erp5_content</string> </value>
</item>
<item>
<key> <string>property_name</string> </key>
<value> <string>short_title</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TranslationInformation" module="Products.ERP5Type.TranslationProviderBase"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>domain_name</string> </key>
<value> <string>erp5_content</string> </value>
</item>
<item>
<key> <string>property_name</string> </key>
<value> <string>title</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
1103 1104
\ No newline at end of file \ No newline at end of file
...@@ -9,6 +9,7 @@ Container | view ...@@ -9,6 +9,7 @@ Container | view
Delivery Cell | view Delivery Cell | view
Delivery Root Simulation Rule | view Delivery Root Simulation Rule | view
Delivery Simulation Rule | view Delivery Simulation Rule | view
Duplicate Inventory Constraint | view
First Causality Movement Group | view First Causality Movement Group | view
Internal Order Cell | view Internal Order Cell | view
Internal Order Line | price_view Internal Order Line | price_view
......
DuplicateInventory
\ No newline at end of file
DuplicateInventoryConstraint
\ No newline at end of file
...@@ -7,6 +7,7 @@ Container Line ...@@ -7,6 +7,7 @@ Container Line
Delivery Cell Delivery Cell
Delivery Root Simulation Rule Delivery Root Simulation Rule
Delivery Simulation Rule Delivery Simulation Rule
Duplicate Inventory Constraint
First Causality Movement Group First Causality Movement Group
Internal Order Internal Order
Internal Order Cell Internal Order Cell
......
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