Skip to content
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] account_chart_update: Translatable fields without transla… #2002

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you mean this?

Suggested change
old_value = stored_translation_rec.get(rec.env.lang, "en_US")
old_value = stored_translation_rec.get(rec.env.lang or "en_US") or ""

if old_value.startswith("<p>") and old_value.endswith("</p>"):
old_value = old_value[3:-4]
is_callable = callable(field.translate)
Expand Down
Loading