Skip to content

Commit

Permalink
[FIX] account_move_template: Fixed invoice_tax_id error while generat…
Browse files Browse the repository at this point in the history
…ing journal entries from template
  • Loading branch information
ppyczko committed Sep 2, 2024
1 parent e0fb9f0 commit 0618c58
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
8 changes: 2 additions & 6 deletions account_move_template/models/account_move_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ class AccountMoveTemplateLine(models.Model):
string="Payment Terms",
help="Used to compute the due date of the journal item.",
)
is_refund = fields.Boolean(
default=False,
string="Is a refund?",
)
tax_repartition_line_id = fields.Many2one(
"account.tax.repartition.line",
string="Tax Repartition Line",
Expand All @@ -179,10 +175,10 @@ class AccountMoveTemplateLine(models.Model):
help="When amount is negative, use this account instead",
)

@api.depends("is_refund", "account_id", "tax_line_id")
@api.depends("account_id", "tax_line_id")
def _compute_tax_repartition_line_id(self):
for record in self.filtered(lambda x: x.account_id and x.tax_line_id):
tax_repartition = "refund_tax_id" if record.is_refund else "invoice_tax_id"
tax_repartition = "tax_id"

Check warning on line 181 in account_move_template/models/account_move_template.py

View check run for this annotation

Codecov / codecov/patch

account_move_template/models/account_move_template.py#L181

Added line #L181 was not covered by tests
record.tax_repartition_line_id = self.env[
"account.tax.repartition.line"
].search(
Expand Down
1 change: 0 additions & 1 deletion account_move_template/view/account_move_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
/>

<field name="payment_term_id" />
<field name="is_refund" />
<field name="tax_line_id" />
<field
name="tax_repartition_line_id"
Expand Down
4 changes: 1 addition & 3 deletions account_move_template/wizard/account_move_template_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def _prepare_wizard_line(self, tmpl_line):
"analytic_distribution": tmpl_line.analytic_distribution,
"note": tmpl_line.note,
"payment_term_id": tmpl_line.payment_term_id.id or False,
"is_refund": tmpl_line.is_refund,
"tax_repartition_line_id": tmpl_line.tax_repartition_line_id.id or False,
}
return vals
Expand Down Expand Up @@ -225,7 +224,7 @@ def _prepare_move_line(self, line, amount):
}
if line.tax_ids:
values["tax_ids"] = [Command.set(line.tax_ids.ids)]
tax_repartition = "refund_tax_id" if line.is_refund else "invoice_tax_id"
tax_repartition = "tax_id"

Check warning on line 227 in account_move_template/wizard/account_move_template_run.py

View check run for this annotation

Codecov / codecov/patch

account_move_template/wizard/account_move_template_run.py#L227

Added line #L227 was not covered by tests
atrl_ids = self.env["account.tax.repartition.line"].search(
[
(tax_repartition, "in", line.tax_ids.ids),
Expand Down Expand Up @@ -285,7 +284,6 @@ class AccountMoveTemplateLineRun(models.TransientModel):
)
amount = fields.Monetary(required=True, currency_field="company_currency_id")
note = fields.Char(readonly=True)
is_refund = fields.Boolean(string="Is a refund?", readonly=True)
tax_repartition_line_id = fields.Many2one(
"account.tax.repartition.line",
string="Tax Repartition Line",
Expand Down

0 comments on commit 0618c58

Please sign in to comment.