diff --git a/l10n_it_account/models/__init__.py b/l10n_it_account/models/__init__.py index da692602393b..9ee9b058738d 100644 --- a/l10n_it_account/models/__init__.py +++ b/l10n_it_account/models/__init__.py @@ -3,3 +3,5 @@ from . import account_account from . import account_group from . import account_tax +from . import ir_ui_menu +from . import base_language_install diff --git a/l10n_it_account/models/base_language_install.py b/l10n_it_account/models/base_language_install.py new file mode 100644 index 000000000000..8a65569b36b3 --- /dev/null +++ b/l10n_it_account/models/base_language_install.py @@ -0,0 +1,23 @@ +# 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 BaseLanguageInstall(models.TransientModel): + _inherit = "base.language.install" + + def lang_install(self): + res = super().lang_install() + + lang_code = self.first_lang_id.code + + if lang_code == "it_IT": + 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) + + menu_finance.update_it_translation() + + return res diff --git a/l10n_it_account/models/ir_ui_menu.py b/l10n_it_account/models/ir_ui_menu.py new file mode 100644 index 000000000000..e1fc55bf522d --- /dev/null +++ b/l10n_it_account/models/ir_ui_menu.py @@ -0,0 +1,32 @@ +# 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 IrUiMenu(models.Model): + _inherit = "ir.ui.menu" + + def write(self, vals): + res = super().write(vals) + + lang = self.env["res.lang"].search([("code", "=", "it_IT")], limit=1) + + if lang and self == self.env.ref("account.menu_finance"): + self.update_it_translation() + + return res + + def update_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. + """ + field_name = self._fields["name"] + translations = field_name._get_stored_translations(self) + + translations["it_IT"] = "Contabilità" + self.env.cache.update_raw(self, 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..48b16c99b27a 100644 --- a/l10n_it_account/views/account_menuitem.xml +++ b/l10n_it_account/views/account_menuitem.xml @@ -3,12 +3,12 @@ Copyright 2022 Alex Comba - Agile Business Group License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - + Accounting -