[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
parent
b830a23a64
commit
577fc45a8b
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue