Skip to content

Commit

Permalink
Merge PR #2092 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by StefanRijnhart
  • Loading branch information
OCA-git-bot committed Dec 6, 2019
2 parents b6413a2 + b57a57a commit 8187780
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions odoo/addons/base/migrations/12.0.1.3/pre-migration.py
Expand Up @@ -87,35 +87,36 @@ def switch_noupdate_flag(env):
def eliminate_duplicate_translations(cr):
# Deduplicate code translations
openupgrade.logged_query(
cr, """ DELETE FROM ir_translation WHERE id IN (
SELECT it2.id FROM ir_translation it1
JOIN ir_translation it2 ON it1.type = 'code'
AND it1.type = it2.type
AND it1.src = it2.src
AND it1.lang = it2.lang
AND it1.id < it2.id); """)
cr, """
DELETE FROM ir_translation WHERE id IN (
SELECT id FROM (
SELECT id, row_number() over (
partition BY type, src, lang ORDER BY id
) AS rnum FROM ir_translation WHERE type = 'code'
) t WHERE t.rnum > 1
)""")
# Deduplicate model translations on the same record
openupgrade.logged_query(
cr, """ DELETE FROM ir_translation WHERE id IN (
SELECT it2.id FROM ir_translation it1
JOIN ir_translation it2 ON it1.type = 'model'
AND it1.type = it2.type
AND it1.name = it2.name
AND it1.res_id = it2.res_id
AND it1.lang = it2.lang
AND it1.id < it2.id); """)
cr, """
DELETE FROM ir_translation WHERE id IN (
SELECT id FROM (
SELECT id, row_number() over (
partition BY type, name, res_id, lang ORDER BY id
) AS rnum FROM ir_translation WHERE type = 'model'
) t WHERE t.rnum > 1
)""")
# Deduplicate various
openupgrade.logged_query(
cr, """ DELETE FROM ir_translation WHERE id IN (
SELECT it2.id FROM ir_translation it1
JOIN ir_translation it2 ON it1.type IN
('selection', 'constraint', 'sql_constraint',
'view', 'field', 'help', 'xsl', 'report')
AND it1.type = it2.type
AND it1.name = it2.name
AND it1.src = it2.src
AND it1.lang = it2.lang
AND it1.id < it2.id); """)
cr, """
DELETE FROM ir_translation WHERE id IN (
SELECT id FROM (
SELECT id, row_number() over (
partition BY type, name, src, lang ORDER BY id
) AS rnum FROM ir_translation WHERE
type IN ('selection', 'constraint', 'sql_constraint',
'view', 'field', 'help', 'xsl', 'report')
) t WHERE t.rnum > 1
)""")


def fix_lang_constraints(env):
Expand Down

0 comments on commit 8187780

Please sign in to comment.