diff --git a/l10n_it_account/__init__.py b/l10n_it_account/__init__.py index d3972593f3e9..0a0612ae8e4d 100644 --- a/l10n_it_account/__init__.py +++ b/l10n_it_account/__init__.py @@ -1,6 +1,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models +from . import wizards from . import tools from odoo import api, SUPERUSER_ID @@ -8,3 +9,7 @@ def _l10n_it_account_post_init(cr, registry): env = api.Environment(cr, SUPERUSER_ID, {}) env["account.account"].set_account_types_negative_sign() + + lang = env["res.lang"] + if lang._lang_get("it_IT"): + lang.update_menu_finance_it_translation() diff --git a/l10n_it_account/models/__init__.py b/l10n_it_account/models/__init__.py index da692602393b..46df1f7f948d 100644 --- a/l10n_it_account/models/__init__.py +++ b/l10n_it_account/models/__init__.py @@ -3,3 +3,4 @@ from . import account_account from . import account_group from . import account_tax +from . import res_lang diff --git a/l10n_it_account/models/res_lang.py b/l10n_it_account/models/res_lang.py new file mode 100644 index 000000000000..d535c74628f1 --- /dev/null +++ b/l10n_it_account/models/res_lang.py @@ -0,0 +1,35 @@ +# Copyright 2024 Sergio Zanchetta (PNLUG APS - Gruppo Odoo) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class Lang(models.Model): + _inherit = "res.lang" + + def toggle_active(self): + res = super().toggle_active() + + if "it_IT" in [lang.code for lang in self.filtered(lambda L: L.active)]: + self.update_menu_finance_it_translation() + + return res + + def update_menu_finance_it_translation(self): + """In Odoo the inheritance mechanism is not yet implemented for menus. + Changing a menu item name doesn't create a new string to be translated + but overwrites the source string of the original module to which the menu + belongs to. This is a workaround that allows the translated string to be + modified in the same way. + """ + menu_finance_id = self.env["ir.model.data"]._xmlid_to_res_id( + "account.menu_finance" + ) + menu_finance = self.env["ir.ui.menu"].browse(menu_finance_id) + + field_name = menu_finance._fields["name"] + translations = field_name._get_stored_translations(menu_finance) + + translations["it_IT"] = "Contabilità" + self.env.cache.update_raw(menu_finance, field_name, [translations], dirty=True) + self.modified(["name"]) diff --git a/l10n_it_account/views/account_menuitem.xml b/l10n_it_account/views/account_menuitem.xml index ebbe83a870b6..4b98a4a3d4af 100644 --- a/l10n_it_account/views/account_menuitem.xml +++ b/l10n_it_account/views/account_menuitem.xml @@ -3,12 +3,13 @@ Copyright 2022 Alex Comba - Agile Business Group License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> + Accounting -