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
1=== modified file 'mrp/mrp.py'
2--- mrp/mrp.py 2013-11-19 16:25:22 +0000
3+++ mrp/mrp.py 2014-01-22 12:47:11 +0000
4@@ -758,15 +758,11 @@
5 for scheduled in production.product_lines:
6
7 # total qty of consumed product we need after this consumption
8- total_consume = ((production_qty + produced_qty) * scheduled.product_qty / production.product_qty)
9+ total_consume = ((production_qty - produced_qty) * scheduled.product_qty / production.product_qty)
10
11 # qty available for consume and produce
12 qty_avail = scheduled.product_qty - consumed_data.get(scheduled.product_id.id, 0.0)
13
14- if qty_avail <= 0.0:
15- # there will be nothing to consume for this raw material
16- continue
17-
18 raw_product = [move for move in production.move_lines if move.product_id.id==scheduled.product_id.id]
19 if raw_product:
20 # qtys we have to consume
21@@ -775,9 +771,6 @@
22 # if qtys we have to consume is more than qtys available to consume
23 prod_name = scheduled.product_id.name_get()[0][1]
24 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))
25- if qty <= 0.0:
26- # we already have more qtys consumed than we need
27- continue
28
29 raw_product[0].action_consume(qty, raw_product[0].location_id.id, context=context)
30
31
32=== modified file 'mrp/stock.py'
33--- mrp/stock.py 2013-09-11 12:30:44 +0000
34+++ mrp/stock.py 2014-01-22 12:47:11 +0000
35@@ -112,9 +112,12 @@
36 production_obj = self.pool.get('mrp.production')
37 wf_service = netsvc.LocalService("workflow")
38 for move in self.browse(cr, uid, ids):
39+ production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
40+ if move.product_qty == 0:
41+ self.pool['stock.move'].action_cancel(cr, uid, [move.id], context=context)
42+ continue
43 move.action_confirm(context)
44 new_moves = super(StockMove, self).action_consume(cr, uid, [move.id], product_qty, location_id, context=context)
45- production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
46 for prod in production_obj.browse(cr, uid, production_ids, context=context):
47 if prod.state == 'confirmed':
48 production_obj.force_production(cr, uid, [prod.id])
49
50=== modified file 'stock/stock.py'
51--- stock/stock.py 2013-11-28 14:50:59 +0000
52+++ stock/stock.py 2014-01-22 12:47:11 +0000
53@@ -2641,7 +2641,7 @@
54 quantity = move.product_qty
55
56 uos_qty = quantity / move_qty * move.product_uos_qty
57- if quantity_rest > 0:
58+ if float_compare(quantity_rest, 0, precision_rounding=move.product_id.uom_id.rounding):
59 default_val = {
60 'product_qty': quantity,
61 'product_uos_qty': uos_qty,