From fd779c89edb3e1284659c69c344f616780be77db Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Wed, 1 Dec 2021 12:14:52 +0100 Subject: [PATCH] [FIX] multi company error on rma location choice --- rma/models/rma.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rma/models/rma.py b/rma/models/rma.py index 8277c7b7..b204e25c 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -18,7 +18,14 @@ class Rma(models.Model): _inherit = ["mail.thread", "portal.mixin", "mail.activity.mixin"] def _domain_location_id(self): - rma_loc = self.env["stock.warehouse"].search([]).mapped("rma_loc_id") + # this is done with sudo, intercompany rules are not applied by default so we + # add company in domain explicitly to avoid multi-company rule error when + # the user will try to choose a location + rma_loc = ( + self.env["stock.warehouse"] + .search([("company_id", "in", self.env.companies.ids)]) + .mapped("rma_loc_id") + ) return [("id", "child_of", rma_loc.ids)] # General fields