← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/6.0-opw-5351-improved-ach into lp:openobject-addons/6.0

 

Anup(OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/6.0-opw-5351-improved-ach into lp:openobject-addons/6.0.

Requested reviews:
  Jay Vora (OpenERP) (jvo-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-5351-improved-ach/+merge/58652

Hello Jay,

   I have fixed the issues mentioned by you. I agree with you that it should have the confirmation date rather than the order date as the procurements will only be created when you confirm the order.

   I also agree with you that the datetime will be called repeatedly in the inner for loop and will make the system slower. 
   
   I also improved the performance by removing the pool calls at every iteration in the loops. This will save a lot of time.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-5351-improved-ach/+merge/58652
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/6.0-opw-5351-improved-ach.
=== modified file 'sale/sale.py'
--- sale/sale.py	2011-01-19 08:38:17 +0000
+++ sale/sale.py	2011-04-21 11:34:24 +0000
@@ -656,14 +656,20 @@
         move_obj = self.pool.get('stock.move')
         proc_obj = self.pool.get('procurement.order')
         company = self.pool.get('res.users').browse(cr, uid, uid).company_id
+        sequence_obj = self.pool.get('ir.sequence')
+        picking_obj = self.pool.get('stock.picking')
+        sale_order_line_obj = self.pool.get('sale.order.line')
+        
         for order in self.browse(cr, uid, ids, context={}):
             proc_ids = []
             output_id = order.shop_id.warehouse_id.lot_output_id.id
             picking_id = False
+            
+            date_planned = datetime.strptime(order.date_confirm, '%Y-%m-%d') + relativedelta(days=line.delay or 0.0)
+            date_planned = (date_planned - timedelta(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
+            
             for line in order.order_line:
                 proc_id = False
-                date_planned = datetime.now() + relativedelta(days=line.delay or 0.0)
-                date_planned = (date_planned - timedelta(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
 
                 if line.state == 'done':
                     continue
@@ -671,8 +677,8 @@
                 if line.product_id and line.product_id.product_tmpl_id.type in ('product', 'consu'):
                     location_id = order.shop_id.warehouse_id.lot_stock_id.id
                     if not picking_id:
-                        pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
-                        picking_id = self.pool.get('stock.picking').create(cr, uid, {
+                        pick_name = sequence_obj.get(cr, uid, 'stock.picking.out')
+                        picking_id = picking_obj.create(cr, uid, {
                             'name': pick_name,
                             'origin': order.name,
                             'type': 'out',
@@ -684,7 +690,7 @@
                             'invoice_state': (order.order_policy=='picking' and '2binvoiced') or 'none',
                             'company_id': order.company_id.id,
                         })
-                    move_id = self.pool.get('stock.move').create(cr, uid, {
+                    move_id = move_obj.create(cr, uid, {
                         'name': line.name[:64],
                         'picking_id': picking_id,
                         'product_id': line.product_id.id,
@@ -708,7 +714,7 @@
                     })
 
                 if line.product_id:
-                    proc_id = self.pool.get('procurement.order').create(cr, uid, {
+                    proc_id = proc_obj.create(cr, uid, {
                         'name': line.name,
                         'origin': order.name,
                         'date_planned': date_planned,
@@ -726,7 +732,7 @@
                         'company_id': order.company_id.id,
                     })
                     proc_ids.append(proc_id)
-                    self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
+                    sale_order_line_obj.write(cr, uid, [line.id], {'procurement_id': proc_id})
                     if order.state == 'shipping_except':
                         for pick in order.picking_ids:
                             for move in pick.move_lines:


Follow ups