Commit 768d0d18 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_trade: add scirpt to remove old movement after upgrade

parent 1a30a4b5
def removeOldMovement(self):
portal = self.getPortalObject()
temp_constructor = lambda self, id, *args, **kw: self.newContent(
temp_object=True, portal_type='Movement',
id=id, *args, **kw)
catalog_kw = dict(disable_cache=1, check_uid=0)
uid_set = set()
for inventory in portal.portal_catalog(portal_type='Inventory',
limit=None,
simulation_state='delivered',
sort_on=[('delivery.start_date', 'ascending'), ('uid', 'ascending')]):
for line in inventory.contentValues(portal_type='Inventory Line'):
for cell in line.contentValues(portal_type='Inventory Cell'):
uid_set.add(cell.getUid())
uid_set.add(line.getUid())
uid_set.add(inventory.getUid())
to_delete_list = []
for uid in uid_set:
temp_object = temp_constructor(self, 'temp_object')
temp_object.setUid(uid)
to_delete_list.append(temp_object)
self.getPortalObject().portal_catalog.catalogObjectList(to_delete_list[:], method_id_list=['z0_uncatalog_stock'], **catalog_kw)
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Extension Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>Inventory</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>extension.erp5.Inventory</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Extension Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>removeOldMovement</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>Inventory</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Inventory_removeOldMovement</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
extension.erp5.Inventory
\ 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