From c64d4287e9ddede06ac59e03988fb0148ca5e37e Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Wed, 4 May 2011 19:15:48 +0200 Subject: [PATCH] on movement collections, use list of properties defined in rules Until now, we had in movement collections all possible properties found by _propertyMap for every movement. Now movement collections use list of properties defined in rules. This change was breaking some tests because not enough properties were expanded, so in the same time it is required to add more properties to progagate on several rules --- .../causality_tester.xml | 84 ++++++++++++ .../causality_tester.xml | 90 +++++++++++++ .../trade_phase_tester.xml | 84 ++++++++++++ .../causality_tester.xml | 84 ++++++++++++ .../causality_tester.xml | 90 +++++++++++++ ...ew_invoice_transaction_simulation_rule.xml | 24 ++++ .../causality_tester.xml | 84 ++++++++++++ .../trade_phase_tester.xml | 84 ++++++++++++ .../causality_tester.xml | 84 ++++++++++++ .../trade_phase_tester.xml | 84 ++++++++++++ .../trade_phase_tester.xml | 84 ++++++++++++ .../causality_tester.xml | 84 ++++++++++++ .../price_tester.xml | 125 ++++++++++++++++++ bt5/erp5_simulation_test/bt/revision | 2 +- product/ERP5/Document/BusinessProcess.py | 16 ++- product/ERP5/Document/QuantitySplitSolver.py | 7 +- product/ERP5/MovementCollectionDiff.py | 22 ++- .../interfaces/movement_collection_updater.py | 16 ++- .../ERP5/mixin/movement_collection_updater.py | 16 ++- product/ERP5/mixin/rule.py | 18 ++- 20 files changed, 1159 insertions(+), 23 deletions(-) create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_root_simulation_rule/causality_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_simulation_rule/causality_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_simulation_rule/trade_phase_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_root_simulation_rule/causality_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_simulation_rule/causality_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule/causality_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule/trade_phase_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_order_root_simulation_rule/causality_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_order_root_simulation_rule/trade_phase_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_payment_simulation_rule/trade_phase_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_trade_model_simulation_rule/causality_tester.xml create mode 100644 bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_trade_model_simulation_rule/price_tester.xml diff --git a/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_root_simulation_rule/causality_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_root_simulation_rule/causality_tester.xml new file mode 100644 index 0000000000..f57d31a314 --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_root_simulation_rule/causality_tester.xml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>causality_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>causality_list</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>causality divergence tester</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_simulation_test/PathTemplateItem/portal_rules/new_delivery_simulation_rule/causality_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_simulation_rule/causality_tester.xml new file mode 100644 index 0000000000..ded5ccab47 --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_simulation_rule/causality_tester.xml @@ -0,0 +1,90 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>causality_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>causality_list</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>causality divergence tester</string> </value> + </item> + </dictionary> + </pickle> + </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <tuple> + <global name="PersistentMapping" module="Persistence.mapping"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="3" aka="AAAAAAAAAAM="> + <pickle> + <tuple> + <global name="PersistentMapping" module="Persistence.mapping"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_simulation_rule/trade_phase_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_simulation_rule/trade_phase_tester.xml new file mode 100644 index 0000000000..ebbaf50bfa --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_delivery_simulation_rule/trade_phase_tester.xml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>trade_phase_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>trade_phase</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>trade_phase divergence tester</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_simulation_test/PathTemplateItem/portal_rules/new_invoice_root_simulation_rule/causality_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_root_simulation_rule/causality_tester.xml new file mode 100644 index 0000000000..f57d31a314 --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_root_simulation_rule/causality_tester.xml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>causality_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>causality_list</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>causality divergence tester</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_simulation_test/PathTemplateItem/portal_rules/new_invoice_simulation_rule/causality_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_simulation_rule/causality_tester.xml new file mode 100644 index 0000000000..ded5ccab47 --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_simulation_rule/causality_tester.xml @@ -0,0 +1,90 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>causality_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>causality_list</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>causality divergence tester</string> </value> + </item> + </dictionary> + </pickle> + </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <tuple> + <global name="PersistentMapping" module="Persistence.mapping"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="3" aka="AAAAAAAAAAM="> + <pickle> + <tuple> + <global name="PersistentMapping" module="Persistence.mapping"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule.xml index 09c99003d6..c8c3b9cdf2 100644 --- a/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule.xml +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule.xml @@ -6,6 +6,30 @@ </pickle> <pickle> <dictionary> + <item> + <key> <string>_Add_portal_content_Permission</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>_Delete_objects_Permission</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>_Modify_portal_content_Permission</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> <item> <key> <string>_count</string> </key> <value> diff --git a/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule/causality_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule/causality_tester.xml new file mode 100644 index 0000000000..f57d31a314 --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule/causality_tester.xml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>causality_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>causality_list</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>causality divergence tester</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_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule/trade_phase_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule/trade_phase_tester.xml new file mode 100644 index 0000000000..ebbaf50bfa --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_invoice_transaction_simulation_rule/trade_phase_tester.xml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>trade_phase_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>trade_phase</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>trade_phase divergence tester</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_simulation_test/PathTemplateItem/portal_rules/new_order_root_simulation_rule/causality_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_order_root_simulation_rule/causality_tester.xml new file mode 100644 index 0000000000..f57d31a314 --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_order_root_simulation_rule/causality_tester.xml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>causality_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>causality_list</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>causality divergence tester</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_simulation_test/PathTemplateItem/portal_rules/new_order_root_simulation_rule/trade_phase_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_order_root_simulation_rule/trade_phase_tester.xml new file mode 100644 index 0000000000..ebbaf50bfa --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_order_root_simulation_rule/trade_phase_tester.xml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>trade_phase_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>trade_phase</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>trade_phase divergence tester</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_simulation_test/PathTemplateItem/portal_rules/new_payment_simulation_rule/trade_phase_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_payment_simulation_rule/trade_phase_tester.xml new file mode 100644 index 0000000000..ebbaf50bfa --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_payment_simulation_rule/trade_phase_tester.xml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>trade_phase_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>trade_phase</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>trade_phase divergence tester</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_simulation_test/PathTemplateItem/portal_rules/new_trade_model_simulation_rule/causality_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_trade_model_simulation_rule/causality_tester.xml new file mode 100644 index 0000000000..f57d31a314 --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_trade_model_simulation_rule/causality_tester.xml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Membership Divergence Tester" 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>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>causality_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Membership Divergence Tester</string> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>causality_list</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>causality divergence tester</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_simulation_test/PathTemplateItem/portal_rules/new_trade_model_simulation_rule/price_tester.xml b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_trade_model_simulation_rule/price_tester.xml new file mode 100644 index 0000000000..cbf9e3f550 --- /dev/null +++ b/bt5/erp5_simulation_test/PathTemplateItem/portal_rules/new_trade_model_simulation_rule/price_tester.xml @@ -0,0 +1,125 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Float Divergence Tester" 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>quantity_range_min</string> </value> + </item> + <item> + <key> <string>type</string> </key> + <value> <string>int</string> </value> + </item> + </dictionary> + <dictionary> + <item> + <key> <string>id</string> </key> + <value> <string>quantity_range_max</string> </value> + </item> + <item> + <key> <string>type</string> </key> + <value> <string>int</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>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>divergence_provider</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>price_tester</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Float Divergence Tester</string> </value> + </item> + <item> + <key> <string>quantity_range_max</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>quantity_range_min</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>tested_property</string> </key> + <value> + <tuple> + <string>price</string> + </tuple> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>price divergence tester</string> </value> + </item> + </dictionary> + </pickle> + </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <tuple> + <global name="PersistentMapping" module="Persistence.mapping"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="3" aka="AAAAAAAAAAM="> + <pickle> + <tuple> + <global name="PersistentMapping" module="Persistence.mapping"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_simulation_test/bt/revision b/bt5/erp5_simulation_test/bt/revision index da2d3988d7..b5045cc404 100644 --- a/bt5/erp5_simulation_test/bt/revision +++ b/bt5/erp5_simulation_test/bt/revision @@ -1 +1 @@ -14 \ No newline at end of file +21 \ No newline at end of file diff --git a/product/ERP5/Document/BusinessProcess.py b/product/ERP5/Document/BusinessProcess.py index 4558f86387..64cd11f1f8 100644 --- a/product/ERP5/Document/BusinessProcess.py +++ b/product/ERP5/Document/BusinessProcess.py @@ -701,9 +701,17 @@ class BusinessProcess(Path, XMLObject): movement._edit(**kw) business_link = self.getBusinessLinkValueList(trade_phase=trade_phase, context=movement) - movement._setCausalityList([trade_model_path.getRelativeUrl()] - + [x.getRelativeUrl() for x in business_link] - + movement.getCausalityList()) + # we have to exclude trade model path and business link in causality list + # because original amount might come from another generatedAmountList + # calculation + causality_list = [trade_model_path.getRelativeUrl()] \ + + [x.getRelativeUrl() for x in business_link] + excluded_portal_type_set = set(self.getPortalTradeModelPathTypeList() + + self.getPortalBusinessLinkTypeList()) + for causality_value in movement.getCausalityValueList(): + if not(causality_value.getPortalType() in excluded_portal_type_set): + causality_list.append(causality_value.getRelativeUrl()) + movement._setCausalityList(causality_list) result.append(movement) if not explanation.getSpecialiseValue().getSameTotalQuantity(): @@ -756,7 +764,7 @@ class BusinessProcess(Path, XMLObject): property_dict = _getPropertyAndCategoryList(amount) else: property_dict = {} - for tester in rule._getUpdatingTesterList(exclude_quantity=False): + for tester in rule._getUpdatingTesterList(): property_dict.update(tester.getUpdatablePropertyDict( amount, None)) diff --git a/product/ERP5/Document/QuantitySplitSolver.py b/product/ERP5/Document/QuantitySplitSolver.py index 03fef87f1a..a358401265 100644 --- a/product/ERP5/Document/QuantitySplitSolver.py +++ b/product/ERP5/Document/QuantitySplitSolver.py @@ -34,7 +34,7 @@ from Products.ERP5Type import Permissions, PropertySheet, interfaces from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5.mixin.solver import SolverMixin from Products.ERP5.mixin.configurable import ConfigurableMixin -from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList +from Products.ERP5.MovementCollectionDiff import _getPropertyDict class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject): """Target solver that split the prevision based on quantity. @@ -91,7 +91,9 @@ class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject): split_index += 1 new_id = "%s_split_%s" % (simulation_movement.getId(), split_index) # Copy at same level - kw = _getPropertyAndCategoryList(simulation_movement) + rule = applied_rule.getSpecialiseValue() + kw = _getPropertyDict(simulation_movement, + property_id_set=rule.getUpdatablePropertyIdSet()) kw.update({'portal_type':simulation_movement.getPortalType(), 'id':new_id, 'delivery':None, @@ -111,7 +113,6 @@ class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject): # XXX we need to call expand on both simulation_movement and new_movement here? # simulation_movement.expand(activate_kw=activate_kw) # new_movement.expand(activate_kw=activate_kw) - # Finish solving if self.getPortalObject().portal_workflow.isTransitionPossible( self, 'succeed'): diff --git a/product/ERP5/MovementCollectionDiff.py b/product/ERP5/MovementCollectionDiff.py index babccd5ebc..dca1b0dd52 100644 --- a/product/ERP5/MovementCollectionDiff.py +++ b/product/ERP5/MovementCollectionDiff.py @@ -41,11 +41,12 @@ class MovementCollectionDiff(object): # Declarative interfaces zope.interface.implements(interfaces.IMovementCollectionDiff,) - def __init__(self): + def __init__(self, property_id_set=None): self._deletable_movement_list = [] self._new_movement_list = [] self._updatable_movement_list = [] self._property_dict_dict = {} + self._property_id_set = property_id_set def getDeletableMovementList(self): """ @@ -88,11 +89,13 @@ class MovementCollectionDiff(object): """ property_dict = self._property_dict_dict.get(movement) if property_dict is None: - property_dict = _getPropertyList(movement) - property_dict.update(_getCategoryList(movement, acquire=False)) - return property_dict - else: - return property_dict + if self._property_id_set is not None: + property_dict = _getPropertyDict(movement, + property_id_set=self._property_id_set) + else: + property_dict = _getPropertyList(movement) + property_dict.update(_getCategoryList(movement, acquire=False)) + return property_dict def addUpdatableMovement(self, movement, property_dict): """ @@ -113,6 +116,13 @@ def _getPropertyAndCategoryList(document): property_dict.update(_getCategoryList(document)) return property_dict +def _getPropertyDict(document, property_id_set=None): + assert property_id_set is not None + property_dict = {} + for property_id in property_id_set: + property_dict[property_id] = document.getProperty(property_id) + return property_dict + def _getPropertyList(document, acquire=True): property_map = document.getPropertyMap() bad_property_list = ['id', 'uid', 'categories_list', 'last_id',] diff --git a/product/ERP5/interfaces/movement_collection_updater.py b/product/ERP5/interfaces/movement_collection_updater.py index 22204d16dc..9244ee410b 100644 --- a/product/ERP5/interfaces/movement_collection_updater.py +++ b/product/ERP5/interfaces/movement_collection_updater.py @@ -40,7 +40,8 @@ class IMovementCollectionUpdater(Interface): obtained from an IMovementCollection, thus generating an IMovementCollectionDiff. """ - def getMovementCollectionDiff(context, rounding=False, movement_generator=None): + def getMovementCollectionDiff(context, rounding=False, movement_generator=None, + property_id_set=None): """ Return a IMovementCollectionDiff by comparing movements the list of movements of context and the list of movements @@ -52,9 +53,15 @@ class IMovementCollectionUpdater(Interface): movement_generator -- an optional IMovementGenerator (if not specified, a context implicit IMovementGenerator will be used) + + property_id_set -- an optional list of properties that we + care on movements. This allows to improve + performance by not looking at properties + we don't care """ - def updateMovementCollection(context, rounding=False, movement_generator=None): + def updateMovementCollection(context, rounding=False, movement_generator=None, + property_id_set=None): """ Invoke getMovementCollectionDiff and update context with the resulting IMovementCollectionDiff. @@ -65,4 +72,9 @@ class IMovementCollectionUpdater(Interface): movement_generator -- an optional IMovementGenerator (if not specified, a context implicit IMovementGenerator will be used) + + property_id_set -- an optional list of properties that we + care on movements. This allows to improve + performance by not looking at properties + we don't care """ diff --git a/product/ERP5/mixin/movement_collection_updater.py b/product/ERP5/mixin/movement_collection_updater.py index e723f5ff60..3470f04f5a 100644 --- a/product/ERP5/mixin/movement_collection_updater.py +++ b/product/ERP5/mixin/movement_collection_updater.py @@ -51,7 +51,8 @@ class MovementCollectionUpdaterMixin: # Implementation of IMovementCollectionUpdater def getMovementCollectionDiff(self, context, rounding=False, - movement_generator=None): + movement_generator=None, + property_id_set=None): """ Return a IMovementCollectionDiff by comparing movements the list of movements of context and the list of movements @@ -63,6 +64,8 @@ class MovementCollectionUpdaterMixin: movement_generator -- an optional IMovementGenerator (if not specified, a context implicit IMovementGenerator will be used) + + property_id_set -- a set listing properties we are looking in movements """ # We suppose here that we have an IMovementCollection in hand decision_movement_list = context.getMovementList() @@ -138,7 +141,8 @@ class MovementCollectionUpdaterMixin: prevision_to_decision_map.append((prevision_movement, map_list)) # Third, time to create the diff - movement_collection_diff = MovementCollectionDiff() + movement_collection_diff = MovementCollectionDiff( + property_id_set=property_id_set) for (prevision_movement, decision_movement_list) in prevision_to_decision_map: self._extendMovementCollectionDiff(movement_collection_diff, prevision_movement, decision_movement_list) @@ -146,7 +150,8 @@ class MovementCollectionUpdaterMixin: return movement_collection_diff def updateMovementCollection(self, context, rounding=False, - movement_generator=None): + movement_generator=None, + property_id_set=None): """ Invoke getMovementCollectionDiff and update context with the resulting IMovementCollectionDiff. @@ -157,9 +162,12 @@ class MovementCollectionUpdaterMixin: movement_generator -- an optional IMovementGenerator (if not specified, a context implicit IMovementGenerator will be used) + + property_id_set -- a set listing properties we are looking in movements """ movement_diff = self.getMovementCollectionDiff(context, - rounding=rounding, movement_generator=movement_generator) + rounding=rounding, movement_generator=movement_generator, + property_id_set=property_id_set) # Apply Diff for movement in movement_diff.getDeletableMovementList(): diff --git a/product/ERP5/mixin/rule.py b/product/ERP5/mixin/rule.py index be3524c29a..77304572d1 100644 --- a/product/ERP5/mixin/rule.py +++ b/product/ERP5/mixin/rule.py @@ -31,6 +31,7 @@ from AccessControl import ClassSecurityInfo from Acquisition import aq_base from Products.CMFCore.utils import getToolByName from Products.ERP5Type import Permissions, interfaces +from Products.ERP5Type.Cache import caching_instance_method from Products.ERP5Type.Core.Predicate import Predicate from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList @@ -192,6 +193,15 @@ class RuleMixin(Predicate): return False return super(RuleMixin, self).test(*args, **kw) + @caching_instance_method(id="Rule.getUpdatablePropertyIdSet", + cache_factory='erp5_content_long', + cache_id_generator=lambda method_id, document: document.getUid()) + def getUpdatablePropertyIdSet(self): + property_id_set = set() + [property_id_set.update(x.getTestedPropertyList()) for x in \ + self._getUpdatingTesterList()] + return property_id_set + def expand(self, applied_rule, **kw): """ Expand this applied rule to create new documents inside the @@ -205,7 +215,9 @@ class RuleMixin(Predicate): # Update movements # NOTE-JPS: it is OK to make rounding a standard parameter of rules # although rounding in simulation is not recommended at all - self.updateMovementCollection(applied_rule, movement_generator=self._getMovementGenerator(applied_rule)) + self.updateMovementCollection(applied_rule, + movement_generator=self._getMovementGenerator(applied_rule), + property_id_set=self.getUpdatablePropertyIdSet()) # And forward expand for movement in applied_rule.getMovementList(): movement.expand(**kw) @@ -298,7 +310,7 @@ class RuleMixin(Predicate): return filter(lambda x:x.isMatchingProvider(), self.objectValues( portal_type=self.getPortalDivergenceTesterTypeList())) - def _getUpdatingTesterList(self, exclude_quantity=True): + def _getUpdatingTesterList(self, exclude_quantity=False): """ Return the applicable divergence testers which must be used to update movements. (ie. not all divergence testers of the Rule) @@ -384,7 +396,7 @@ class RuleMixin(Predicate): # ie. what comes in must either go out or has been lost divergence_tester_list = self._getDivergenceTesterList() profit_tester_list = divergence_tester_list - updating_tester_list = self._getUpdatingTesterList() + updating_tester_list = self._getUpdatingTesterList(exclude_quantity=True) profit_updating_tester_list = updating_tester_list quantity_tester_list = self._getQuantityTesterList() compensated_quantity = 0.0 -- 2.30.9