Skip to content

Commit

Permalink
Merge pull request OCA#388 from SonCrits/merge_upstream_1
Browse files Browse the repository at this point in the history
Merge upstream 16 230710 01
  • Loading branch information
royle-vietnam authored Jul 13, 2023
2 parents 215dd08 + 146ea7f commit 6756d94
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 39 deletions.
8 changes: 4 additions & 4 deletions docsource/modules150-160.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ Module coverage 15.0 -> 16.0
+-------------------------------------------------+----------------------+-------------------------------------------------+
| google_calendar |Done | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |del| google_drive | | |
| |del| google_drive | |Obsolete module |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| google_gmail | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| google_recaptcha |Nothing to do | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |del| google_spreadsheet | | |
| |del| google_spreadsheet | |Obsolete module. |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| hr | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down Expand Up @@ -528,13 +528,13 @@ Module coverage 15.0 -> 16.0
+-------------------------------------------------+----------------------+-------------------------------------------------+
| note |Nothing to do | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |del| note_pad |Done |Merged into web_editor |
| |del| note_pad |Done |Merged into note |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |new| onboarding | | |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |del| pad |Done |Merged into web_editor |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| |del| pad_project | | |
| |del| pad_project |Done |Merged into project |
+-------------------------------------------------+----------------------+-------------------------------------------------+
| partner_autocomplete | Nothing to do |No DB layout changes. |
+-------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
3 changes: 2 additions & 1 deletion openupgrade_scripts/apriori.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
"l10n_be_edi": "account_edi_ubl_cii",
"l10n_nl_edi": "account_edi_ubl_cii",
"l10n_no_edi": "account_edi_ubl_cii",
"note_pad": "web_editor",
"note_pad": "note",
"pad": "web_editor",
"pad_project": "project",
"pos_coupon": "pos_loyalty",
"pos_gift_card": "pos_loyalty",
"sale_gift_card": "sale_loyalty",
Expand Down
80 changes: 46 additions & 34 deletions openupgrade_scripts/scripts/base/16.0.1.3/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,7 @@
_logger = logging.getLogger(__name__)


@openupgrade.migrate(use_env=False)
def migrate(cr, version):
"""
Don't request an env for the base pre-migration as flushing the env in
odoo/modules/registry.py will break on the 'base' module not yet having
been instantiated.
"""
if "openupgrade_framework" not in tools.config["server_wide_modules"]:
_logger.error(
"openupgrade_framework is not preloaded. You are highly "
"recommended to run the Odoo with --load=openupgrade_framework "
"when migrating your database."
)
openupgrade.update_module_names(cr, renamed_modules.items())
openupgrade.update_module_names(cr, merged_modules.items(), merge_modules=True)
# restricting inherited views to groups isn't allowed any more
cr.execute(
"DELETE FROM ir_ui_view_group_rel r "
"USING ir_ui_view v "
"WHERE r.view_id=v.id AND v.inherit_id IS NOT NULL AND v.mode != 'primary'"
)
# update all translatable fields
cr.execute(
"SELECT f.name, m.model FROM ir_model_fields f "
"JOIN ir_model m ON f.model_id=m.id WHERE f.translate"
)
def update_translatable_fields(cr):
# map of nonstandard table names
model2table = {
"ir.actions.actions": "ir_actions",
Expand All @@ -59,6 +34,10 @@ def migrate(cr, version):
"ir.actions.client": ["name"],
"ir.actions.report": ["name"],
}
cr.execute(
"SELECT f.name, m.model FROM ir_model_fields f "
"JOIN ir_model m ON f.model_id=m.id WHERE f.translate"
)
for field, model in cr.fetchall():
if field in exclusions.get(model, []):
continue
Expand All @@ -83,20 +62,53 @@ def migrate(cr, version):
cr,
"""
WITH t AS (
SELECT res_id, jsonb_object_agg(lang, value) AS value
FROM ir_translation
WHERE type = 'model' AND name = %(name)s AND state = 'translated'
GROUP BY res_id
SELECT it.res_id as res_id, jsonb_object_agg(it.lang, it.value) AS value,
bool_or(imd.noupdate) AS noupdate
FROM ir_translation it
LEFT JOIN ir_model_data imd ON imd.model = %(model)s AND imd.res_id = it.res_id
WHERE it.type = 'model' AND it.name = %(name)s AND it.state = 'translated'
GROUP BY it.res_id
)
UPDATE "%(table)s" m
SET "%(field_name)s" = t.value || m."%(field_name)s"
FROM t
WHERE t.res_id = m.id
SET "%(field_name)s" = CASE WHEN t.noupdate THEN m.%(field_name)s || t.value
ELSE t.value || m.%(field_name)s END
FROM t
WHERE t.res_id = m.id
""",
{"table": AsIs(table), "name": translation_name, "field_name": AsIs(field)},
{
"table": AsIs(table),
"model": model,
"name": translation_name,
"field_name": AsIs(field),
},
)
openupgrade.logged_query(
cr,
"DELETE FROM ir_translation WHERE type = 'model' AND name = %s",
[translation_name],
)


@openupgrade.migrate(use_env=False)
def migrate(cr, version):
"""
Don't request an env for the base pre-migration as flushing the env in
odoo/modules/registry.py will break on the 'base' module not yet having
been instantiated.
"""
if "openupgrade_framework" not in tools.config["server_wide_modules"]:
_logger.error(
"openupgrade_framework is not preloaded. You are highly "
"recommended to run the Odoo with --load=openupgrade_framework "
"when migrating your database."
)
openupgrade.update_module_names(cr, renamed_modules.items())
openupgrade.update_module_names(cr, merged_modules.items(), merge_modules=True)
# restricting inherited views to groups isn't allowed any more
cr.execute(
"DELETE FROM ir_ui_view_group_rel r "
"USING ir_ui_view v "
"WHERE r.view_id=v.id AND v.inherit_id IS NOT NULL AND v.mode != 'primary'"
)
# update all translatable fields
update_translatable_fields(cr)

0 comments on commit 6756d94

Please sign in to comment.