[FIX] base: Allow to get default with auth=none

Since dae065d, model defaults are retrieved based on the env company instead of
the user's company.

However, for a request with auth='none', the company might not be set on the
environnement (if `allowed_company_ids` is not in the context).
This makes the sql query crash, trying to compare an integer to `false`.

closes odoo/odoo#42951

X-original-commit: fa47b1b23a7fa09166c16aacf025cdcefcfaa9fd
Signed-off-by: lul-odoo <LucasLefevre@users.noreply.github.com>
This commit is contained in:
Lucas Lefèvre
2020-01-08 14:09:58 +00:00
parent d3171f2474
commit 04bd54d0bc
+2 -1
View File
@@ -135,7 +135,8 @@ class IrDefault(models.Model):
AND {}
ORDER BY d.user_id, d.company_id, d.id
"""
params = [model_name, self.env.uid, self.env.company.id]
# self.env.company is empty when there is no user (controllers with auth=None)
params = [model_name, self.env.uid, self.env.company.id or None]
if condition:
query = query.format("d.condition=%s")
params.append(condition)