[Erp5-report] r16409 - /erp5/trunk/products/ERP5/Extensions/CheckPortalTypes.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Sep 17 15:51:46 CEST 2007
Author: jerome
Date: Mon Sep 17 15:51:46 2007
New Revision: 16409
URL: http://svn.erp5.org?rev=16409&view=rev
Log:
Add a migration script to change the class of Balance Transactions and
reversing source / destination properties inside.
Modified:
erp5/trunk/products/ERP5/Extensions/CheckPortalTypes.py
Modified: erp5/trunk/products/ERP5/Extensions/CheckPortalTypes.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Extensions/CheckPortalTypes.py?rev=16409&r1=16408&r2=16409&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Extensions/CheckPortalTypes.py (original)
+++ erp5/trunk/products/ERP5/Extensions/CheckPortalTypes.py Mon Sep 17 15:51:46 2007
@@ -19,4 +19,65 @@
new_obj = new_class(object_id)
new_obj.__dict__.update(old_obj.__dict__)
self._setObject(object_id, new_obj)
-
+
+
+def updateBalanceTransactionClass(self):
+ """Update Balance Transactions new indexing that occured around r16371
+ """
+ from Products.ERP5Type.Document.BalanceTransaction import BalanceTransaction
+ from Products.ERP5Type.Document.BalanceTransactionLine\
+ import BalanceTransactionLine
+
+ def reverseSourceAndDestination(self):
+ destination_list = self.getValueList('source')
+ source_list = self.getValueList('destination')
+ destination_section_list = self.getValueList('source_section')
+ source_section_list = self.getValueList('destination_section')
+ destination_payment_list = self.getValueList('source_payment')
+ source_payment_list = self.getValueList('destination_payment')
+ stop_date = self.getStartDate()
+ start_date = self.getStopDate()
+ source_reference = self.getDestinationReference()
+ destination_reference = self.getSourceReference()
+
+ self.edit(destination_value_list=destination_list,
+ source_value_list=source_list,
+ destination_section_value_list=destination_section_list,
+ source_section_value_list=source_section_list,
+ destination_payment_value_list=destination_payment_list,
+ stop_date=stop_date,
+ start_date=start_date,
+ source_reference=source_reference,
+ destination_reference=destination_reference)
+
+ if self.getPortalTypeName() != 'Balance Transaction':
+ self.setQuantity( - self.getQuantity())
+
+ stap = self.getDestinationTotalAssetPrice()
+ dtap = self.getSourceTotalAssetPrice()
+ if stap:
+ self.setSourceTotalAssetPrice(stap)
+ if dtap:
+ self.setDestinationTotalAssetPrice(dtap)
+
+ module = self.getPortalObject().accounting_module
+ for obj in module.contentValues(filter=
+ dict(portal_type='Balance Transaction')):
+ obj = obj.getObject()
+ #print 'updating', obj, 'with class', BalanceTransaction
+ changeObjectClass(module, obj.getId(), BalanceTransaction)
+ get_transaction().commit(1)
+
+ newobj = getattr(module, obj.getId())
+ reverseSourceAndDestination(newobj)
+ for subobj in newobj.getMovementList(
+ portal_type=( 'Accounting Transaction Line',
+ 'Balance Transaction Line', )):
+ changeObjectClass(newobj, subobj.getId(), BalanceTransactionLine)
+ reverseSourceAndDestination(subobj)
+ #print ' subupdating', subobj, 'with class', BalanceTransactionLine
+
+ # XXX 'something' activates some unindexObject calls, so activate our
+ # reindexing after ...
+ newobj.activate(after_method_id='unindexObject').recursiveReindexObject()
+
More information about the Erp5-report
mailing list