Test company header is not empty before using its id

Closes #12363
This commit is contained in:
Cédric Krier
2023-07-18 22:58:23 +02:00
parent 5b1a9801a0
commit f2ebadf1da
3 changed files with 9 additions and 3 deletions
+3 -1
View File
@@ -1945,7 +1945,9 @@ class PurchaseReport(CompanyReport):
pool = Pool()
Date = pool.get('ir.date')
context = super().get_context(records, header, data)
with Transaction().set_context(company=context.get('company')):
company = header.get('company')
with Transaction().set_context(
company=company.id if company else None):
context['today'] = Date.today()
return context
@@ -431,7 +431,9 @@ class PurchaseRequestQuotationReport(CompanyReport):
pool = Pool()
Date = pool.get('ir.date')
context = super().get_context(records, header, data)
with Transaction().set_context(company=header['company'].id):
company = header.get('company')
with Transaction().set_context(
company=company.id if company else None):
context['today'] = Date.today()
return context
+3 -1
View File
@@ -1986,7 +1986,9 @@ class SaleReport(CompanyReport):
pool = Pool()
Date = pool.get('ir.date')
context = super().get_context(records, header, data)
with Transaction().set_context(company=header['company'].id):
company = header.get('company')
with Transaction().set_context(
company=company.id if company else None):
context['today'] = Date.today()
return context