[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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user