[FIX] mrp_subproduct: update qty to produce now change accordingly the qty of subproducts created
lp bug: https://launchpad.net/bugs/904170 fixed bzr revid: qdp-launchpad@openerp.com-20120214155746-zyejucj0745obtps
This commit is contained in:
parent
9effc0ba64
commit
471d403d81
|
@ -49,6 +49,11 @@ class change_production_qty(osv.osv_memory):
|
||||||
res.update({'product_qty': prod.product_qty})
|
res.update({'product_qty': prod.product_qty})
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _update_product_to_produce(self, cr, uid, prod, qty, context=None):
|
||||||
|
move_lines_obj = self.pool.get('stock.move')
|
||||||
|
for m in prod.move_created_ids:
|
||||||
|
move_lines_obj.write(cr, uid, [m.id], {'product_qty': qty})
|
||||||
|
|
||||||
def change_prod_qty(self, cr, uid, ids, context=None):
|
def change_prod_qty(self, cr, uid, ids, context=None):
|
||||||
"""
|
"""
|
||||||
Changes the Quantity of Product.
|
Changes the Quantity of Product.
|
||||||
|
@ -87,8 +92,7 @@ class change_production_qty(osv.osv_memory):
|
||||||
for r in res[0]:
|
for r in res[0]:
|
||||||
if r['product_id'] == move.product_id.id:
|
if r['product_id'] == move.product_id.id:
|
||||||
move_lines_obj.write(cr, uid, [move.id], {'product_qty' : r['product_qty']})
|
move_lines_obj.write(cr, uid, [move.id], {'product_qty' : r['product_qty']})
|
||||||
for m in prod.move_created_ids:
|
self._update_product_to_produce(cr, uid, prod, wiz_qty.product_qty, context=context)
|
||||||
move_lines_obj.write(cr, uid, [m.id], {'product_qty': wiz_qty.product_qty})
|
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,14 @@ class mrp_bom(osv.osv):
|
||||||
_columns={
|
_columns={
|
||||||
'sub_products':fields.one2many('mrp.subproduct', 'bom_id', 'sub_products'),
|
'sub_products':fields.one2many('mrp.subproduct', 'bom_id', 'sub_products'),
|
||||||
}
|
}
|
||||||
|
|
||||||
mrp_bom()
|
mrp_bom()
|
||||||
|
|
||||||
class mrp_production(osv.osv):
|
class mrp_production(osv.osv):
|
||||||
_description = 'Production'
|
_description = 'Production'
|
||||||
_inherit= 'mrp.production'
|
_inherit= 'mrp.production'
|
||||||
|
|
||||||
|
|
||||||
def action_confirm(self, cr, uid, ids):
|
def action_confirm(self, cr, uid, ids):
|
||||||
""" Confirms production order and calculates quantity based on subproduct_type.
|
""" Confirms production order and calculates quantity based on subproduct_type.
|
||||||
@return: Newly generated picking Id.
|
@return: Newly generated picking Id.
|
||||||
|
@ -124,4 +126,22 @@ class mrp_production(osv.osv):
|
||||||
return super(mrp_production, self)._get_subproduct_factor(cr, uid, production_id, move_id, context=context)
|
return super(mrp_production, self)._get_subproduct_factor(cr, uid, production_id, move_id, context=context)
|
||||||
|
|
||||||
mrp_production()
|
mrp_production()
|
||||||
|
|
||||||
|
class change_production_qty(osv.osv_memory):
|
||||||
|
_inherit = 'change.production.qty'
|
||||||
|
|
||||||
|
def _update_product_to_produce(self, cr, uid, prod, qty, context=None):
|
||||||
|
bom_obj = self.pool.get('mrp.bom')
|
||||||
|
move_lines_obj = self.pool.get('stock.move')
|
||||||
|
prod_obj = self.pool.get('mrp.production')
|
||||||
|
for m in prod.move_created_ids:
|
||||||
|
if m.product_id.id == prod.product_id.id:
|
||||||
|
move_lines_obj.write(cr, uid, [m.id], {'product_qty': qty})
|
||||||
|
else:
|
||||||
|
for sub_product_line in prod.bom_id.sub_products:
|
||||||
|
if sub_product_line.product_id.id == m.product_id.id:
|
||||||
|
factor = prod_obj._get_subproduct_factor(cr, uid, prod.id, m.id, context=context)
|
||||||
|
subproduct_qty = sub_product_line.subproduct_type == 'variable' and qty * factor or sub_product_line.product_qty
|
||||||
|
move_lines_obj.write(cr, uid, [m.id], {'product_qty': subproduct_qty})
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
Loading…
Reference in New Issue