Commit 9bac9962 authored by Julien Muchembled's avatar Julien Muchembled

invoicing: speed up InvoiceTransaction_selectInvoiceMovement

parent ad6958f4
<dtml-var table_0>.base_category_uid = <dtml-var "portal_categories.specialise.getUid()">
<dtml-var RELATED_QUERY_SEPARATOR>
<dtml-var table_0>.uid = <dtml-var table_2>.parent_uid
<dtml-var RELATED_QUERY_SEPARATOR>
<dtml-var table_2>.uid = <dtml-var table_1>.parent_uid
<dtml-var RELATED_QUERY_SEPARATOR>
<dtml-var table_3>.uid = <dtml-var table_0>.category_uid
AND <dtml-var table_1>.uid = <dtml-var query_table>.parent_uid
\ No newline at end of file
<dtml-var table_1>.uid = <dtml-var table_0>.parent_uid
<dtml-var RELATED_QUERY_SEPARATOR>
<dtml-var table_2>.uid = <dtml-var table_1>.parent_uid
AND <dtml-var table_2>.base_category_uid = <dtml-var "portal_categories.specialise.getUid()">
<dtml-var RELATED_QUERY_SEPARATOR>
<dtml-var table_0>.uid = <dtml-var query_table>.parent_uid
......@@ -8,16 +8,13 @@
<dictionary>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value>
<none/>
</value>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>table_0\n
table_1\n
table_2\n
table_3\n
RELATED_QUERY_SEPARATOR=" AND "\n
query_table="catalog"</string> </value>
</item>
......@@ -27,11 +24,15 @@ query_table="catalog"</string> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value> <string></string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value> <string></string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_hook</string> </key>
......@@ -45,7 +46,7 @@ query_table="catalog"</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_related_grand_grand_parent_specialise</string> </value>
<value> <string>z_related_grand_grand_parent_specialise_uid</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
......
<key_list>
<key>grand_grand_grand_parent_simulation_state | catalog,catalog,catalog,catalog/simulation_state/z_related_grand_grand_grand_parent</key>
<key>grand_grand_parent_specialise_portal_type | category,catalog,catalog,catalog/portal_type/z_related_grand_grand_parent_specialise</key>
<key>grand_grand_parent_specialise_reference | category,catalog,catalog,catalog/reference/z_related_grand_grand_parent_specialise</key>
<key>grand_grand_parent_specialise_uid | catalog,catalog,category/category_uid/z_related_grand_grand_parent_specialise_uid</key>
</key_list>
\ No newline at end of file
......@@ -3,11 +3,16 @@
Simulation Movements can come from normal Invoice Transaction Rule
and same rule which is children of Trade Model Rule """
portal = context.getPortalObject()
searchRules = portal.portal_rules.searchFolder
getRuleUidList = lambda *args: [x.getUid() for x in searchRules(reference=args)]
# search for normal movements
kw['parent_specialise_reference'] = ['default_invoice_transaction_rule']
kw['grand_grand_parent_specialise_reference'] = [
'default_invoicing_rule', 'default_invoice_rule', 'default_tax_rule']
if context.Invoice_isAdvanced():
kw['parent_specialise_uid'] = getRuleUidList('default_invoice_transaction_rule')
kw['grand_grand_parent_specialise_uid'] = getRuleUidList(
'default_invoicing_rule', 'default_invoice_rule', 'default_tax_rule')
if portal.Invoice_isAdvanced():
kw['explanation_portal_type'] = ['%s Order' % trade_type,
'%s Invoice' % trade_type,
'%s Packing List' % trade_type,
......@@ -27,13 +32,14 @@ kw['group_by'] = ('uid',)
search_kw = kw.copy()
search_kw['grand_parent_simulation_state'] = ['started']
movement_list = list(context.portal_catalog(**search_kw))
movement_list = list(portal.portal_catalog(**search_kw))
# update query to search for movements which are children of Trade Model Rule
kw['grand_grand_parent_specialise_reference'] = 'default_trade_model_rule'
kw['grand_grand_parent_specialise_uid'] = getRuleUidList(
'default_trade_model_rule')
kw['grand_grand_grand_parent_simulation_state'] = ['started']
movement_list += list(context.portal_catalog(**kw))
movement_list += portal.portal_catalog(**kw)
# Simulation movement's state maybe not yet updated, make sure it's the right one
return [x for x in movement_list if x.getParentValue().getParentValue().getSimulationState() == 'started']
erp5_mysql_innodb/z_related_grand_grand_grand_parent
erp5_mysql_innodb/z_related_grand_grand_parent_specialise
\ No newline at end of file
erp5_mysql_innodb/z_related_grand_grand_parent_specialise_uid
\ No newline at end of file
grand_grand_grand_parent_simulation_state | catalog,catalog,catalog,catalog/simulation_state/z_related_grand_grand_grand_parent
grand_grand_parent_specialise_portal_type | category,catalog,catalog,catalog/portal_type/z_related_grand_grand_parent_specialise
grand_grand_parent_specialise_reference | category,catalog,catalog,catalog/reference/z_related_grand_grand_parent_specialise
\ No newline at end of file
grand_grand_parent_specialise_uid | catalog,catalog,category/category_uid/z_related_grand_grand_parent_specialise_uid
\ No newline at end of file
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