From 8ae6406a37dbe615bd1fcd3c0356e5a7951b96f3 Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Mon, 4 Apr 2016 13:58:04 +0200 Subject: [PATCH] [FIX] account: allow forcing company when fetching fpos The code to fetch the fiscal position of a partner uses ACLs and ir_rules to select the correct ones, but when calling the function as admin, multi-company rules flight out the window. By allowing to force a company in the context, we can get the fpos as the admin from the pov of any company. --- addons/account/models/partner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index e0c8dac8373..337797b2d1c 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -123,6 +123,8 @@ class AccountFiscalPosition(models.Model): if not country_id: return False base_domain = [('auto_apply', '=', True), ('vat_required', '=', vat_required)] + if self.env.context.get('force_company'): + base_domain.append(('company_id', '=', self.env.context.get('force_company'))) null_state_dom = state_domain = [('state_ids', '=', False)] null_zip_dom = zip_domain = [('zip_from', '=', 0), ('zip_to', '=', 0)] null_country_dom = [('country_id', '=', False), ('country_group_id', '=', False)]