[FIX] mrp,mrp_subproduct:sub_products qty is True when Product type is Variable & sub product is in more than one BOM
lp bug: https://launchpad.net/bugs/794431 fixed bzr revid: aag@tinyerp.com-20110823102708-itcfkm74hlhj6m3t
This commit is contained in:
+5
-3
@@ -681,8 +681,10 @@ class mrp_production(osv.osv):
|
||||
res = False
|
||||
return res
|
||||
|
||||
def rest_qty_compute(self, cr, uid, obj, move_obj=None, context=None):
|
||||
return {'product_qty': obj.product_qty, 'sub_qty': 1}
|
||||
def rest_qty_compute(self, cr, uid, production_id, move_id=None, context=None):
|
||||
production_obj = self.pool.get('mrp.production')
|
||||
production_browse = prod_obj.browse(cr, uid, production_id, context)
|
||||
return {'product_qty': production_browse.product_qty, 'sub_qty': 1}
|
||||
|
||||
def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None):
|
||||
""" To produce final product based on production mode (consume/consume&produce).
|
||||
@@ -751,7 +753,7 @@ class mrp_production(osv.osv):
|
||||
|
||||
for produce_product in production.move_created_ids:
|
||||
produced_qty = produced_products.get(produce_product.product_id.id, 0)
|
||||
get_qty = self.rest_qty_compute(cr, uid, production, produce_product)
|
||||
get_qty = self.rest_qty_compute(cr, uid, production.id, produce_product.id)
|
||||
rest_qty = get_qty['product_qty'] - produced_qty
|
||||
if rest_qty <= production_qty:
|
||||
production_qty = rest_qty
|
||||
|
||||
@@ -97,13 +97,17 @@ class mrp_production(osv.osv):
|
||||
self.pool.get('stock.move').create(cr, uid, data)
|
||||
return picking_id
|
||||
|
||||
def rest_qty_compute(self, cr, uid, obj, move_obj=None, context=None):
|
||||
def rest_qty_compute(self, cr, uid, production_id, move_id=None, context=None):
|
||||
sub_obj = self.pool.get('mrp.subproduct')
|
||||
move_obj = self.pool.get('stock.move')
|
||||
production_obj = self.pool.get('mrp.production')
|
||||
production_browse = production_obj.browse(cr, uid, production_id, context)
|
||||
move_browse = move_obj.browse(cr, uid, move_id, context)
|
||||
sub_qty = 1
|
||||
sub_id = sub_obj.search(cr, uid,[('product_id', '=', move_obj.product_id.id)] )
|
||||
sub_id = sub_obj.search(cr, uid,[('product_id', '=', move_browse.product_id.id),('bom_id', '=', production_browse.bom_id.id)] )
|
||||
if sub_id:
|
||||
sub_qty = sub_obj.browse(cr ,uid, sub_id[0]).product_qty
|
||||
return {'product_qty': obj.product_qty * sub_qty, 'sub_qty': sub_qty}
|
||||
return {'product_qty': production_browse.product_qty * sub_qty, 'sub_qty': sub_qty}
|
||||
|
||||
mrp_production()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
Reference in New Issue
Block a user