From a5581cd532c76792372b85501761d0398772ac3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 24 Jun 2020 11:56:30 +0900 Subject: [PATCH] invoicing: scripts to get dynamic accounting trade model paths --- ...amicDestinationCategoryListWithAnalytic.py | 18 ++++++ ...micDestinationCategoryListWithAnalytic.xml | 62 +++++++++++++++++++ ...cDestinationCategoryListWithoutAnalytic.py | 27 ++++++++ ...DestinationCategoryListWithoutAnalytic.xml | 62 +++++++++++++++++++ ...ngDynamicSourceCategoryListWithAnalytic.py | 18 ++++++ ...gDynamicSourceCategoryListWithAnalytic.xml | 62 +++++++++++++++++++ ...ynamicSourceCategoryListWithoutAnalytic.py | 26 ++++++++ ...namicSourceCategoryListWithoutAnalytic.xml | 62 +++++++++++++++++++ 8 files changed, 337 insertions(+) create mode 100644 bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithAnalytic.py create mode 100644 bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithAnalytic.xml create mode 100644 bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic.py create mode 100644 bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic.xml create mode 100644 bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithAnalytic.py create mode 100644 bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithAnalytic.xml create mode 100644 bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic.py create mode 100644 bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic.xml diff --git a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithAnalytic.py b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithAnalytic.py new file mode 100644 index 0000000000..0d5960dde1 --- /dev/null +++ b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithAnalytic.py @@ -0,0 +1,18 @@ +category_list = context.TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic(movement) + +function = movement.getDestinationFunction( + base=True) or context.getDestinationFunction(base=True) +if function: + category_list.append(function) + +funding = movement.getDestinationFunding( + base=True) or context.getDestinationFunding(base=True) +if funding: + category_list.append(funding) + +project = movement.getDestinationProject( + base=True) or context.getDestinationProject(base=True) +if project: + category_list.append(project) + +return category_list diff --git a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithAnalytic.xml b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithAnalytic.xml new file mode 100644 index 0000000000..4788333122 --- /dev/null +++ b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithAnalytic.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>movement</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>TradeModelPath_getAccountingDynamicDestinationCategoryListWithAnalytic</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic.py b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic.py new file mode 100644 index 0000000000..575fb639a3 --- /dev/null +++ b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic.py @@ -0,0 +1,27 @@ +portal = context.getPortalObject() + +category_list = [ + c for c in [ + movement.getDestinationSection(base=True), + movement.getDestinationPayment(base=True) + ] if c +] + +account = movement.getDestinationAccount() or context.getDestination() +if not account: + # try to find from predicates + resource = movement.getResourceValue() + if resource is not None: + account = next( + ( + predicate.getDestinationAccount() + for predicate in portal.portal_domains.searchPredicateList( + context=movement, + portal_type='Purchase Supply Line', + ) + if predicate.getDestinationAccount()), None) + +if account: + category_list.append('destination/%s' % account) + +return category_list diff --git a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic.xml b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic.xml new file mode 100644 index 0000000000..51e543f34a --- /dev/null +++ b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>movement</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithAnalytic.py b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithAnalytic.py new file mode 100644 index 0000000000..ddef438c5e --- /dev/null +++ b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithAnalytic.py @@ -0,0 +1,18 @@ +category_list = context.TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic(movement) + +function = movement.getSourceFunction(base=True) or context.getSourceFunction( + base=True) +if function: + category_list.append(function) + +funding = movement.getSourceFunding(base=True) or context.getSourceFunding( + base=True) +if funding: + category_list.append(funding) + +project = movement.getSourceProject(base=True) or context.getSourceProject( + base=True) +if project: + category_list.append(project) + +return category_list diff --git a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithAnalytic.xml b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithAnalytic.xml new file mode 100644 index 0000000000..fab426b8c9 --- /dev/null +++ b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithAnalytic.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>movement</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>TradeModelPath_getAccountingDynamicSourceCategoryListWithAnalytic</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic.py b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic.py new file mode 100644 index 0000000000..0a0f539f36 --- /dev/null +++ b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic.py @@ -0,0 +1,26 @@ +portal = context.getPortalObject() + +category_list = [ + c for c in [ + movement.getSourceSection(base=True), + movement.getSourcePayment(base=True) + ] if c +] + +account = movement.getSourceAccount() or context.getSource() +if not account: + # try to find from predicates + resource = movement.getResourceValue() + if resource is not None: + account = next( + ( + predicate.getSourceAccount() + for predicate in portal.portal_domains.searchPredicateList( + context=movement, + portal_type='Sale Supply Line', + ) + if predicate.getSourceAccount()), None) +if account: + category_list.append('source/%s' % account) + +return category_list diff --git a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic.xml b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic.xml new file mode 100644 index 0000000000..f331e97415 --- /dev/null +++ b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>movement</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> -- 2.30.9