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

[13.0][FIX] account_chart_update: avoid break where key is not in real #14

Open
wants to merge 1 commit into
base: 13-account-chart-refactor-update-taxes
Choose a base branch
from
Open
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
43 changes: 23 additions & 20 deletions account_chart_update/wizard/wizard_chart_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,26 +719,29 @@ def diff_fields(self, template, real):
expected = self.find_repartition_by_templates(
template[key], real[key], real, field.inverse_name
)
# Register detected differences
if expected is not None:
if expected != [] and (
key
in ["invoice_repartition_line_ids", "refund_repartition_line_ids"]
or expected != real[key]
):
result[key] = expected
else:
template_value = template[key]
if template._name == "account.account.template" and key == "code":
template_value = self.padded_code(template["code"])
if template_value != real[key]:
result[key] = template_value
# Avoid to cache recordset references
if key in result:
if isinstance(real._fields[key], fields.Many2many):
result[key] = [(6, 0, result[key].ids)]
elif isinstance(real._fields[key], fields.Many2one):
result[key] = result[key].id
try:
# Register detected differences
if expected is not None:
if expected != [] and (
key
in ["invoice_repartition_line_ids", "refund_repartition_line_ids"]
or expected != real[key]
):
result[key] = expected
else:
template_value = template[key]
if template._name == "account.account.template" and key == "code":
template_value = self.padded_code(template["code"])
if template_value != real[key]:
result[key] = template_value
# Avoid to cache recordset references
if key in result:
if isinstance(real._fields[key], fields.Many2many):
result[key] = [(6, 0, result[key].ids)]
elif isinstance(real._fields[key], fields.Many2one):
result[key] = result[key].id
except KeyError:
pass
return result

@api.model
Expand Down