Merge lp:~openerp-dev/openobject-addons/7.0-mrpzeromove-dle into lp:openobject-addons/7.0

Proposed by Denis Ledoux (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-mrpzeromove-dle
Merge into: lp:openobject-addons/7.0
Diff against target: 61 lines (+6/-10)
3 files modified
mrp/mrp.py (+1/-8)
mrp/stock.py (+4/-1)
stock/stock.py (+1/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-mrpzeromove-dle
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+202659@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

9784. By Denis Ledoux (OpenERP)

[FIX] mrp: avoid float rounding error using float_compare, and cancel moves if move with a quantity of 0

Sometimes, a move line with a quantity of 0 was created due to a float compared to 0 without using float_compare.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'mrp/mrp.py'
--- mrp/mrp.py 2013-11-19 16:25:22 +0000
+++ mrp/mrp.py 2014-01-22 12:47:11 +0000
@@ -758,15 +758,11 @@
758 for scheduled in production.product_lines:758 for scheduled in production.product_lines:
759759
760 # total qty of consumed product we need after this consumption760 # total qty of consumed product we need after this consumption
761 total_consume = ((production_qty + produced_qty) * scheduled.product_qty / production.product_qty)761 total_consume = ((production_qty - produced_qty) * scheduled.product_qty / production.product_qty)
762762
763 # qty available for consume and produce763 # qty available for consume and produce
764 qty_avail = scheduled.product_qty - consumed_data.get(scheduled.product_id.id, 0.0)764 qty_avail = scheduled.product_qty - consumed_data.get(scheduled.product_id.id, 0.0)
765765
766 if qty_avail <= 0.0:
767 # there will be nothing to consume for this raw material
768 continue
769
770 raw_product = [move for move in production.move_lines if move.product_id.id==scheduled.product_id.id]766 raw_product = [move for move in production.move_lines if move.product_id.id==scheduled.product_id.id]
771 if raw_product:767 if raw_product:
772 # qtys we have to consume768 # qtys we have to consume
@@ -775,9 +771,6 @@
775 # if qtys we have to consume is more than qtys available to consume771 # if qtys we have to consume is more than qtys available to consume
776 prod_name = scheduled.product_id.name_get()[0][1]772 prod_name = scheduled.product_id.name_get()[0][1]
777 raise osv.except_osv(_('Warning!'), _('You are going to consume total %s quantities of "%s".\nBut you can only consume up to total %s quantities.') % (qty, prod_name, qty_avail))773 raise osv.except_osv(_('Warning!'), _('You are going to consume total %s quantities of "%s".\nBut you can only consume up to total %s quantities.') % (qty, prod_name, qty_avail))
778 if qty <= 0.0:
779 # we already have more qtys consumed than we need
780 continue
781774
782 raw_product[0].action_consume(qty, raw_product[0].location_id.id, context=context)775 raw_product[0].action_consume(qty, raw_product[0].location_id.id, context=context)
783776
784777
=== modified file 'mrp/stock.py'
--- mrp/stock.py 2013-09-11 12:30:44 +0000
+++ mrp/stock.py 2014-01-22 12:47:11 +0000
@@ -112,9 +112,12 @@
112 production_obj = self.pool.get('mrp.production')112 production_obj = self.pool.get('mrp.production')
113 wf_service = netsvc.LocalService("workflow")113 wf_service = netsvc.LocalService("workflow")
114 for move in self.browse(cr, uid, ids):114 for move in self.browse(cr, uid, ids):
115 production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
116 if move.product_qty == 0:
117 self.pool['stock.move'].action_cancel(cr, uid, [move.id], context=context)
118 continue
115 move.action_confirm(context)119 move.action_confirm(context)
116 new_moves = super(StockMove, self).action_consume(cr, uid, [move.id], product_qty, location_id, context=context)120 new_moves = super(StockMove, self).action_consume(cr, uid, [move.id], product_qty, location_id, context=context)
117 production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
118 for prod in production_obj.browse(cr, uid, production_ids, context=context):121 for prod in production_obj.browse(cr, uid, production_ids, context=context):
119 if prod.state == 'confirmed':122 if prod.state == 'confirmed':
120 production_obj.force_production(cr, uid, [prod.id])123 production_obj.force_production(cr, uid, [prod.id])
121124
=== modified file 'stock/stock.py'
--- stock/stock.py 2013-11-28 14:50:59 +0000
+++ stock/stock.py 2014-01-22 12:47:11 +0000
@@ -2641,7 +2641,7 @@
2641 quantity = move.product_qty2641 quantity = move.product_qty
26422642
2643 uos_qty = quantity / move_qty * move.product_uos_qty2643 uos_qty = quantity / move_qty * move.product_uos_qty
2644 if quantity_rest > 0:2644 if float_compare(quantity_rest, 0, precision_rounding=move.product_id.uom_id.rounding):
2645 default_val = {2645 default_val = {
2646 'product_qty': quantity,2646 'product_qty': quantity,
2647 'product_uos_qty': uos_qty,2647 'product_uos_qty': uos_qty,