I have a field that is related to a translate = True, but when value changes from a form, it only changes the translated term. Old term is being keep on DB.
Let’s say we have this model A:
class Main(models.Model):
name = fields.Char(translate=True)
class Child(models.Model):
parent_id = fields.Many2one('main')
parent_name = fields.Char(related='parent_id.name')
When a record is created, lets say that child have this value on DB.
select parent_id, parent_name from child;
1 | {‘en_GB’: ‘foo’, ‘es_ES’: ‘foo’}
Now supposed an spanish user, changes it to bar.
select parent_id, parent_name from child;
1 | {‘en_GB’: ‘foo’, ‘es_ES’: ‘bar’}
When a english user see the record, it gets foo. But spanish user was OK. So changes on DB only updating the term from the frontend instead of syncronization with the comodel.
I debugged the code but value is getting from is the translated term from the frontend (‘bar’).
PSQL line is
UPDATE "child" SET "parent_name" = '{"en_GB": "bar"}' || COALESCE("lead_crm_stage_name", '{}'::jsonb) || '{"es_ES": "bar"}'
but that COALESCE sentence is preventing old value to be overriding