Skip to content
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
8 changes: 8 additions & 0 deletions account_payment_return/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class AccountMove(models.Model):
copy=False,
)

def _payment_returned(self, return_line):
vals = return_line._prepare_invoice_returned_vals()
if vals:
self.write(vals)

def check_payment_return(self):
returned_invoices = (
self.env["account.partial.reconcile"]
Expand Down Expand Up @@ -111,6 +116,9 @@ class AccountMoveLine(models.Model):
copy=False,
)

def _payment_returned(self, return_line):
self.mapped("move_id")._payment_returned(return_line)


class AccountPartialReconcile(models.Model):
_inherit = "account.partial.reconcile"
Expand Down
6 changes: 5 additions & 1 deletion account_payment_return/models/payment_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def action_confirm(self):
# payment_aml: credit on customer account (from payment move)
# invoice_amls: debit on customer account (from invoice move)
invoice_amls = payment_aml.matched_debit_ids.mapped("debit_move_id")
invoice_amls._payment_returned(return_line)
Copy link
Contributor

Choose a reason for hiding this comment

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

In version 12, the line 227 was removed (invoices.write(self._prepare_invoice_returned_vals()). If you don't do that, the invoices are written twice.

all_move_lines |= payment_aml
invoices |= invoice_amls.mapped("move_id")
payment_aml.remove_move_reconcile()
Expand Down Expand Up @@ -224,7 +225,6 @@ def action_confirm(self):
]
}
)
invoices.write(self._prepare_invoice_returned_vals())
self.write({"state": "done", "move_id": move.id})
return True

Expand Down Expand Up @@ -407,6 +407,10 @@ def _prepare_return_move_line_vals(self, move):
"move_id": move.id,
}

def _prepare_invoice_returned_vals(self):
res = self.return_id._prepare_invoice_returned_vals()
return res

def _prepare_expense_lines_vals(self, move):
self.ensure_one()
return [
Expand Down