[FIX] account: avoid crash when request not bound to database

- When installing account using a request (e.g. http route auth set to `None`) not bound to a database,
  the installation fails.

  To avoid this, we check if the request we are using is bound to a
  database, if not, the fallback code is executed.
This commit is contained in:
Toufik Ben Jaa
2018-12-12 15:19:25 +01:00
parent 54ad2f57ce
commit 37fa21a2af
+2 -2
View File
@@ -165,7 +165,7 @@ class AccountChartTemplate(models.Model):
of accounts had been created for it yet.
"""
self.ensure_one()
if request:
if request and request.db:
company_id = request.env.user.company_id.id
company = self.env['res.company'].browse(company_id)
else:
@@ -185,7 +185,7 @@ class AccountChartTemplate(models.Model):
rights.
"""
self.ensure_one()
if request:
if request and request.db:
company_id = request.env.user.company_id.id
company = self.env['res.company'].browse(company_id)
else: