Kirti Savalia(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-904170-ksa into
lp:openobject-addons.
Requested reviews:
Kirti Savalia(OpenERP) (ksa-openerp)
Raphael Collet (OpenERP) (rco-openerp)
Rucha (Open ERP) (rpa-openerp)
Related bugs:
Bug #904170 in OpenERP Addons: "change qty on production order ignores
quantity type of subproduct"
https://bugs.launchpad.net/openobject-addons/+bug/904170
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-904170-ksa/+merge/85817
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-904170-ksa/+merge/85817
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-904170-ksa.
=== modified file 'mrp_subproduct/mrp_subproduct.py'
--- mrp_subproduct/mrp_subproduct.py 2011-11-11 13:59:06 +0000
+++ mrp_subproduct/mrp_subproduct.py 2011-12-20 10:44:33 +0000
@@ -124,4 +124,45 @@
return super(mrp_production, self)._get_subproduct_factor(cr, uid, production_id, move_id, context=context)
mrp_production()
+
+class change_production_qty(osv.osv_memory):
+ _inherit = 'change.production.qty'
+
+ def change_prod_qty(self, cr, uid, ids, context=None):
+ """
+ Changes the Quantity of Product.
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+ @return:
+ """
+ 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
+ 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']})
+ for m in prod.move_created_ids:
+ for sub_product in prod.bom_id.sub_products:
+ if sub_product.subproduct_type == 'fixed' and sub_product.product_id.id == m.product_id.id:
+ move_lines_obj.write(cr, uid, [m.id], {'product_qty': sub_product.product_qty})
+ else:
+ move_lines_obj.write(cr, uid, [m.id], {'product_qty': wiz_qty.product_qty})
+
+ return {}
+
+change_production_qty()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
_______________________________________________
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