From 068feaa080bb3a2f3111a2fac85a48bcb6629a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 7 Oct 2011 13:42:23 +0200 Subject: [PATCH] Fix migration that adds company to Shipments --- shipment.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/shipment.py b/shipment.py index 964dcf831e..8f322e4778 100644 --- a/shipment.py +++ b/shipment.py @@ -156,9 +156,10 @@ class ShipmentIn(ModelWorkflow, ModelSQL, ModelView): 'GROUP BY shipment.id ' 'ORDER BY MAX(move.company)' % (self._table, move_obj._table)) - for company_id, shipment_ids in itertools.groupby(cursor.fetchall(), + for company_id, values in itertools.groupby(cursor.fetchall(), operator.itemgetter(1)): - self.write(list(shipment_ids), {'company': company_id}) + shipment_ids = [x[0] for x in values] + self.write(shipment_ids, {'company': company_id}) table.not_null_action('company', action='add') # Add index on create_date @@ -516,9 +517,10 @@ class ShipmentInReturn(ModelWorkflow, ModelSQL, ModelView): 'GROUP BY shipment.id ' 'ORDER BY MAX(move.company)' % (self._table, move_obj._table)) - for company_id, shipment_ids in itertools.groupby(cursor.fetchall(), + for company_id, values in itertools.groupby(cursor.fetchall(), operator.itemgetter(1)): - self.write(list(shipment_ids), {'company': company_id}) + shipment_ids = [x[0] for x in values] + self.write(shipment_ids, {'company': company_id}) table.not_null_action('company', action='add') # Add index on create_date @@ -792,9 +794,10 @@ class ShipmentOut(ModelWorkflow, ModelSQL, ModelView): 'GROUP BY shipment.id ' 'ORDER BY MAX(move.company)' % (self._table, move_obj._table)) - for company_id, shipment_ids in itertools.groupby(cursor.fetchall(), + for company_id, values in itertools.groupby(cursor.fetchall(), operator.itemgetter(1)): - self.write(list(shipment_ids), {'company': company_id}) + shipment_ids = [x[0] for x in values] + self.write(shipment_ids, {'company': company_id}) table.not_null_action('company', action='add') # Migration from 1.0 customer_location is no more used @@ -1280,9 +1283,10 @@ class ShipmentOutReturn(ModelWorkflow, ModelSQL, ModelView): 'GROUP BY shipment.id ' 'ORDER BY MAX(move.company)' % (self._table, move_obj._table)) - for company_id, shipment_ids in itertools.groupby(cursor.fetchall(), + for company_id, values in itertools.groupby(cursor.fetchall(), operator.itemgetter(1)): - self.write(list(shipment_ids), {'company': company_id}) + shipment_ids = [x[0] for x in values] + self.write(shipment_ids, {'company': company_id}) table.not_null_action('company', action='add') # Add index on create_date @@ -1734,9 +1738,10 @@ class ShipmentInternal(ModelWorkflow, ModelSQL, ModelView): 'GROUP BY shipment.id ' 'ORDER BY MAX(move.company)' % (self._table, move_obj._table)) - for company_id, shipment_ids in itertools.groupby(cursor.fetchall(), + for company_id, values in itertools.groupby(cursor.fetchall(), operator.itemgetter(1)): - self.write(list(shipment_ids), {'company': company_id}) + shipment_ids = [x[0] for x in values] + self.write(shipment_ids, {'company': company_id}) table.not_null_action('company', action='add') # Add index on create_date