Commit 528b07bf authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_trade: no need to execute one by one

parent 5a186352
line_total_asset_price = context.getPortalObject().portal_simulation.getCurrentInventoryAssetPrice(**kw) or 0
context.edit( context.edit(
total_asset_price = context.getPortalObject().portal_simulation.getCurrentInventoryAssetPrice(**kw) or 0 total_asset_price = context.getPortalObject().portal_simulation.getCurrentInventoryAssetPrice(**kw) or 0
) )
inventory_report = context.getParent()
inventory_report.edit(
total_asset_price = inventory_report.getTotalAssetPrice() + line_total_asset_price)
...@@ -4,6 +4,7 @@ newContent = context.newContent ...@@ -4,6 +4,7 @@ newContent = context.newContent
section_uid = context.getDestinationSectionUid() section_uid = context.getDestinationSectionUid()
node_uid = context.getDestinationUid() node_uid = context.getDestinationUid()
valuation_method = context.getValuationMethod() valuation_method = context.getValuationMethod()
relative_url = context.getRelativeUrl()
at_date = context.getAtDate() at_date = context.getAtDate()
inventory_list = getCurrentInventoryList( inventory_list = getCurrentInventoryList(
...@@ -14,8 +15,9 @@ inventory_list = getCurrentInventoryList( ...@@ -14,8 +15,9 @@ inventory_list = getCurrentInventoryList(
resourceType=portal.getPortalProductTypeList(), resourceType=portal.getPortalProductTypeList(),
at_date = at_date at_date = at_date
) )
after_tag = None
line_tag = '%s:lineUpdateTotalAssetPrice' % relative_url
#only after all calculation are finished then change report state
for inventory in inventory_list: for inventory in inventory_list:
inventory_report_line = newContent(portal_type='Inventory Report Line') inventory_report_line = newContent(portal_type='Inventory Report Line')
inventory_report_line.edit( inventory_report_line.edit(
...@@ -24,10 +26,8 @@ for inventory in inventory_list: ...@@ -24,10 +26,8 @@ for inventory in inventory_list:
total_quantity = inventory.total_quantity, total_quantity = inventory.total_quantity,
total_asset_price=0 total_asset_price=0
) )
tag = '%s-%s' % (inventory_report_line.getUid(), 'InventoryReportLine_updateTotalAssetPrice')
inventory_report_line.activate( inventory_report_line.activate(
after_tag = after_tag, tag = line_tag
tag = tag
).InventoryReportLine_updateTotalAssetPrice( ).InventoryReportLine_updateTotalAssetPrice(
section_uid = section_uid, section_uid = section_uid,
node_uid = node_uid, node_uid = node_uid,
...@@ -37,6 +37,7 @@ for inventory in inventory_list: ...@@ -37,6 +37,7 @@ for inventory in inventory_list:
at_date = at_date, at_date = at_date,
is_accountable = 1 is_accountable = 1
) )
after_tag = tag
context.activate(after_tag=after_tag).record() tag = '%s:updateTotalAssetPrice' % relative_url
context.activate(after_tag=line_tag, tag=tag).InventoryReport_updateTotalAssetPrice()
context.activate(after_tag=tag).record()
total_asset_price = 0
for inventory_report_line in context.contentValues(portal_type='Inventory Report Line'):
total_asset_price += inventory_report_line.total_asset_price
context.edit(
total_asset_price = total_asset_price)
<?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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InventoryReport_updateTotalAssetPrice</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