Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions l10n_it_riba_oca/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from openupgradelib import openupgrade

from odoo import api

OLD_MODULE_NAME = "l10n_it_ricevute_bancarie"
NEW_MODULE_NAME = "l10n_it_riba"

Expand All @@ -15,3 +17,13 @@ def pre_absorb_old_module(env):
],
merge_modules=True,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non riguarda le modifiche di questa PR, ma ho notato che qui si usa merge_modules=True, mentre in https://github.com/OCA/OpenUpgrade/blob/82572397744b96c1a1ad706d8a911abc90ee4dea/openupgrade_scripts/apriori.py#L25 il modulo è elencato tra i moduli da rinominare, puoi verificare se serve davvero usare merge_modules oppure no?
Se serve, allora il modulo va spostato nella lista dei moduli da mergiare; altrimenti va tolto da qui.

Così la migrazione tramite OpenUpgrade e l'hook di init fanno le stesse operazioni.

)


def migrate_old_module(cr):
"""Migration wrapper to absorb old l10n_it_riba module into l10n_it_riba_oca.

Called from pre-migration script with cursor-only access.
Creates an env from cr and delegates to pre_absorb_old_module.
"""
env = api.Environment(cr, 1, {}) # uid=1 (admin), empty context
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L'utente con ID 1 non è admin ma Odoobot

pre_absorb_old_module(env)
2 changes: 1 addition & 1 deletion l10n_it_riba_oca/migrations/18.0.1.0.0/pre-migrate.py
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se l'unica cosa da fare nella migrazione è rinominare il modulo, probabilmente non serve nemmeno questo file perché la rinomina viene già eseguita in https://github.com/OCA/OpenUpgrade/blob/82572397744b96c1a1ad706d8a911abc90ee4dea/openupgrade_scripts/scripts/base/18.0.1.3/pre-migration.py#L74, puoi verificare?
Se non serve meglio rimuoverlo e lasciamo solo l'hook pre_absorb_old_module.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
from odoo.addons.l10n_it_riba_oca import hooks


def migrate(cr, installed_version):
def migrate(cr, version):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se questo non serve meglio toglierlo, così in questo commit ci sono solo le modifiche necessarie

# Used by OpenUpgrade when module is in `apriori`
hooks.migrate_old_module(cr)
Comment on lines 11 to 16
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possiamo invece usare openupgradelib e chiamare direttamente pre_absorb_old_module?
Così è analogo a come viene fatto negli altri moduli del repository, vedi ad esempio:

from openupgradelib import openupgrade
from odoo.addons.l10n_it_account_vat_period_end_settlement import hooks
@openupgrade.migrate()
def migrate(env, version):
# Used by OpenUpgrade when module is in `apriori`
hooks.pre_absorb_old_module(env)