From 35f3dea5d2641f88cbf61a3540851d2788db0055 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 27 Nov 2015 15:43:04 +0100 Subject: [PATCH] [FIX] stock_dropshipping: do not raise a warning for dropshipping product When selling a product with a dropshipping route, the available stock was checked and a warning got raise if it was the case. The _check_routing was not working properly as is called in a context of an onchange and 'self' was the record in the database, not in the browser. Just use check there is a dropshipping route on the product instead of checking it on the routes of the sale order line (not reliable info anyway). Add a todo for master to improve it to change the signature of the method. opw 657760 --- addons/stock_dropshipping/stock_dropshipping.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/stock_dropshipping/stock_dropshipping.py b/addons/stock_dropshipping/stock_dropshipping.py index a68d0520acd..a3741e8d67a 100644 --- a/addons/stock_dropshipping/stock_dropshipping.py +++ b/addons/stock_dropshipping/stock_dropshipping.py @@ -7,6 +7,7 @@ from openerp.exceptions import UserError class sale_order_line(models.Model): _inherit = 'sale.order.line' + # TODO @api.model as called from onchange @api.multi def _check_routing(self, product, warehouse): """ skip stock verification if the route goes from supplier to customer @@ -14,12 +15,11 @@ class sale_order_line(models.Model): """ res = super(sale_order_line, self)._check_routing(product, warehouse) if not res: - for line in self: - for pull_rule in line.route_id.pull_ids: + for route in product.route_ids: + for pull_rule in route.pull_ids: if (pull_rule.picking_type_id.default_location_src_id.usage == 'supplier' and pull_rule.picking_type_id.default_location_dest_id.usage == 'customer'): - res = True - break + return True return res