Atik Agewan(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-794431-aag into
lp:openobject-addons.
Requested reviews:
Rucha (Open ERP) (rpa-openerp)
Related bugs:
Bug #794431 in OpenERP Addons: "sub_product results in wrong resulted
quantity "
https://bugs.launchpad.net/openobject-addons/+bug/794431
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-794431-aag/+merge/71830
Hello,
mrp : Add new Function rest_qty_compute to compute rest_qty.
mrp_subproducts : overwrite rest_qty_compute function.
so when subproducts qty type is variable than it will compute true qty.
Thanks
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-794431-aag/+merge/71830
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-794431-aag.
=== modified file 'mrp/mrp.py'
--- mrp/mrp.py 2011-07-01 23:41:24 +0000
+++ mrp/mrp.py 2011-08-17 09:30:09 +0000
@@ -680,6 +680,11 @@
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 @@
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 @@
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 = []
=== modified file 'mrp/wizard/mrp_product_produce.py'
--- mrp/wizard/mrp_product_produce.py 2011-04-21 05:14:24 +0000
+++ mrp/wizard/mrp_product_produce.py 2011-08-17 09:30:09 +0000
@@ -49,8 +49,9 @@
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 = {
=== modified file 'mrp_subproduct/mrp_subproduct.py'
--- mrp_subproduct/mrp_subproduct.py 2011-01-14 00:11:01 +0000
+++ mrp_subproduct/mrp_subproduct.py 2011-08-17 09:30:09 +0000
@@ -97,5 +97,15 @@
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:
_______________________________________________
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