Skip to content

Commit

Permalink
fix wizard amount residual not computed
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu.saison committed Nov 22, 2024
1 parent 92f3b49 commit e4032e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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 @@ class OverdueReminderStep(models.TransientModel):
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

0 comments on commit e4032e1

Please sign in to comment.