From 37b1689be7585e72eca2fce68fa70cfe45e314a0 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Mon, 14 Oct 2019 13:15:22 +0000 Subject: [PATCH] [FIX] account, analytic: remove company_ids context key mechanism --- addons/account/models/account_move.py | 7 ++++--- addons/analytic/models/analytic_account.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index fb1fbea2b70..bea32a8313f 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3810,9 +3810,10 @@ class AccountMoveLine(models.Model): if context.get('company_id'): domain += [('company_id', '=', context['company_id'])] - - if 'company_ids' in context: - domain += [('company_id', 'in', context['company_ids'])] + elif context.get('allowed_company_ids'): + domain += [('company_id', 'in', self.env.companies.ids)] + else: + domain += [('company_id', '=', self.env.company.id)] if context.get('reconcile_date'): domain += ['|', ('reconciled', '=', False), '|', ('matched_debit_ids.max_date', '>', context['reconcile_date']), ('matched_credit_ids.max_date', '>', context['reconcile_date'])] diff --git a/addons/analytic/models/analytic_account.py b/addons/analytic/models/analytic_account.py index 286ff4a66f5..d6945cfcda4 100644 --- a/addons/analytic/models/analytic_account.py +++ b/addons/analytic/models/analytic_account.py @@ -82,7 +82,10 @@ class AccountAnalyticAccount(models.Model): def _compute_debit_credit_balance(self): Curr = self.env['res.currency'] analytic_line_obj = self.env['account.analytic.line'] - domain = [('account_id', 'in', self.ids)] + domain = [ + ('account_id', 'in', self.ids) + ('company_id', 'in', [False] + self.env.companies.ids) + ] if self._context.get('from_date', False): domain.append(('date', '>=', self._context['from_date'])) if self._context.get('to_date', False): @@ -90,8 +93,6 @@ class AccountAnalyticAccount(models.Model): if self._context.get('tag_ids'): tag_domain = expression.OR([[('tag_ids', 'in', [tag])] for tag in self._context['tag_ids']]) domain = expression.AND([domain, tag_domain]) - if self._context.get('company_ids'): - domain.append(('company_id', 'in', self._context['company_ids'])) user_currency = self.env.company.currency_id credit_groups = analytic_line_obj.read_group(