From 0cfc78cdad8de5ffbab3c6a4ed420187a0397782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 17 Sep 2023 19:19:17 +0200 Subject: [PATCH] Do not fail to set default fiscal year when context value is None We can not compare contextual fiscalyear or period as positive if their values have been set to None. Closes #12502 --- modules/account/account.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/account/account.py b/modules/account/account.py index 66ff27602a..1340c4dcd5 100644 --- a/modules/account/account.py +++ b/modules/account/account.py @@ -2179,10 +2179,12 @@ class GeneralLedgerAccountContext(ModelView): FiscalYear = pool.get('account.fiscalyear') Period = pool.get('account.period') context = Transaction().context - if context.get('fiscalyear', -1) >= 0: - return context['fiscalyear'] - elif context.get('period', -1) >= 0: - period = Period(context['period']) + fiscalyear_id = context.get('fiscalyear') + period_id = context.get('period') + if fiscalyear_id is not None and fiscalyear_id >= 0: + return fiscalyear_id + elif period_id is not None and period_id >= 0: + period = Period(period_id) return period.fiscalyear.id else: try: