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

[14.0][FIX] account_invoice_overdue_reminder: wizard amount residual not computed #406

Open
wants to merge 1 commit into
base: 14.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
2 changes: 1 addition & 1 deletion account_invoice_overdue_reminder/data/mail_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<th style="padding: 5px; border: 1px solid black;">Residual</th>
<th style="padding: 5px; border: 1px solid black;">Past Reminders</th>
</tr>
% for inv in object.invoice_ids.sorted(key='invoice_date'):
% for inv in object.get_invoices().sorted(key='invoice_date'):
<tr style="background-color:
% if inv.move_type == 'out_refund':
LightGray
Expand Down
14 changes: 14 additions & 0 deletions account_invoice_overdue_reminder/wizard/overdue_reminder_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,20 @@
def _reminder_type_selection(self):
return self.env["overdue.reminder.action"]._reminder_type_selection()

# Fix bug:
# When removing a invoice in the interface the field "mail_body" is recomputed in
# "onchange mode". This mean that the field "invoice_ids" have New Record (NewId)
# instead of real record. The issue is that the field "amount_residual" do
# not work with New Record due to "if line.id" here:
# https://github.com/odoo/odoo/blob/cc0060e889603eb2e47fa44a8a22a70d7d784185
# /addons/account/models/account_move.py#L4029
# And so the amount_residual will be always be recomputed by the onchange to 0

# To avoid this issue we force in the template to use real invoices(get_invoices())

def get_invoices(self):
return self.env["account.move"].browse(self.invoice_ids.ids)

Check warning on line 400 in account_invoice_overdue_reminder/wizard/overdue_reminder_wizard.py

View check run for this annotation

Codecov / codecov/patch

account_invoice_overdue_reminder/wizard/overdue_reminder_wizard.py#L400

Added line #L400 was not covered by tests

@api.depends("invoice_ids", "user_id", "partner_id")
def _compute_counter_and_mail(self):
xmlid = self._get_overdue_invoice_reminder_template()
Expand Down
Loading