From 37fa21a2af7c118ceb3c875b6f09c68292a6727e Mon Sep 17 00:00:00 2001 From: Toufik Ben Jaa Date: Wed, 12 Dec 2018 15:16:48 +0100 Subject: [PATCH] [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. --- addons/account/models/chart_template.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 317f98e99bf..85839660413 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -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: