Commit 96606fea authored by Titouan Soulard's avatar Titouan Soulard

erp5_trade: delete old offset lines when recalculating

parent 869f8cf2
......@@ -3,14 +3,21 @@ Calls `Inventory_computeOffset` as an activity and execute the right
transitions before and after calling the script.
"""
tag = script.id + "offset_computing" + context.getPath()
offset_deleting_tag = script.id + "offset_deleting" + context.getPath()
offset_computing_tag = script.id + "offset_computing" + context.getPath()
# Use intermediate workflow state to avoid changes while calculation
# is in process.
context.calculate()
context.activate(
tag=tag,
tag=offset_deleting_tag,
priority=3,
).Inventory_deleteOffsetLines()
context.activate(
after_tag=offset_deleting_tag,
tag=offset_computing_tag,
# Lower priority over many processes
priority=3,
).Inventory_computeOffset()
......@@ -18,5 +25,5 @@ context.activate(
# Switch to calculated state (and allow user to cancel or record)
# when calculation is finished.
context.activate(
after_tag=tag,
after_tag=offset_computing_tag,
).plan()
"""
Deletes all Inventory Offset Lines (and therefore contained cells) for an Inventory.
Meant to be used when recalculating a non-recorded Inventory.
"""
inventory_offset_line_list = context.contentValues(portal_type='Inventory Offset Line')
if inventory_offset_line_list:
context.manage_delObjects(ids=[x.getId() for x in inventory_offset_line_list])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Inventory_deleteOffsetLines</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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