From 2408befc8d9a842ddcdcce016ee6b60318de5236 Mon Sep 17 00:00:00 2001 From: Arnaud Baes Date: Wed, 14 Aug 2019 16:23:40 +0000 Subject: [PATCH] [FIX] sale_stock: wrong route computed on so lines _compute_is_mto was based on the sequence of the routes, as most of those sequences were hardcoded, some had the same values, resulting in wrong calculations. Furthermore, the method was setting the so lines as mto if the sequence of the MTO route had the priority on the other ones, even if the mto route wasn't set on the product. This simply ensure to check the mto route is set on the product, sequences should be set manually to prevent any sequence conflict. TaskID: 2053703 closes odoo/odoo#35740 Signed-off-by: Arnold Moyaux --- addons/sale_stock/models/sale_order.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 63150f16e37..083bf9f4551 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -264,7 +264,7 @@ class SaleOrderLine(models.Model): remaining.free_qty_today = False remaining.qty_available_today = False - @api.depends('product_id', 'route_id', 'order_id.warehouse_id') + @api.depends('product_id', 'route_id', 'order_id.warehouse_id', 'product_id.route_ids') def _compute_is_mto(self): """ Verify the route of the product based on the warehouse set 'is_available' at True if the product availibility in stock does @@ -278,18 +278,18 @@ class SaleOrderLine(models.Model): product_routes = line.route_id or (product.route_ids + product.categ_id.total_route_ids) # Check MTO - wh_mto_route = line.order_id.warehouse_id.mto_pull_id.route_id - if wh_mto_route and wh_mto_route.mapped('sequence') <= product_routes.mapped('sequence'): - line.is_mto = True - else: - mto_route = False + mto_route = line.order_id.warehouse_id.mto_pull_id.route_id + if not mto_route: try: mto_route = self.env['stock.warehouse']._find_global_route('stock.route_warehouse0_mto', _('Make To Order')) except UserError: # if route MTO not found in ir_model_data, we treat the product as in MTS pass - if mto_route and mto_route in product_routes: - line.is_mto = True + + if mto_route and mto_route in product.route_ids: + line.is_mto = True + else: + line.is_mto = False @api.depends('product_id') def _compute_qty_delivered_method(self):