From 45eac34ee574ef8d29a7d711db1e6fd9abdbf4f1 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Tue, 26 Apr 2022 17:47:16 +0200 Subject: [PATCH] Add company domain to fiscalyear of reporting contexts issue11206 review376651002 --- account.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/account.py b/account.py index fd58736c02..974a027010 100644 --- a/account.py +++ b/account.py @@ -2035,7 +2035,11 @@ class GeneralLedgerAccountContext(ModelView): 'General Ledger Account Context' __name__ = 'account.general_ledger.account.context' fiscalyear = fields.Many2One('account.fiscalyear', 'Fiscal Year', - required=True) + required=True, + domain=[ + ('company', '=', Eval('company')), + ], + depends=['company']) start_period = fields.Many2One('account.period', 'Start Period', domain=[ ('fiscalyear', '=', Eval('fiscalyear')), @@ -2119,6 +2123,12 @@ class GeneralLedgerAccountContext(ModelView): def default_to_date(cls): return Transaction().context.get('to_date') + @fields.depends('company', 'fiscalyear', methods=['on_change_fiscalyear']) + def on_change_company(self): + if self.fiscalyear and self.fiscalyear.company != self.company: + self.fiscalyear = None + self.on_change_fiscalyear() + @fields.depends('fiscalyear', 'start_period', 'end_period') def on_change_fiscalyear(self): if (self.start_period @@ -2586,6 +2596,12 @@ class IncomeStatementContext(ModelView): def default_comparison(cls): return False + @fields.depends('company', 'fiscalyear', methods=['on_change_fiscalyear']) + def on_change_company(self): + if self.fiscalyear and self.fiscalyear.company != self.company: + self.fiscalyear = None + self.on_change_fiscalyear() + @fields.depends('fiscalyear', 'start_period', 'end_period') def on_change_fiscalyear(self): if (self.start_period