From f0b6ecdea269ccc0a18e10d0d672605e15b1b57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 6 Feb 2013 11:12:46 +0000 Subject: [PATCH] Add a related keys for queries on explanation in inventory API In inventory API queries, stock table is already selected, and we want the query parameters to be applied on this stock table, whereas default related keys would add stock table one more time --- ...Line_getInventoryQueryDictForCellIndex.xml | 2 +- product/ERP5/Document/BudgetLine.py | 2 +- ...ed_explanation_from_stock.catalog_keys.xml | 2 + .../z_related_explanation_from_stock.xml | 68 +++++++++++++++++++ .../related_key_list.xml | 2 + .../bt/template_catalog_method_id_list | 1 + .../bt/template_catalog_related_key_list | 4 +- 7 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_explanation_from_stock.catalog_keys.xml create mode 100644 product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_explanation_from_stock.xml diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getInventoryQueryDictForCellIndex.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getInventoryQueryDictForCellIndex.xml index b05208fb93..25814ee2e5 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getInventoryQueryDictForCellIndex.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getInventoryQueryDictForCellIndex.xml @@ -72,7 +72,7 @@ if budget_cell is None:\n kw = budget_model.getInventoryQueryDict(budget_cell)\n \n if engaged_budget:\n - kw.setdefault(\'explanation_simulation_state\',\n + kw.setdefault(\'stock_explanation_simulation_state\',\n portal.getPortalReservedInventoryStateList() +\n portal.getPortalCurrentInventoryStateList() +\n portal.getPortalTransitInventoryStateList())\n diff --git a/product/ERP5/Document/BudgetLine.py b/product/ERP5/Document/BudgetLine.py index 278df48a0b..7cc6751af3 100644 --- a/product/ERP5/Document/BudgetLine.py +++ b/product/ERP5/Document/BudgetLine.py @@ -77,7 +77,7 @@ class BudgetLine(Predicate, XMLMatrix, VariatedMixin): """Returns all the engagements in a dict where the keys are the cells, and the value is the engaged budget. """ - kw.setdefault('explanation_simulation_state', + kw.setdefault('stock_explanation_simulation_state', self.getPortalReservedInventoryStateList() + self.getPortalCurrentInventoryStateList() + self.getPortalTransitInventoryStateList()) diff --git a/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_explanation_from_stock.catalog_keys.xml b/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_explanation_from_stock.catalog_keys.xml new file mode 100644 index 0000000000..a540f9431e --- /dev/null +++ b/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_explanation_from_stock.catalog_keys.xml @@ -0,0 +1,2 @@ +<catalog_method> +</catalog_method> diff --git a/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_explanation_from_stock.xml b/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_explanation_from_stock.xml new file mode 100644 index 0000000000..9a8f18855a --- /dev/null +++ b/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_explanation_from_stock.xml @@ -0,0 +1,68 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="SQL" module="Products.ZSQLMethods.SQL"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>allow_simple_one_argument_traversal</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>arguments_src</string> </key> + <value> <string>table_0</string> </value> + </item> + <item> + <key> <string>cache_time_</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>class_file_</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>class_name_</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>connection_hook</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>connection_id</string> </key> + <value> <string>erp5_sql_connection</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>z_related_explanation_from_stock</string> </value> + </item> + <item> + <key> <string>max_cache_</string> </key> + <value> <int>100</int> </value> + </item> + <item> + <key> <string>max_rows_</string> </key> + <value> <int>1000</int> </value> + </item> + <item> + <key> <string>src</string> </key> + <value> <string encoding="cdata"><![CDATA[ + +<dtml-var table_0>.uid = stock.explanation_uid + +]]></string> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogRelatedKeyTemplateItem/related_key_list.xml b/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogRelatedKeyTemplateItem/related_key_list.xml index 991b2a90f2..b807de7974 100644 --- a/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogRelatedKeyTemplateItem/related_key_list.xml +++ b/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogRelatedKeyTemplateItem/related_key_list.xml @@ -29,6 +29,8 @@ <key>predicate_uid | predicate/uid/z_related_predicate</key> <key>related_resource_from_use_category_uid | category,category/category_uid/z_related_resource_from_use</key> <key>resourceType | stock,catalog/portal_type/z_related_resource_from_stock</key> + <key>stock_explanation_portal_type | catalog/portal_type/z_related_explanation_from_stock</key> + <key>stock_explanation_simulation_state | catalog/simulation_state/z_related_explanation_from_stock</key> <key>stock_function_category_strict_membership_uid | category/category_uid/z_related_strict_membership_function_uid_from_stock</key> <key>stock_function_category_uid | category/category_uid/z_related_function_uid_from_stock</key> <key>stock_funding_category_strict_membership_uid | category/category_uid/z_related_strict_membership_funding_uid_from_stock</key> diff --git a/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_method_id_list b/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_method_id_list index f9bc7e4314..cc171fd256 100644 --- a/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_method_id_list +++ b/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_method_id_list @@ -86,6 +86,7 @@ erp5_mysql_innodb/z_related_base_category_id erp5_mysql_innodb/z_related_career_skill erp5_mysql_innodb/z_related_children erp5_mysql_innodb/z_related_explanation +erp5_mysql_innodb/z_related_explanation_from_stock erp5_mysql_innodb/z_related_function_uid_from_stock erp5_mysql_innodb/z_related_funding_uid_from_stock erp5_mysql_innodb/z_related_grand_parent diff --git a/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_related_key_list b/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_related_key_list index 99e63c39b4..0c58548bb9 100644 --- a/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_related_key_list +++ b/product/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/template_catalog_related_key_list @@ -59,4 +59,6 @@ related_resource_from_use_category_uid | category,category/category_uid/z_relate stock_funding_category_strict_membership_uid | category/category_uid/z_related_strict_membership_funding_uid_from_stock stock_funding_category_uid | category/category_uid/z_related_funding_uid_from_stock stock_payment_request_category_strict_membership_uid | category/category_uid/z_related_strict_membership_payment_request_uid_from_stock -stock_payment_request_category_uid | category/category_uid/z_related_payment_request_uid_from_stock \ No newline at end of file +stock_payment_request_category_uid | category/category_uid/z_related_payment_request_uid_from_stock +stock_explanation_portal_type | catalog/portal_type/z_related_explanation_from_stock +stock_explanation_simulation_state | catalog/simulation_state/z_related_explanation_from_stock \ No newline at end of file -- 2.30.9