2

when adding

name = fields.Char(translate=True,)
company_name = fields.Char(translate=True)
display_name = fields.Char(translate=True)

to the res.partner then go to trying to open the reconciliation action i am geting

TypeError: (this.m2o_value||"").trim is not a function. (In '(this.m2o_value||"").trim()', '(this.m2o_value||"").trim' is undefined)

is was working in odoo 14 but when i upgraded to 16 is gave me this error.

can you help me with the js part i don't really unstained the error

i tried removing translate=True on the name and company name and the reconciliation works

Moaz Mabrok
  • 697
  • 10
  • 32

1 Answers1

3

It's me again

After been able to test and debug your issue locally I endup with this solution that you need to include in you module

class AccountReconciliation(models.AbstractModel):
    _inherit = 'account.reconciliation.widget'

    @api.model
    def get_all_data_for_manual_reconciliation(self, partner_ids, account_ids):
        res = super(AccountReconciliation, self).get_all_data_for_manual_reconciliation(partner_ids, account_ids)
        for partner_data in res.get('customers', []):
            if isinstance(partner_data.get('partner_name'), dict):
                partner_data['partner_name'] = partner_data['partner_name'].get(self.env.context['lang'], 'en_US')
        return res

The reason it's that after you change res.partner name field to be translate=True and get that change applied into the database that will cause the field column to be of type JSONB so any select to that field using direct SQL will get a JSON Object which is what happens in get_all_data_for_manual_reconciliation of account.reconciliation.widget model so I manually check that and properly select the value related to the current user lang stored in the Enviroment Context

Hope that you could solve your issue with this change. I have tested and it's working on my localhost

aekis.dev
  • 2,626
  • 1
  • 12
  • 19