[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.
pull/630/head
mle 2023-06-15 10:48:17 +02:00 committed by Enric Tobella
parent b830a23a64
commit 577fc45a8b
1 changed files with 10 additions and 2 deletions

View File

@ -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,