From 478b0e833d63e31ce222cae6acb006a80d35961d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 7 Aug 2014 13:01:16 +0200
Subject: [PATCH] InvoiceConstraint: properly support sale & purchase invoice

---
 .../start_date_constraint.xml                 |  93 ++++++++++++-
 .../stop_date_constraint.xml                  | 131 ++++++++++++++++++
 bt5/erp5_invoicing/bt/revision                |   2 +-
 3 files changed, 224 insertions(+), 2 deletions(-)
 create mode 100644 bt5/erp5_invoicing/PropertySheetTemplateItem/portal_property_sheets/InvoiceConstraint/stop_date_constraint.xml

diff --git a/bt5/erp5_invoicing/PropertySheetTemplateItem/portal_property_sheets/InvoiceConstraint/start_date_constraint.xml b/bt5/erp5_invoicing/PropertySheetTemplateItem/portal_property_sheets/InvoiceConstraint/start_date_constraint.xml
index bc05cd9d6a..556f1892a6 100644
--- a/bt5/erp5_invoicing/PropertySheetTemplateItem/portal_property_sheets/InvoiceConstraint/start_date_constraint.xml
+++ b/bt5/erp5_invoicing/PropertySheetTemplateItem/portal_property_sheets/InvoiceConstraint/start_date_constraint.xml
@@ -6,6 +6,35 @@
     </pickle>
     <pickle>
       <dictionary>
+        <item>
+            <key> <string>_identity_criterion</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+            </value>
+        </item>
+        <item>
+            <key> <string>_local_properties</string> </key>
+            <value>
+              <tuple>
+                <dictionary>
+                  <item>
+                      <key> <string>id</string> </key>
+                      <value> <string>message_property_not_set</string> </value>
+                  </item>
+                  <item>
+                      <key> <string>type</string> </key>
+                      <value> <string>string</string> </value>
+                  </item>
+                </dictionary>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>_range_criterion</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
+            </value>
+        </item>
         <item>
             <key> <string>constraint_property</string> </key>
             <value>
@@ -22,14 +51,76 @@
             <key> <string>id</string> </key>
             <value> <string>start_date_constraint</string> </value>
         </item>
+        <item>
+            <key> <string>int_index</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>membership_criterion_category</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
         <item>
             <key> <string>message_no_such_property</string> </key>
-            <value> <string>Shipping Date must be defined</string> </value>
+            <value> <string>Invoice Date must be defined</string> </value>
+        </item>
+        <item>
+            <key> <string>message_property_not_set</string> </key>
+            <value> <string>Invoice Date must be defined</string> </value>
         </item>
         <item>
             <key> <string>portal_type</string> </key>
             <value> <string>Property Existence Constraint</string> </value>
         </item>
+        <item>
+            <key> <string>string_index</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>test_method_id</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>test_tales_expression</string> </key>
+            <value> <string>python: context.portal_type in portal.getPortalSaleTypeList()</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <global name="PersistentMapping" module="Persistence.mapping"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>data</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="3" aka="AAAAAAAAAAM=">
+    <pickle>
+      <global name="PersistentMapping" module="Persistence.mapping"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>data</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
       </dictionary>
     </pickle>
   </record>
diff --git a/bt5/erp5_invoicing/PropertySheetTemplateItem/portal_property_sheets/InvoiceConstraint/stop_date_constraint.xml b/bt5/erp5_invoicing/PropertySheetTemplateItem/portal_property_sheets/InvoiceConstraint/stop_date_constraint.xml
new file mode 100644
index 0000000000..b59bd7c47a
--- /dev/null
+++ b/bt5/erp5_invoicing/PropertySheetTemplateItem/portal_property_sheets/InvoiceConstraint/stop_date_constraint.xml
@@ -0,0 +1,131 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="Property Existence Constraint" module="erp5.portal_type"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_identity_criterion</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+            </value>
+        </item>
+        <item>
+            <key> <string>_local_properties</string> </key>
+            <value>
+              <tuple>
+                <dictionary>
+                  <item>
+                      <key> <string>id</string> </key>
+                      <value> <string>message_property_not_set</string> </value>
+                  </item>
+                  <item>
+                      <key> <string>type</string> </key>
+                      <value> <string>string</string> </value>
+                  </item>
+                </dictionary>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>_range_criterion</string> </key>
+            <value>
+              <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
+            </value>
+        </item>
+        <item>
+            <key> <string>constraint_property</string> </key>
+            <value>
+              <tuple>
+                <string>stop_date</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string>Stop Date must be defined</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>stop_date_constraint</string> </value>
+        </item>
+        <item>
+            <key> <string>int_index</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>membership_criterion_category</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>message_no_such_property</string> </key>
+            <value> <string>Invoice Date must be defined</string> </value>
+        </item>
+        <item>
+            <key> <string>message_property_not_set</string> </key>
+            <value> <string>Invoice Date must be defined</string> </value>
+        </item>
+        <item>
+            <key> <string>portal_type</string> </key>
+            <value> <string>Property Existence Constraint</string> </value>
+        </item>
+        <item>
+            <key> <string>string_index</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>test_method_id</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>test_tales_expression</string> </key>
+            <value> <string>python: context.portal_type in portal.getPortalPurchaseTypeList()</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>stop_date</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <global name="PersistentMapping" module="Persistence.mapping"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>data</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="3" aka="AAAAAAAAAAM=">
+    <pickle>
+      <global name="PersistentMapping" module="Persistence.mapping"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>data</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_invoicing/bt/revision b/bt5/erp5_invoicing/bt/revision
index 25493604ef..43f9cb6413 100644
--- a/bt5/erp5_invoicing/bt/revision
+++ b/bt5/erp5_invoicing/bt/revision
@@ -1 +1 @@
-395
\ No newline at end of file
+396
\ No newline at end of file
-- 
2.30.9