Commit c93a52e6 authored by Jérome Perrin's avatar Jérome Perrin

Revert "Revert "catalog/stock: make stock table supporting movements indexed as several movements""

This reverts commit 11babe38.
parent 6d203411
<catalog_method>
<item key="sql_catalog_object_list" type="int">
<value>1</value>
</item>
<item key="_is_filtered_archive" type="int">
<value>1</value>
</item>
<item key="_filter_expression_archive" type="str">
<value>python: isMovement</value>
</item>
</catalog_method>
DELETE FROM
stock
WHERE
<dtml-in uid>
uid=<dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>
</dtml-in>
;
<dtml-var "'\0'">
<dtml-let row_list="[]" uid_dict="{}">
<dtml-in prefix="loop" expr="_.range(_.len(uid))">
<dtml-if "not(isInventoryMovement[loop_item]) and isMovement[loop_item] and getResourceUid[loop_item]">
<dtml-in prefix="mov" expr="asMovementList[loop_item]" no_push_item>
<dtml-if "getDestinationUid[loop_item]">
<dtml-call expr="uid_dict.update({uid[loop_item]: uid_dict.get(uid[loop_item], -1) + 1})">
<dtml-call expr="row_list.append([
uid[loop_item],
uid_dict[uid[loop_item]],
getExplanationUid[loop_item],
getDestinationUid[loop_item],
getDestinationSectionUid[loop_item],
getDestinationPaymentUid[loop_item],
getDestinationFunctionUid[loop_item],
getDestinationProjectUid[loop_item],
getDestinationFundingUid[loop_item],
getDestinationPaymentRequestUid[loop_item],
getSourceSectionUid[loop_item],
getSourceUid[loop_item],
getResourceUid[loop_item],
(mov_item.getInventoriatedQuantity() or 0),
isCancellationAmount[loop_item],
isAccountable[loop_item],
mov_item.getStopDate(),
mov_item.getStartDate(),
getDestinationInventoriatedTotalAssetPrice[loop_item],
getPortalType[loop_item],
getSimulationState[loop_item],
getVariationText[loop_item],
getSubVariationText[loop_item]])">
</dtml-if>
<dtml-if "getSourceUid[loop_item]">
<dtml-call expr="uid_dict.update({uid[loop_item]: uid_dict.get(uid[loop_item], -1) + 1})">
<dtml-call expr="row_list.append([
uid[loop_item],
uid_dict[uid[loop_item]],
getExplanationUid[loop_item],
getSourceUid[loop_item],
getSourceSectionUid[loop_item],
getSourcePaymentUid[loop_item],
getSourceFunctionUid[loop_item],
getSourceProjectUid[loop_item],
getSourceFundingUid[loop_item],
getSourcePaymentRequestUid[loop_item],
getDestinationSectionUid[loop_item],
getDestinationUid[loop_item],
getResourceUid[loop_item],
-(getInventoriatedQuantity[loop_item] or 0),
isCancellationAmount[loop_item],
isAccountable[loop_item],
mov_item.getStartDate(),
mov_item.getStopDate(),
getSourceInventoriatedTotalAssetPrice[loop_item],
getPortalType[loop_item],
getSimulationState[loop_item],
getVariationText[loop_item],
getSubVariationText[loop_item]])">
</dtml-if>
</dtml-in>
</dtml-if>
</dtml-in>
<dtml-if "row_list">
INSERT INTO
stock
VALUES
<dtml-in prefix="row" expr="row_list">
(
<dtml-sqlvar expr="row_item[0]" type="int">,
<dtml-sqlvar expr="row_item[1]" type="int">,
<dtml-sqlvar expr="row_item[2]" type="int" optional>,
<dtml-sqlvar expr="row_item[3]" type="int">,
<dtml-sqlvar expr="row_item[4]" type="int" optional>,
<dtml-sqlvar expr="row_item[5]" type="int" optional>,
<dtml-sqlvar expr="row_item[6]" type="int" optional>,
<dtml-sqlvar expr="row_item[7]" type="int" optional>,
<dtml-sqlvar expr="row_item[8]" type="int" optional>,
<dtml-sqlvar expr="row_item[9]" type="int" optional>,
<dtml-sqlvar expr="row_item[10]" type="int" optional>,
<dtml-sqlvar expr="row_item[11]" type="int" optional>,
<dtml-sqlvar expr="row_item[12]" type="int">,
<dtml-sqlvar expr="row_item[13]" type="float" optional>,
<dtml-sqlvar expr="row_item[14]" type="int">,
<dtml-sqlvar expr="row_item[15]" type="int">,
<dtml-sqlvar expr="row_item[16]" type="datetime" optional>,
<dtml-sqlvar expr="row_item[17]" type="datetime" optional>,
<dtml-sqlvar expr="row_item[18]" type="float" optional>,
<dtml-sqlvar expr="row_item[19]" type="string" optional>,
<dtml-sqlvar expr="row_item[20]" type="string" optional>,
<dtml-sqlvar expr="row_item[21]" type="string" optional>,
<dtml-sqlvar expr="row_item[22]" type="string" optional>
)
<dtml-if sequence-end><dtml-else>,</dtml-if>
</dtml-in>
</dtml-if>
</dtml-let>
<?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>uid\r\n
getExplanationUid\r\n
getResourceUid\r\n
getInventoriatedQuantity\r\n
getSourceUid\r\n
getDestinationUid\r\n
getSourceSectionUid\r\n
getDestinationSectionUid\r\n
isMovement\r\n
isCancellationAmount\r\n
isInventoryMovement\r\n
getSourcePaymentUid\r\n
getDestinationPaymentUid\r\n
getSourceFunctionUid\r\n
getDestinationFunctionUid\r\n
getSourceProjectUid\r\n
getDestinationProjectUid\r\n
getSourceFundingUid\r\n
getDestinationFundingUid\r\n
getSourcePaymentRequestUid\r\n
getDestinationPaymentRequestUid\r\n
getSimulationState\r\n
getSourceInventoriatedTotalAssetPrice\r\n
getDestinationInventoriatedTotalAssetPrice\r\n
getStartDate\r\n
getStopDate\r\n
isAccountable\r\n
getPortalType\r\n
getVariationText\r\n
getSubVariationText\r\n
asMovementList</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_catalog_stock_list</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>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
erp5_mysql_innodb/z_catalog_stock_list
\ No newline at end of file
......@@ -10,6 +10,7 @@ WHERE
<dtml-let row_list="[]" uid_dict="{}">
<dtml-in prefix="loop" expr="_.range(_.len(uid))">
<dtml-if "not(isInventoryMovement[loop_item]) and isMovement[loop_item] and getResourceUid[loop_item]">
<dtml-in prefix="mov" expr="asMovementList[loop_item]" no_push_item>
<dtml-if "getDestinationUid[loop_item]">
<dtml-call expr="uid_dict.update({uid[loop_item]: uid_dict.get(uid[loop_item], -1) + 1})">
<dtml-call expr="row_list.append([
......@@ -26,11 +27,11 @@ WHERE
getSourceSectionUid[loop_item],
getSourceUid[loop_item],
getResourceUid[loop_item],
getInventoriatedQuantity[loop_item],
(mov_item.getInventoriatedQuantity() or 0),
isCancellationAmount[loop_item],
isAccountable[loop_item],
getStopDate[loop_item],
getStartDate[loop_item],
mov_item.getStopDate(),
mov_item.getStartDate(),
getDestinationInventoriatedTotalAssetPrice[loop_item],
getPortalType[loop_item],
getSimulationState[loop_item],
......@@ -53,19 +54,21 @@ WHERE
getDestinationSectionUid[loop_item],
getDestinationUid[loop_item],
getResourceUid[loop_item],
-(getInventoriatedQuantity[loop_item] or 0),
-(mov_item.getInventoriatedQuantity() or 0),
isCancellationAmount[loop_item],
isAccountable[loop_item],
getStartDate[loop_item],
getStopDate[loop_item],
mov_item.getStartDate(),
mov_item.getStopDate(),
getSourceInventoriatedTotalAssetPrice[loop_item],
getPortalType[loop_item],
getSimulationState[loop_item],
getVariationText[loop_item],
getSubVariationText[loop_item]])">
</dtml-if>
</dtml-in>
</dtml-if>
</dtml-in>
<dtml-if "row_list">
REPLACE INTO
stock
......
......@@ -43,7 +43,8 @@ getStopDate\r\n
isAccountable\r\n
getPortalType\r\n
getVariationText\r\n
getSubVariationText</string> </value>
getSubVariationText\r\n
asMovementList</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
......
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