-
-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][FIX] accounting menu not translatable #4298
Open
primes2h
wants to merge
1
commit into
OCA:16.0
Choose a base branch
from
primes2h:16.0-fix-accounting-menu
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
# 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 | ||
|
||
|
||
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() | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
from . import account_account | ||
from . import account_group | ||
from . import account_tax | ||
from . import res_lang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Le modifiche a questo file si possono rimuovere? Sono solo di formattazione e non servono allo scopo del commit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import base_language_install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 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 = self.env["res.lang"] | ||
|
||
if "it_IT" in self.lang_ids.mapped("code"): | ||
lang.update_menu_finance_it_translation() | ||
|
||
return res | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Questo serviva quando
self
era un menu, giusto? Se è così ora si dovrebbe poter rimuovere.