summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2017-12-28 13:17:19 +0100
committerSimon Lejeune <sle@openerp.com>2017-12-28 15:30:13 +0100
commit7862ce4d5d0b52eb4ec172bfaed2c296182dfc7f (patch)
treea5bb0ab1d92667a91261d7f3d79065c331661fe2
parent091c86c21bdebe4592fb64ba0f0a589a25b93a27 (diff)
[FIX] mrp: mo: state and optional bom line
Optional bom line havea default `product_qty` of 0. As the "check availability" button is displayed if the MO is not available and the `_compute_availability` method considers all move of 0 `product_qty` as unassiged, the "check availability" button was always displayed and it was confusing. Do not consider move with a 0 product_qty in the `_compute_availability` method to fix the display of the button.
-rw-r--r--addons/mrp/models/mrp_production.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py
index cd399d60f67..3b66e1def7c 100644
--- a/addons/mrp/models/mrp_production.py
+++ b/addons/mrp/models/mrp_production.py
@@ -216,8 +216,9 @@ class MrpProduction(models.Model):
if order.bom_id.ready_to_produce == 'all_available':
order.availability = any(move.state not in ('assigned', 'done', 'cancel') for move in order.move_raw_ids) and 'waiting' or 'assigned'
else:
- partial_list = [x.state in ('partially_available', 'assigned') for x in order.move_raw_ids]
- assigned_list = [x.state in ('assigned', 'done', 'cancel') for x in order.move_raw_ids]
+ move_raw_ids = order.move_raw_ids.filtered(lambda m: m.product_qty)
+ partial_list = [x.state in ('partially_available', 'assigned') for x in move_raw_ids]
+ assigned_list = [x.state in ('assigned', 'done', 'cancel') for x in move_raw_ids]
order.availability = (all(assigned_list) and 'assigned') or (any(partial_list) and 'partially_available') or 'waiting'
@api.depends('move_raw_ids', 'is_locked', 'state', 'move_raw_ids.quantity_done')