Turkesh Patel (openERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-868650-tpa into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #868650 in OpenERP Addons: "internal moves not updated upon change 
production quantity"
  https://bugs.launchpad.net/openobject-addons/+bug/868650

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-868650-tpa/+merge/113176

[FIX] MRP:internal moves not updated upon changed production quantity.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-868650-tpa/+merge/113176
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-868650-tpa.
=== modified file 'mrp/wizard/change_production_qty.py'
--- mrp/wizard/change_production_qty.py	2012-04-25 08:54:15 +0000
+++ mrp/wizard/change_production_qty.py	2012-07-03 09:07:29 +0000
@@ -54,6 +54,29 @@
         for m in prod.move_created_ids:
             move_lines_obj.write(cr, uid, [m.id], {'product_qty': qty})
 
+    def _update_product_in_move(self, cr, uid, prod, moves, context=None):
+        prod_obj = self.pool.get('mrp.production')
+        bom_obj = self.pool.get('mrp.bom')
+        move_lines_obj = self.pool.get('stock.move')
+        for move in moves:
+            bom_point = prod.bom_id
+            bom_id = prod.bom_id.id
+            if not bom_point:
+                bom_id = bom_obj._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
+                if not bom_id:
+                    raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
+                prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id})
+                bom_point = bom_obj.browse(cr, uid, [bom_id])[0]
+
+            if not bom_id:
+                raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
+
+            factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
+            res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
+            for r in res[0]:
+                if r['product_id'] == move.product_id.id:
+                    move_lines_obj.write(cr, uid, [move.id], {'product_qty' :  r['product_qty']})
+    
     def change_prod_qty(self, cr, uid, ids, context=None):
         """ 
         Changes the Quantity of Product.
@@ -67,31 +90,12 @@
         record_id = context and context.get('active_id',False)
         assert record_id, _('Active Id is not found')
         prod_obj = self.pool.get('mrp.production')
-        bom_obj = self.pool.get('mrp.bom')
         for wiz_qty in self.browse(cr, uid, ids, context=context):
             prod = prod_obj.browse(cr, uid, record_id, context=context)
             prod_obj.write(cr, uid, [prod.id], {'product_qty': wiz_qty.product_qty})
             prod_obj.action_compute(cr, uid, [prod.id])
-
-            move_lines_obj = self.pool.get('stock.move')
-            for move in prod.move_lines:
-                bom_point = prod.bom_id
-                bom_id = prod.bom_id.id
-                if not bom_point:
-                    bom_id = bom_obj._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
-                    if not bom_id:
-                        raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
-                    prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id})
-                    bom_point = bom_obj.browse(cr, uid, [bom_id])[0]
-
-                if not bom_id:
-                    raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
-
-                factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
-                res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
-                for r in res[0]:
-                    if r['product_id'] == move.product_id.id:
-                        move_lines_obj.write(cr, uid, [move.id], {'product_qty' :  r['product_qty']})
+            self._update_product_in_move(cr, uid, prod, prod.move_lines, context=context)
+            self._update_product_in_move(cr, uid, prod, prod.picking_id.move_lines, context=context)
             self._update_product_to_produce(cr, uid, prod, wiz_qty.product_qty, context=context)
 
         return {}

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to