Skip to content

Commit

Permalink
[16.0][FIX] account_chart_update: Translatable fields without transla…
Browse files Browse the repository at this point in the history
…tions may raise errors as its fetched by the wizard but has no translated value

@moduon MT-8280
  • Loading branch information
edlopen committed Dec 30, 2024
1 parent ed2f94a commit 7b28793
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,20 @@ def test_update_taxes_with_english_deactivate(self):
lang_model = self.env["res.lang"]
lang_model.search([("code", "=", "en_US")]).write({"active": False})
self.test_update_taxes()

def test_update_fiscal_position(self):
"""Fiscal position without translations should not be taking into
account of being translated."""
self.fp_template.note = ""
wizard = self.wizard_obj.create(self.wizard_vals)
wizard.action_find_records()
wizard.action_update_records()
new_fp = self.env["account.fiscal.position"].search(
[
("name", "=", self.fp_template.name),
("company_id", "=", self.company.id),
]
)
self.assertEqual(new_fp.with_context(lang="en_US").note, self.fp_template.note)
self.assertEqual(new_fp.with_context(lang="es_ES").note, self.fp_template.note)
self.assertEqual(new_fp.with_context(lang="fr_FR").note, self.fp_template.note)
7 changes: 4 additions & 3 deletions account_chart_update_multilang/wizards/wizard_chart_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ def _update_other_langs(self, templates):
for key in self._diff_translate_fields(template, rec):
for lang in self._other_langs():
field = rec._fields[key]
old_value = field._get_stored_translations(rec).get(
rec.env.lang, "en_US"
)
stored_translation_rec = field._get_stored_translations(rec)
if not stored_translation_rec:
continue

Check warning on line 36 in account_chart_update_multilang/wizards/wizard_chart_update.py

View check run for this annotation

Codecov / codecov/patch

account_chart_update_multilang/wizards/wizard_chart_update.py#L36

Added line #L36 was not covered by tests
old_value = stored_translation_rec.get(rec.env.lang, "en_US")
if old_value.startswith("<p>") and old_value.endswith("</p>"):
old_value = old_value[3:-4]
is_callable = callable(field.translate)
Expand Down

0 comments on commit 7b28793

Please sign in to comment.