From 6d28c9c2e5ea3e9a3b8a872627a411bbfe2f2a59 Mon Sep 17 00:00:00 2001 From: "Tiffany Chang (tic)" Date: Thu, 15 Sep 2022 08:42:36 +0000 Subject: [PATCH] [IMP] mrp_subcontracting: hide is_subcontracting_location setting The `is_subcontracting_location` setting is intended only for complicated route/rule use cases therefore we make it visible only in debug mode to prevent users from setting this value and unintentionally creating a lot of new routes/rules unnecessary. Additionally, it is expected that users who previously set these up manually will not want their custom rules/routes changed but will still need the existing behavior to continue, so we restore the previous check for subcontracting locations set as sublocations of the primary company subcontracting location. Follow up to task: 2720393 Part-of: odoo/odoo#100219 --- addons/mrp_subcontracting/views/stock_location_views.xml | 2 +- addons/mrp_subcontracting_dropshipping/models/stock_rule.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/mrp_subcontracting/views/stock_location_views.xml b/addons/mrp_subcontracting/views/stock_location_views.xml index f04b8c06464..aa3d9a9100c 100644 --- a/addons/mrp_subcontracting/views/stock_location_views.xml +++ b/addons/mrp_subcontracting/views/stock_location_views.xml @@ -6,7 +6,7 @@ - + diff --git a/addons/mrp_subcontracting_dropshipping/models/stock_rule.py b/addons/mrp_subcontracting_dropshipping/models/stock_rule.py index 91dac0321b2..db4cf3e506d 100644 --- a/addons/mrp_subcontracting_dropshipping/models/stock_rule.py +++ b/addons/mrp_subcontracting_dropshipping/models/stock_rule.py @@ -8,7 +8,9 @@ class StockRule(models.Model): _inherit = 'stock.rule' def _prepare_purchase_order(self, company_id, origins, values): - if 'partner_id' not in values[0] and self.location_dest_id.is_subcontracting_location: + if 'partner_id' not in values[0] \ + and (company_id.subcontracting_location_id.parent_path in self.location_dest_id.parent_path + or self.location_dest_id.is_subcontracting_location): values[0]['partner_id'] = values[0]['group_id'].partner_id.id return super()._prepare_purchase_order(company_id, origins, values)