diff --git a/stock_putaway_rule/models/product.py b/stock_putaway_rule/models/product.py index 94da23d30271..92b5f9176ce3 100644 --- a/stock_putaway_rule/models/product.py +++ b/stock_putaway_rule/models/product.py @@ -25,7 +25,9 @@ def action_view_related_putaway_rules(self): ('product_id', '=', self.id), ('category_id', '=', self.product_tmpl_id.categ_id.id), ] - return self.env['product.template']._get_action_view_related_putaway_rules(domain) + return self.env[ + 'product.template' + ]._get_action_view_related_putaway_rules(domain) class ProductTemplate(models.Model): diff --git a/stock_putaway_rule/models/product_strategy.py b/stock_putaway_rule/models/product_strategy.py index 859709b127a1..55ae8c3a92fd 100644 --- a/stock_putaway_rule/models/product_strategy.py +++ b/stock_putaway_rule/models/product_strategy.py @@ -129,7 +129,7 @@ def filter_rules(self, product=None, category=None): def select_putaway(self): """Select a putaway location to return""" - return self[0] + return self[0] if len(self) > 1 else self def _get_destination_location(self): return self.location_out_id diff --git a/stock_putaway_rule/models/stock_location.py b/stock_putaway_rule/models/stock_location.py index e49db90a7510..8f27930fbb11 100644 --- a/stock_putaway_rule/models/stock_location.py +++ b/stock_putaway_rule/models/stock_location.py @@ -19,13 +19,15 @@ def get_putaway_strategy(self, product): while current_location and not putaway_location: # Looking for a putaway about the product. putaway_location = current_location._get_putaway_rule_location( - product=product + product=product, ) + if putaway_location: + break # If not product putaway found, we're looking with category so. categ = product.categ_id while categ: putaway_location = current_location._get_putaway_rule_location( - category=categ + category=categ, ) if putaway_location: break