Add cache to fiscalyear find, test state and return instance

This commit is contained in:
Cédric Krier
2023-02-11 00:13:24 +01:00
parent 45bbfa8fb5
commit c32d602221
6 changed files with 78 additions and 47 deletions
+5 -3
View File
@@ -132,6 +132,8 @@ class ECSalesListContext(ModelView):
pool = Pool()
FiscalYear = pool.get('account.fiscalyear')
context = Transaction().context
return context.get(
'fiscalyear',
FiscalYear.find(context.get('company'), exception=False))
if 'fiscalyear' not in context:
fiscalyear = FiscalYear.find(
cls.default_company(), exception=False, test_state=False)
return fiscalyear.id if fiscalyear else None
return context['fiscalyear']