diff --git a/l10n_it_riba/README.rst b/l10n_it_riba/README.rst index ea5b7f5d322..2576d872af8 100644 --- a/l10n_it_riba/README.rst +++ b/l10n_it_riba/README.rst @@ -120,14 +120,6 @@ in due momenti: registrazione dalla vista ed elenco ed eseguendo l'azione "Imposta data di pagamento RiBa". -Known issues / Roadmap -====================== - -**Italiano** - -Attenzione! Il modulo è stato migrato, ma gli script di migrazione non -sono stati provati. - Bug Tracker =========== diff --git a/l10n_it_riba/__init__.py b/l10n_it_riba/__init__.py index 9dd2c17785b..a020c448d19 100644 --- a/l10n_it_riba/__init__.py +++ b/l10n_it_riba/__init__.py @@ -6,3 +6,4 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models, wizard, report +from .hooks import pre_absorb_old_module diff --git a/l10n_it_riba/__manifest__.py b/l10n_it_riba/__manifest__.py index a67c3f94aa2..463d14b8fc4 100644 --- a/l10n_it_riba/__manifest__.py +++ b/l10n_it_riba/__manifest__.py @@ -47,5 +47,11 @@ "wizard/wizard_riba_multiple_payment_views.xml", ], "demo": ["demo/riba_demo.xml"], + "external_dependencies": { + "python": [ + "openupgradelib", + ], + }, + "pre_init_hook": "pre_absorb_old_module", "installable": True, } diff --git a/l10n_it_riba/hooks.py b/l10n_it_riba/hooks.py new file mode 100644 index 00000000000..7959018910a --- /dev/null +++ b/l10n_it_riba/hooks.py @@ -0,0 +1,312 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + +from odoo.tools import DotDict + +OLD_MODULE_NAME = "l10n_it_ricevute_bancarie" +NEW_MODULE_NAME = "l10n_it_riba" +RENAMED_MODELS = [ + ("riba.distinta", "riba.slip"), + ("riba.distinta.line", "riba.slip.line"), + ("riba.distinta.move.line", "riba.slip.move.line"), + ( + "report.l10n_it_ricevute_bancarie.distinta_qweb", + "report.l10n_it_riba.slip_qweb", + ), # abstract + ("riba.accreditation", "riba.credit"), + ("riba.unsolved", "riba.past_due"), +] +RENAMED_TABLES = [ + ("riba_distinta", "riba_slip"), + ("riba_distinta_line", "riba_slip_line"), + ("riba_distinta_move_line", "riba_slip_move_line"), + ("riba_accreditation", "riba_credit"), + ("riba_unsolved", "riba_past_due"), +] +RENAMED_FIELDS = [ + [ + ( + "account.move", + "riba_credited_ids", + ), + ( + "account.move", + "riba_accredited_ids", + ), + ], + [ + ( + "account.move", + "riba_unsolved_ids", + ), + ( + "account.move", + "riba_past_due_ids", + ), + ], + [ + ( + "account.move", + "unsolved_move_line_ids", # is m2m, with table invoice_unsolved_line_rel + ), + ( + "account.move", + "past_due_move_line_ids", # is m2m, with table invoice_past_due_line_rel + ), + ], + [ + ( + "account.move", + "is_unsolved", + ), + ( + "account.move", + "is_past_due", + ), + ], + [ + ( + "account.move.line", + "distinta_line_ids", + ), + ( + "account.move.line", + "slip_line_ids", + ), + ], + [ + ( + "account.move.line", + "unsolved_invoice_ids", # is m2m with table invoice_unsolved_line_rel + ), + ( + "account.move.line", + "past_due_invoice_ids", # is m2m with table invoice_past_due_line_rel + ), + ], + [ + ( + "riba.distinta", + "date_accreditation", + ), + ( + "riba.slip", + "date_credited", + ), + ], + [ + ( + "riba.distinta", + "date_unsolved", + ), + ( + "riba.slip", + "date_past_due", + ), + ], + [ + ( + "riba.distinta", + "accreditation_move_id", + ), + ( + "riba.slip", + "credit_move_id", + ), + ], + [ + ( + "riba.distinta", + "unsolved_move_ids", # is m2m table name computed + ), + ( + "riba.slip", + "past_due_move_ids", # is m2m table name computed + ), + ], + [ + ( + "riba.distinta.line", + "unsolved_move_id", + ), + ( + "riba.slip.line", + "past_due_move_id", + ), + ], + [ + ( + "riba.distinta.line", + "distinta_id", + ), + ( + "riba.slip.line", + "slip_id", + ), + ], + [ + ( + "riba.configuration", + "accreditation_journal_id", + ), + ( + "riba.configuration", + "credit_journal_id", + ), + ], + [ + ( + "riba.configuration", + "accreditation_account_id", + ), + ( + "riba.configuration", + "credit_account_id", + ), + ], + [ + ( + "riba.configuration", + "unsolved_journal_id", + ), + ( + "riba.configuration", + "past_due_journal_id", + ), + ], + [ + ( + "riba.accreditation", + "accreditation_journal_id", + ), + ( + "riba.credit", + "credit_journal_id", + ), + ], + [ + ( + "riba.accreditation", + "accreditation_account_id", + ), + ( + "riba.credit", + "credit_account_id", + ), + ], + [ + ( + "riba.accreditation", + "accreditation_amount", + ), + ( + "riba.credit", + "credit_amount", + ), + ], + [ + ( + "riba.unsolved", + "unsolved_journal_id", + ), + ( + "riba.past_due", + "past_due_journal_id", + ), + ], +] +RENAMED_XMLIDS = [ + ("seq_riba_distinta", "seq_riba_slip"), + ("print_distinta_qweb", "print_slip_qweb"), + ("access_riba_distinta_uinvoice", "access_riba_slip_uinvoice"), + ("access_riba_distinta_group_invoice", "access_riba_slip_group_invoice"), + ("access_riba_distinta_user", "access_riba_slip_user"), + ("access_riba_distinta_accountant", "access_riba_slip_accountant"), + ("access_riba_distinta_line_uinvoice", "access_riba_slip_line_uinvoice"), + ("access_riba_distinta_line_group_invoice", "access_riba_slip_line_group_invoice"), + ("access_riba_distinta_line_user", "access_riba_slip_line_user"), + ("access_riba_distinta_line_accountant", "access_riba_slip_line_accountant"), + ("access_riba_distinta_move_line_uinvoice", "access_riba_slip_move_line_uinvoice"), + ( + "access_riba_distinta_move_line_group_invoice", + "access_riba_slip_move_line_group_invoice", + ), + ("access_riba_distinta_move_line_user", "access_riba_slip_move_line_user"), + ( + "access_riba_distinta_move_line_accountant", + "access_riba_slip_move_line_accountant", + ), + ("access_riba_unsolved", "access_riba_past_due"), + ("access_riba_accreditation", "access_riba_credit"), + ("riba_distinta_company_rule", "riba_slip_company_rule"), + ("riba_distinta_line_company_rule", "riba_slip_line_company_rule"), + ("view_riba_da_emettere_tree", "view_riba_to_issue_tree"), + ("action_riba_da_emettere", "action_riba_to_issue"), + ("menu_riba_da_emettere", "menu_riba_to_issue"), + ("view_distinta_riba_filtri", "view_slip_riba_filter"), + ("view_distinta_riba_tree", "view_slip_riba_tree"), + ("view_riba_distinta_line_form", "view_riba_slip_line_form"), + ("distinta_riba_action", "slip_riba_action"), + ("distinta_layout", "slip_layout"), + ("distinta_qweb", "slip_qweb"), + ("riba_accreditation", "riba_credit"), + ("riba_accreditation_action", "riba_credit_action"), + ("riba_unsolved", "riba_past_due"), + ("riba_unsolved_action", "riba_past_due_action"), +] + + +def migrate_old_module(cr): + openupgrade.rename_models( + cr, + RENAMED_MODELS, + ) + openupgrade.rename_tables( + cr, + RENAMED_TABLES, + ) + field_spec = [] + for renamed_field in RENAMED_FIELDS: + (old_model, old_field), (new_model, new_field) = renamed_field + field_spec.append( + ( + old_model, + new_model.replace(".", "_"), + old_field, + new_field, + ) + ) + openupgrade.rename_fields( + # The method only needs the cursor, not the whole Environment + DotDict( + cr=cr, + ), + field_spec, + # Prevent Environment usage + # whenever it will be implemented. + no_deep=True, + ) + full_renamed_xmlids = [ + ( + ".".join((OLD_MODULE_NAME, old_xmlid)), + ".".join((NEW_MODULE_NAME, new_xmlid)), + ) + for old_xmlid, new_xmlid in RENAMED_XMLIDS + ] + openupgrade.rename_xmlids( + cr, + full_renamed_xmlids, + ) + + +def pre_absorb_old_module(cr): + if openupgrade.is_module_installed(cr, "l10n_it_ricevute_bancarie"): + openupgrade.update_module_names( + cr, + [ + ("l10n_it_ricevute_bancarie", "l10n_it_riba"), + ], + merge_modules=True, + ) + migrate_old_module(cr) diff --git a/l10n_it_riba/migrations/16.0.1.0.0/post-migrate.py b/l10n_it_riba/migrations/16.0.1.0.0/post-migrate.py index 5358d910b9a..4565c60ba5d 100644 --- a/l10n_it_riba/migrations/16.0.1.0.0/post-migrate.py +++ b/l10n_it_riba/migrations/16.0.1.0.0/post-migrate.py @@ -1,4 +1,5 @@ # Copyright 2023 Simone Rubino - AionTech +# Copyright 2024 Nextev Srl # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from openupgradelib import openupgrade @@ -13,4 +14,33 @@ def migrate(env, version): NEW_MODULE_NAME, "migrations/16.0.1.0.0/data/noupdate.xml", ) - # TODO selection keys of riba.distinta[.line].state have changed + + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("state"), + "state", + [ + ("draft", "draft"), + ("confirmed", "confirmed"), + ("accredited", "credited"), + ("paid", "paid"), + ("unsolved", "past_due"), + ("cancel", "cancel"), + ], + table="riba_slip_line", + ) + + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("state"), + "state", + [ + ("draft", "draft"), + ("accepted", "accepted"), + ("accredited", "credited"), + ("paid", "paid"), + ("unsolved", "past_due"), + ("cancel", "cancel"), + ], + table="riba_slip", + ) diff --git a/l10n_it_riba/migrations/16.0.1.0.0/pre-migrate.py b/l10n_it_riba/migrations/16.0.1.0.0/pre-migrate.py index 255887b1b36..d41e5b37131 100644 --- a/l10n_it_riba/migrations/16.0.1.0.0/pre-migrate.py +++ b/l10n_it_riba/migrations/16.0.1.0.0/pre-migrate.py @@ -1,284 +1,29 @@ # Copyright 2023 Simone Rubino - AionTech +# Copyright 2024 Nextev Srl # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from openupgradelib import openupgrade -OLD_MODULE_NAME = "l10n_it_ricevute_bancarie" -NEW_MODULE_NAME = "l10n_it_riba" -RENAMED_MODELS = [ - ("riba.distinta", "riba.slip"), - ("riba.distinta.line", "riba.slip.line"), - ("riba.distinta.move.line", "riba.slip.move.line"), - ( - "report.l10n_it_ricevute_bancarie.distinta_qweb", - "report.l10n_it_riba.slip_qweb", - ), # abstract - ("riba.accreditation", "riba.credit"), - ("riba.unsolved", "riba.past_due"), -] -RENAMED_FIELDS = [ - [ - ( - "account.move", - "riba_credited_ids", - ), - ( - "account.move", - "riba_accredited_ids", - ), - ], - [ - ( - "account.move", - "riba_unsolved_ids", - ), - ( - "account.move", - "riba_past_due_ids", - ), - ], - [ - ( - "account.move", - "unsolved_move_line_ids", # is m2m, with table invoice_unsolved_line_rel - ), - ( - "account.move", - "past_due_move_line_ids", # is m2m, with table invoice_past_due_line_rel - ), - ], - [ - ( - "account.move", - "is_unsolved", - ), - ( - "account.move", - "is_past_due", - ), - ], - [ - ( - "account.move.line", - "distinta_line_ids", - ), - ( - "account.move.line", - "slip_line_ids", - ), - ], - [ - ( - "account.move.line", - "unsolved_invoice_ids", # is m2m with table invoice_unsolved_line_rel - ), - ( - "account.move.line", - "past_due_invoice_ids", # is m2m with table invoice_past_due_line_rel - ), - ], - [ - ( - "riba.distinta", - "date_accreditation", - ), - ( - "riba.slip", - "date_credited", - ), - ], - [ - ( - "riba.distinta", - "date_unsolved", - ), - ( - "riba.slip", - "date_past_due", - ), - ], - [ - ( - "riba.distinta", - "accreditation_move_id", - ), - ( - "riba.slip", - "credit_move_id", - ), - ], - [ - ( - "riba.distinta", - "unsolved_move_ids", # is m2m table name computed - ), - ( - "riba.slip", - "past_due_move_ids", # is m2m table name computed - ), - ], - [ - ( - "riba.distinta.line", - "unsolved_move_id", - ), - ( - "riba.slip.line", - "past_due_move_id", - ), - ], - [ - ( - "riba.distinta.line", - "distinta_id", - ), - ( - "riba.slip.line", - "slip_id", - ), - ], - [ - ( - "riba.configuration", - "accreditation_journal_id", - ), - ( - "riba.configuration", - "credit_journal_id", - ), - ], - [ - ( - "riba.configuration", - "accreditation_account_id", - ), - ( - "riba.configuration", - "credit_account_id", - ), - ], - [ - ( - "riba.configuration", - "unsolved_journal_id", - ), - ( - "riba.configuration", - "past_due_journal_id", - ), - ], - [ - ( - "riba.accreditation", - "accreditation_journal_id", - ), - ( - "riba.credit", - "credit_journal_id", - ), - ], - [ - ( - "riba.accreditation", - "accreditation_account_id", - ), - ( - "riba.credit", - "credit_account_id", - ), - ], - [ - ( - "riba.accreditation", - "accreditation_amount", - ), - ( - "riba.credit", - "credit_amount", - ), - ], - [ - ( - "riba.unsolved", - "unsolved_journal_id", - ), - ( - "riba.past_due", - "past_due_journal_id", - ), - ], -] -RENAMED_XMLIDS = [ - ("seq_riba_distinta", "seq_riba_slip"), - ("print_distinta_qweb", "print_slip_qweb"), - ("access_riba_distinta_uinvoice", "access_riba_slip_uinvoice"), - ("access_riba_distinta_group_invoice", "access_riba_slip_group_invoice"), - ("access_riba_distinta_user", "access_riba_slip_user"), - ("access_riba_distinta_accountant", "access_riba_slip_accountant"), - ("access_riba_distinta_line_uinvoice", "access_riba_slip_line_uinvoice"), - ("access_riba_distinta_line_group_invoice", "access_riba_slip_line_group_invoice"), - ("access_riba_distinta_line_user", "access_riba_slip_line_user"), - ("access_riba_distinta_line_accountant", "access_riba_slip_line_accountant"), - ("access_riba_distinta_move_line_uinvoice", "access_riba_slip_move_line_uinvoice"), - ( - "access_riba_distinta_move_line_group_invoice", - "access_riba_slip_move_line_group_invoice", - ), - ("access_riba_distinta_move_line_user", "access_riba_slip_move_line_user"), - ( - "access_riba_distinta_move_line_accountant", - "access_riba_slip_move_line_accountant", - ), - ("access_riba_unsolved", "access_riba_past_due"), - ("access_riba_accreditation", "access_riba_credit"), - ("riba_distinta_company_rule", "riba_slip_company_rule"), - ("riba_distinta_line_company_rule", "riba_slip_line_company_rule"), - ("view_riba_da_emettere_tree", "view_riba_to_issue_tree"), - ("action_riba_da_emettere", "action_riba_to_issue"), - ("menu_riba_da_emettere", "menu_riba_to_issue"), - ("view_distinta_riba_filtri", "view_slip_riba_filter"), - ("view_distinta_riba_tree", "view_slip_riba_tree"), - ("view_riba_distinta_line_form", "view_riba_slip_line_form"), - ("distinta_riba_action", "slip_riba_action"), - ("distinta_layout", "slip_layout"), - ("distinta_qweb", "slip_qweb"), - ("riba_accreditation", "riba_credit"), - ("riba_accreditation_action", "riba_credit_action"), - ("riba_unsolved", "riba_past_due"), - ("riba_unsolved_action", "riba_past_due_action"), -] +# pylint: disable=odoo-addons-relative-import +# because +# from ... import hooks +# raises +# ImportError: attempted relative import with no known parent package +from odoo.addons.l10n_it_riba import hooks -@openupgrade.migrate() -def migrate(env, version): - openupgrade.rename_models( - env.cr, - RENAMED_MODELS, +def migrate(cr, installed_version): + # copy old riba.distinta.line.state refs + openupgrade.copy_columns( + cr, + {"riba_distinta_line": [("state", None, None)]}, ) - field_spec = [] - for renamed_field in RENAMED_FIELDS: - (old_model, old_field), (new_model, new_field) = renamed_field - field_spec.append( - ( - old_model, - old_model.replace(".", "_"), - old_field, - new_field, - ) - ) - openupgrade.rename_fields( - env, - field_spec, + # copy old riba.distinta.state refs + openupgrade.copy_columns( + cr, + {"riba_distinta": [("state", None, None)]}, ) - openupgrade.rename_xmlids( - env.cr, - [ - ( - ".".join((OLD_MODULE_NAME, old_xml_id)), - ".".join((NEW_MODULE_NAME, new_xml_id)), - ) - for old_xml_id, new_xml_id in RENAMED_XMLIDS - ], - ) + # Used by OpenUpgrade when module is in `apriori` + hooks.migrate_old_module(cr) diff --git a/l10n_it_riba/readme/ROADMAP.md b/l10n_it_riba/readme/ROADMAP.md deleted file mode 100644 index 6134113a526..00000000000 --- a/l10n_it_riba/readme/ROADMAP.md +++ /dev/null @@ -1,4 +0,0 @@ -**Italiano** - -Attenzione! Il modulo è stato migrato, ma gli script di migrazione non -sono stati provati. diff --git a/l10n_it_riba/static/description/index.html b/l10n_it_riba/static/description/index.html index fa83d24cf7f..3e1692ff78e 100644 --- a/l10n_it_riba/static/description/index.html +++ b/l10n_it_riba/static/description/index.html @@ -8,11 +8,10 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ +:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. -Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +274,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: gray; } /* line numbers */ +pre.code .ln { color: grey; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +300,7 @@ span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle { @@ -377,11 +376,10 @@

ITA - Ricevute bancarie

-
-

Known issues / Roadmap

-

Italiano

-

Attenzione! Il modulo è stato migrato, ma gli script di migrazione non -sono stati provati.

-
-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed @@ -473,9 +465,9 @@

Bug Tracker

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

- -Odoo Community Association - +Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.