Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] base: remove duplicated translation before update #25787

Merged

Conversation

mart-e
Copy link
Contributor

@mart-e mart-e commented Jul 16, 2018

Since 160d657, the translations must be unique on the source.
When calling insert_missing on a field, the final step is to set the correct source on every translation to keep them synchronised (UPDATE ir_translation SET src=%(src)s).

In case the translation looked like:

  id   | lang  | src | type  | res_id |       name
---------+-------+-----+-------+--------+------------------
    42 | fr_FR | KGM | model |      2 | product.uom,name
    43 | fr_FR | kg  | model |      2 | product.uom,name

The final step will fail as violating the unicity constraint.

Remove duplicated translations before making the update.

opw-1866065

@mart-e mart-e requested review from KangOl and xmo-odoo July 16, 2018 13:06
@mart-e mart-e added the OE the report is linked to a support ticket (opw-...) label Jul 16, 2018
@mart-e mart-e force-pushed the saas-11.2-remove-dup-insert-missing-trans-mat branch from 0ab49af to 1420df8 Compare July 16, 2018 13:09
@KangOl
Copy link
Contributor

KangOl commented Jul 16, 2018

Can a non-regression test be added?

@mart-e mart-e force-pushed the saas-11.2-remove-dup-insert-missing-trans-mat branch from cf5a4f9 to 4ed4d4a Compare July 16, 2018 14:05
@mart-e
Copy link
Contributor Author

mart-e commented Jul 16, 2018

@KangOl added! Also, which is better MAX or MIN? I am currently using MIN but in the scenario of my test, MAX would make more sense. Is the latest translation the more up to date or the more likely to be garbage?

@KangOl
Copy link
Contributor

KangOl commented Jul 16, 2018

Good question.

FYI, min(id) is kept during migration. Actually, during migration, src is also used to search duplicates, so not really the same situation

@mart-e mart-e force-pushed the saas-11.2-remove-dup-insert-missing-trans-mat branch 2 times, most recently from dda0b6d to 86d053b Compare July 18, 2018 13:41
Since 160d657, the translations must be unique on the source.
When calling insert_missing on a field, the final step is to set the correct
source on every translation to keep them synchronised.

In case the translation looked like:

  id   | lang  | src | type  | res_id |       name
---------+-------+-----+-------+--------+------------------
    42 | fr_FR | KGM | model |      2 | product.uom,name
    43 | fr_FR | kg  | model |      2 | product.uom,name

The final step will fail as violating the unicity constraint.

Remove duplicated translations before making the update.
It was chosen to keep the latest translation as it should be the most up to
date (e.g. after an import creating duplicated translations).

Add a non-regression test for previous change

opw-1864123
Closes odoo#25787
@mart-e mart-e force-pushed the saas-11.2-remove-dup-insert-missing-trans-mat branch from 86d053b to 2472bdb Compare July 19, 2018 07:21
@mart-e mart-e merged commit 2472bdb into odoo:saas-11.2 Jul 19, 2018
@mart-e mart-e deleted the saas-11.2-remove-dup-insert-missing-trans-mat branch July 19, 2018 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants