[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>
This commit is contained in:
Arnaud Baes
2019-08-21 09:51:17 +00:00
parent c1281f5795
commit 2408befc8d
+8 -8
View File
@@ -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):