[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.
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user