From 4fa4e1faa127abe85ad0bbb22177ef94066f8bc6 Mon Sep 17 00:00:00 2001 From: mle Date: Thu, 15 Jun 2023 10:48:17 +0200 Subject: [PATCH] [FIX] account_reconcile_oca: account name can be translatable By default, account_account name is a char field. But if l10n_multilang is installed, it is translatable, hence the DB column is now a jsonb. We must handle both cases in the select query. --- .../models/account_account_reconcile.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/account_reconcile_oca/models/account_account_reconcile.py b/account_reconcile_oca/models/account_account_reconcile.py index f90a4cb9..5129f538 100644 --- a/account_reconcile_oca/models/account_account_reconcile.py +++ b/account_reconcile_oca/models/account_account_reconcile.py @@ -34,10 +34,18 @@ class AccountAccountReconcile(models.Model): ) def _select(self): - return """ + account_account_name_field = self.env["ir.model.fields"].search( + [("model", "=", "account.account"), ("name", "=", "name")] + ) + account_name = ( + f"a.name ->> '{self.env.user.lang}'" + if account_account_name_field.translate + else "a.name" + ) + return f""" SELECT min(aml.id) as id, - MAX(a.name) as name, + MAX({account_name}) as name, aml.partner_id, a.id as account_id, FALSE as is_reconciled,