Commit 4aec00c2 authored by Titouan Soulard's avatar Titouan Soulard

erp5_trade: fix method `Movement_zGetPackedQuantity`

The ZSQLMethod was using a wrong table `movement` instead of the `stock` table,
hence throwing errors. This commit makes it use the right table, by adding a
filter on `node_uid`, taking into account the structure of the new table.

/reviewed-by @jerome
/reviewed-on !2030
parent 6dedcc43
Pipeline #38715 failed with stage
in 0 seconds
movement = context movement = context
delivery_uid = movement.getExplanationUid() delivery_uid = movement.getExplanationUid()
destination_uid = movement.getDestinationUid()
resource_uid = movement.getResourceUid() resource_uid = movement.getResourceUid()
variation_text = movement.getVariationText() variation_text = movement.getVariationText()
packed_quantity = 0 packed_quantity = 0
sql_list = movement.Movement_zGetPackedQuantity( sql_list = movement.Movement_zGetPackedQuantity(
node_uid=destination_uid,
explanation_uid=delivery_uid, explanation_uid=delivery_uid,
resource_uid=resource_uid, resource_uid=resource_uid,
variation_text=variation_text) variation_text=variation_text)
......
SELECT SELECT
SUM(movement.quantity) AS quantity SUM(stock.quantity) AS quantity
FROM FROM
catalog AS container_cell, movement catalog AS container_cell, stock
WHERE WHERE
movement.explanation_uid = <dtml-sqlvar explanation_uid type="int"> stock.explanation_uid = <dtml-sqlvar explanation_uid type="int">
AND container_cell.has_cell_content = 0 AND container_cell.has_cell_content = 0
AND container_cell.uid = movement.uid AND container_cell.uid = stock.uid
AND (container_cell.portal_type = "Container Cell" AND (container_cell.portal_type = "Container Cell"
OR container_cell.portal_type = "Container Line") OR container_cell.portal_type = "Container Line")
<dtml-if resource_uid> <dtml-if resource_uid>
AND movement.resource_uid = <dtml-sqlvar resource_uid type="int"> AND stock.resource_uid = <dtml-sqlvar resource_uid type="int">
</dtml-if>
<dtml-if node_uid>
AND stock.node_uid = <dtml-sqlvar node_uid type="int">
</dtml-if> </dtml-if>
<dtml-if variation_text> <dtml-if variation_text>
AND movement.variation_text = <dtml-sqlvar variation_text type="string"> AND stock.variation_text = <dtml-sqlvar variation_text type="string">
</dtml-if> </dtml-if>
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
<item> <item>
<key> <string>arguments_src</string> </key> <key> <string>arguments_src</string> </key>
<value> <string>explanation_uid\n <value> <string>explanation_uid\n
node_uid\n
resource_uid\n resource_uid\n
variation_text</string> </value> variation_text</string> </value>
</item> </item>
......
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