From 7862ce4d5d0b52eb4ec172bfaed2c296182dfc7f Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Thu, 28 Dec 2017 13:17:19 +0100 Subject: [PATCH] [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. --- addons/mrp/models/mrp_production.py | 5 +++-- 1 file 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')