From edf431a4a18b93df046178243e674d82d3cc0cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20L=C3=B3pez=20Pe=C3=B1alver?= Date: Thu, 7 Nov 2024 10:10:53 +0100 Subject: [PATCH] [FIX] account_chart_update_multilang: hide default language in wizard and ditch decorators as mentioned in code review --- account_chart_update/wizard/wizard_chart_update.py | 2 -- account_chart_update_multilang/__manifest__.py | 3 +++ .../static/description/index.html | 11 ++++------- .../wizards/wizard_chart_update.py | 12 +++++++----- .../wizards/wizard_chart_update_views.xml | 14 ++++++++++++++ 5 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 account_chart_update_multilang/wizards/wizard_chart_update_views.xml diff --git a/account_chart_update/wizard/wizard_chart_update.py b/account_chart_update/wizard/wizard_chart_update.py index f17a2c5f0..6d3949247 100644 --- a/account_chart_update/wizard/wizard_chart_update.py +++ b/account_chart_update/wizard/wizard_chart_update.py @@ -783,8 +783,6 @@ class WizardUpdateChartsAccounts(models.TransientModel): } | specials_mapping.get(name, set()) return set(models.MAGIC_COLUMNS) | specials - @api.model - @tools.ormcache("name") def fields_to_include(self, name): """Get fields that will be used when checking differences. diff --git a/account_chart_update_multilang/__manifest__.py b/account_chart_update_multilang/__manifest__.py index fa43ac9f5..2ad978299 100644 --- a/account_chart_update_multilang/__manifest__.py +++ b/account_chart_update_multilang/__manifest__.py @@ -17,4 +17,7 @@ "account_chart_update", "l10n_multilang", ], + "data": [ + "wizards/wizard_chart_update_views.xml", + ], } diff --git a/account_chart_update_multilang/static/description/index.html b/account_chart_update_multilang/static/description/index.html index a5a8b9be5..d3bcbe7b8 100644 --- a/account_chart_update_multilang/static/description/index.html +++ b/account_chart_update_multilang/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 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code { 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.option { span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle { @@ -435,9 +434,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

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.

diff --git a/account_chart_update_multilang/wizards/wizard_chart_update.py b/account_chart_update_multilang/wizards/wizard_chart_update.py index 697756fca..c26ab4942 100644 --- a/account_chart_update_multilang/wizards/wizard_chart_update.py +++ b/account_chart_update_multilang/wizards/wizard_chart_update.py @@ -24,7 +24,9 @@ class WizardUpdateChartsAccount(models.TransientModel): template = self.env.ref(tpl_xmlid) module, xmlid = tpl_xmlid.split(".", 1) rec_xmlid = f"{module}.{self.company_id.id}_{xmlid}" - rec = self.env.ref(rec_xmlid) + rec = self.env.ref(rec_xmlid, False) + if not rec: + continue translations = {} for key in self._diff_translate_fields(template, rec): for lang in self._other_langs(): @@ -45,12 +47,12 @@ class WizardUpdateChartsAccount(models.TransientModel): """Find differences by comparing the translations of the fields.""" res = {} to_include = self.fields_to_include(template._name) - for key in template._fields: - if not template._fields[key].translate or key not in to_include: + for key in to_include: + if not (template._fields.get(key) and template._fields[key].translate): continue for lang in self._other_langs(): - template_trans = getattr(template.with_context(lang=lang), key) - real_trans = getattr(real.with_context(lang=lang), key) + template_trans = template.with_context(lang=lang)[key] + real_trans = real.with_context(lang=lang)[key] if template_trans != real_trans: res[key] = template[key] return res diff --git a/account_chart_update_multilang/wizards/wizard_chart_update_views.xml b/account_chart_update_multilang/wizards/wizard_chart_update_views.xml new file mode 100644 index 000000000..5f22a2ae7 --- /dev/null +++ b/account_chart_update_multilang/wizards/wizard_chart_update_views.xml @@ -0,0 +1,14 @@ + + + + + wizard.update.charts.accounts + + + + 1 + + + + +