From ef75711fb2d79aacf1fa89dfbed1fb9b36fce068 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Fri, 3 Nov 2023 11:46:20 +0100 Subject: [PATCH] [FIX] mrp: clean bom overview report Does 2 things: - ensure that the "free_qty" doesn't display a negative value (=> consistent with MO overview + avoids neg "Ready to Produce" values) - ensure that showOptions.availabilities is always a Boolean and never "undefined" (=> avoid traceback when opening overview while in debug mode) closes odoo/odoo#140767 Signed-off-by: Quentin Wolfs (quwo) --- addons/mrp/report/mrp_report_bom_structure.py | 2 +- .../mrp/static/src/components/bom_overview/mrp_bom_overview.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp/report/mrp_report_bom_structure.py b/addons/mrp/report/mrp_report_bom_structure.py index fb5e0f05aad..615c8f50d94 100644 --- a/addons/mrp/report/mrp_report_bom_structure.py +++ b/addons/mrp/report/mrp_report_bom_structure.py @@ -380,7 +380,7 @@ class ReportBomStructure(models.AbstractModel): @api.model def _get_quantities_info(self, product, bom_uom, product_info, parent_bom=False, parent_product=False): return { - 'free_qty': product.uom_id._compute_quantity(product.free_qty, bom_uom) if product.detailed_type == 'product' else False, + 'free_qty': max(product.uom_id._compute_quantity(product.free_qty, bom_uom), 0) if product.detailed_type == 'product' else False, 'on_hand_qty': product.uom_id._compute_quantity(product.qty_available, bom_uom) if product.detailed_type == 'product' else False, 'stock_loc': 'in_stock', } diff --git a/addons/mrp/static/src/components/bom_overview/mrp_bom_overview.js b/addons/mrp/static/src/components/bom_overview/mrp_bom_overview.js index fd534f8d12a..87e0c3b024f 100644 --- a/addons/mrp/static/src/components/bom_overview/mrp_bom_overview.js +++ b/addons/mrp/static/src/components/bom_overview/mrp_bom_overview.js @@ -21,7 +21,7 @@ export class BomOverviewComponent extends Component { this.state = useState({ showOptions: { uom: false, - availabilities: false || this.props.action.context.activate_availabilities, + availabilities: false || Boolean(this.props.action.context.activate_availabilities), costs: true, operations: true, leadTimes: true,