From 874fa51dbe5d47a8b511cbf99e51e014e1577908 Mon Sep 17 00:00:00 2001 From: "Mathias Mathy (MAMA)" Date: Thu, 11 May 2023 11:18:23 +0000 Subject: [PATCH] [FIX] stock: Warning on replenish max Qty change Change the rules for the activation of the unwanted replenish warning. Before : Verification for unwanted replenish were only done if the stock_orderpoint have a max qty >= 1 After : Verification for unwanted replenish are done if the stock_orderpoint have a max qty >= 0 task : 2918947 closes odoo/odoo#121144 Signed-off-by: Arnold Moyaux (arm) --- .../sale_purchase_stock/tests/test_unwanted_replenish_flow.py | 4 ++-- addons/stock/models/stock_orderpoint.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/sale_purchase_stock/tests/test_unwanted_replenish_flow.py b/addons/sale_purchase_stock/tests/test_unwanted_replenish_flow.py index 95c8d668f74..17bbac58048 100644 --- a/addons/sale_purchase_stock/tests/test_unwanted_replenish_flow.py +++ b/addons/sale_purchase_stock/tests/test_unwanted_replenish_flow.py @@ -64,14 +64,14 @@ class TestWarnUnwantedReplenish(common.TransactionCase): orderpoint_form = Form(cls.env['stock.warehouse.orderpoint']) orderpoint_form.product_id = cls.product_A orderpoint_form.product_min_qty = 0.0 - orderpoint_form.product_max_qty = 1.0 + orderpoint_form.product_max_qty = 0.0 cls.orderpoint_A = orderpoint_form.save() cls.orderpoint_A.trigger = 'manual' orderpoint_form = Form(cls.env['stock.warehouse.orderpoint']) orderpoint_form.product_id = cls.product_B orderpoint_form.product_min_qty = 0.0 - orderpoint_form.product_max_qty = 1.0 + orderpoint_form.product_max_qty = 0.0 cls.orderpoint_B = orderpoint_form.save() cls.orderpoint_B.trigger = 'manual' diff --git a/addons/stock/models/stock_orderpoint.py b/addons/stock/models/stock_orderpoint.py index 6ea867efccf..dcc2ff8402a 100644 --- a/addons/stock/models/stock_orderpoint.py +++ b/addons/stock/models/stock_orderpoint.py @@ -174,7 +174,7 @@ class StockWarehouseOrderpoint(models.Model): @api.depends('product_id', 'qty_to_order', 'product_max_qty') def _compute_unwanted_replenish(self): for orderpoint in self: - if not orderpoint.product_id or float_is_zero(orderpoint.qty_to_order, precision_rounding=orderpoint.product_uom.rounding) or float_is_zero(orderpoint.product_max_qty, precision_rounding=orderpoint.product_uom.rounding): + if not orderpoint.product_id or float_is_zero(orderpoint.qty_to_order, precision_rounding=orderpoint.product_uom.rounding) or float_compare(orderpoint.product_max_qty, 0, precision_rounding=orderpoint.product_uom.rounding) == -1: orderpoint.unwanted_replenish = False else: after_replenish_qty = orderpoint.product_id.with_context(company_id=orderpoint.company_id.id, location=orderpoint.location_id.id).virtual_available + orderpoint.qty_to_order