summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorArnaud Baes <arb@odoo.com>2019-08-14 16:23:40 +0000
committerArnaud Baes <arb@odoo.com>2019-08-21 09:51:17 +0000
commit2408befc8d9a842ddcdcce016ee6b60318de5236 (patch)
treedff2289c00d045a4c32e3affce3d875ff902e1ee /addons
parentc1281f57953b47b9f42f1a678fff789ce0019f36 (diff)
[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 <amoyaux@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/sale_stock/models/sale_order.py16
1 files 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):