[FIX] mrp,mrp_subproduct:sub_products qty is True when Product type is Variable
lp bug: https://launchpad.net/bugs/794431 fixed bzr revid: aag@tinyerp.com-20110817091826-fkg4y3b6pbbh220e
This commit is contained in:
+8
-3
@@ -680,6 +680,11 @@ class mrp_production(osv.osv):
|
||||
if production.move_created_ids:
|
||||
res = False
|
||||
return res
|
||||
|
||||
def rest_qty_compute(self, cr, uid, obj, move_obj=None, context=None):
|
||||
qty = obj.product_qty * sub_qty
|
||||
res = {'product_qty': qty, 'sub_qty': 1}
|
||||
return res
|
||||
|
||||
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).
|
||||
@@ -694,7 +699,6 @@ class mrp_production(osv.osv):
|
||||
stock_mov_obj = self.pool.get('stock.move')
|
||||
production = self.browse(cr, uid, production_id, context=context)
|
||||
|
||||
|
||||
produced_qty = 0
|
||||
if production_mode == 'consume_produce':
|
||||
produced_qty = production_qty
|
||||
@@ -749,11 +753,12 @@ class mrp_production(osv.osv):
|
||||
|
||||
for produce_product in production.move_created_ids:
|
||||
produced_qty = produced_products.get(produce_product.product_id.id, 0)
|
||||
rest_qty = production.product_qty - produced_qty
|
||||
get_qty = self.rest_qty_compute(cr, uid, production, produce_product)
|
||||
rest_qty = get_qty['product_qty'] - produced_qty
|
||||
if rest_qty <= production_qty:
|
||||
production_qty = rest_qty
|
||||
if rest_qty > 0 :
|
||||
stock_mov_obj.action_consume(cr, uid, [produce_product.id], production_qty, context=context)
|
||||
stock_mov_obj.action_consume(cr, uid, [produce_product.id], production_qty * get_qty['sub_qty'], context=context)
|
||||
|
||||
for raw_product in production.move_lines2:
|
||||
new_parent_ids = []
|
||||
|
||||
@@ -49,8 +49,9 @@ class mrp_product_produce(osv.osv_memory):
|
||||
context['active_id'], context=context)
|
||||
done = 0.0
|
||||
for move in prod.move_created_ids2:
|
||||
if not move.scrapped:
|
||||
done += move.product_qty
|
||||
if move.product_id == prod.product_id:
|
||||
if not move.scrapped:
|
||||
done += move.product_qty
|
||||
return (prod.product_qty - done) or prod.product_qty
|
||||
|
||||
_defaults = {
|
||||
|
||||
@@ -97,5 +97,15 @@ 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):
|
||||
sub_obj = self.pool.get('mrp.subproduct')
|
||||
sub_qty = 1
|
||||
sub_id = sub_obj.search(cr, uid,[('product_id', '=', move_obj.product_id.id)] )
|
||||
if sub_id:
|
||||
sub_qty = sub_obj.browse(cr ,uid, sub_id[0]).product_qty
|
||||
qty = obj.product_qty * sub_qty
|
||||
res = {'product_qty': qty, 'sub_qty': sub_qty}
|
||||
return res
|
||||
|
||||
mrp_production()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
Reference in New Issue
Block a user