From bb0095642e246702212db85b271d1833bf27f779 Mon Sep 17 00:00:00 2001 From: mtr Date: Fri, 15 Apr 2011 14:43:34 +0530 Subject: [PATCH 1/3] [FIX] sale:improved execute method of config wizard when there is one step picking lp bug: https://launchpad.net/bugs/759695 fixed bzr revid: mtr@mtr-20110415091334-tna4ac2k0e1ltnwn --- addons/sale/sale.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index f80d610eb03..60b09f08518 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -710,7 +710,7 @@ class sale_order(osv.osv): 'note': line.notes, 'company_id': order.company_id.id, }) - + if line.product_id: proc_id = self.pool.get('procurement.order').create(cr, uid, { 'name': line.name, @@ -1202,14 +1202,16 @@ class sale_config_picking_policy(osv.osv_memory): } def execute(self, cr, uid, ids, context=None): + ir_values_obj = self.pool.get('ir.values') + ir_model_data_obj = self.pool.get('ir.model.data') + location_id = ir_model_data_obj.get_object_reference(cr, uid, 'stock', 'stock_location_output') + location_id = location_id and location_id[1] or False for o in self.browse(cr, uid, ids, context=context): - ir_values_obj = self.pool.get('ir.values') ir_values_obj.set(cr, uid, 'default', False, 'picking_policy', ['sale.order'], o.picking_policy) ir_values_obj.set(cr, uid, 'default', False, 'order_policy', ['sale.order'], o.order_policy) + if o.step == 'one': + self.pool.get('stock.location').write(cr, uid, [location_id], {'chained_auto_packing': 'transparent'}) if o.step == 'two': - md = self.pool.get('ir.model.data') - location_id = md.get_object_reference(cr, uid, 'stock', 'stock_location_output') - location_id = location_id and location_id[1] or False self.pool.get('stock.location').write(cr, uid, [location_id], {'chained_auto_packing': 'manual'}) sale_config_picking_policy() From 4b46fd652aef91324875955e04256ca158d89ce3 Mon Sep 17 00:00:00 2001 From: mtr Date: Fri, 15 Apr 2011 15:05:16 +0530 Subject: [PATCH 2/3] [IMP] sale:improved code for revision no 4640 bzr revid: mtr@mtr-20110415093516-r3ffuz6mrbaqca3c --- addons/sale/sale.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 60b09f08518..1c0e8cc48f7 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1204,15 +1204,16 @@ class sale_config_picking_policy(osv.osv_memory): def execute(self, cr, uid, ids, context=None): ir_values_obj = self.pool.get('ir.values') ir_model_data_obj = self.pool.get('ir.model.data') + stock_location_obj = self.pool.get('stock.location') location_id = ir_model_data_obj.get_object_reference(cr, uid, 'stock', 'stock_location_output') location_id = location_id and location_id[1] or False for o in self.browse(cr, uid, ids, context=context): ir_values_obj.set(cr, uid, 'default', False, 'picking_policy', ['sale.order'], o.picking_policy) ir_values_obj.set(cr, uid, 'default', False, 'order_policy', ['sale.order'], o.order_policy) if o.step == 'one': - self.pool.get('stock.location').write(cr, uid, [location_id], {'chained_auto_packing': 'transparent'}) + stock_location_obj.write(cr, uid, [location_id], {'chained_auto_packing': 'transparent'}) if o.step == 'two': - self.pool.get('stock.location').write(cr, uid, [location_id], {'chained_auto_packing': 'manual'}) + stock_location_obj.write(cr, uid, [location_id], {'chained_auto_packing': 'manual'}) sale_config_picking_policy() From 995b1bacd84985a25d59dcf4d81da5a1fb9e9ca4 Mon Sep 17 00:00:00 2001 From: mtr Date: Fri, 15 Apr 2011 16:11:21 +0530 Subject: [PATCH 3/3] [IMP] sale: optimized code for execute method of config wizard bzr revid: mtr@mtr-20110415104121-30u1fodo8osjw9v3 --- addons/sale/sale.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 1c0e8cc48f7..4a49a52ede1 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1207,13 +1207,15 @@ class sale_config_picking_policy(osv.osv_memory): stock_location_obj = self.pool.get('stock.location') location_id = ir_model_data_obj.get_object_reference(cr, uid, 'stock', 'stock_location_output') location_id = location_id and location_id[1] or False + chaining_type = False for o in self.browse(cr, uid, ids, context=context): ir_values_obj.set(cr, uid, 'default', False, 'picking_policy', ['sale.order'], o.picking_policy) ir_values_obj.set(cr, uid, 'default', False, 'order_policy', ['sale.order'], o.order_policy) if o.step == 'one': - stock_location_obj.write(cr, uid, [location_id], {'chained_auto_packing': 'transparent'}) - if o.step == 'two': - stock_location_obj.write(cr, uid, [location_id], {'chained_auto_packing': 'manual'}) + chaining_type = 'transparent' + else: + chaining_type = 'manual' + stock_location_obj.write(cr, uid, [location_id], {'chained_auto_packing': chaining_type}) sale_config_picking_policy()