diff --git a/payment_status_in_sale/__manifest__.py b/payment_status_in_sale/__manifest__.py index e7979cd41..e26af7933 100644 --- a/payment_status_in_sale/__manifest__.py +++ b/payment_status_in_sale/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################### { 'name': 'Sale Order Payment Status', - 'version': '18.0.1.0.0', + 'version': '18.0.1.0.1', 'category': 'Sales', 'summary': 'Displays the payment status and details in the Sale Order.', 'description': """This module is used to display the invoice status of the diff --git a/payment_status_in_sale/doc/RELEASE_NOTES.md b/payment_status_in_sale/doc/RELEASE_NOTES.md index 9d9e1e8a2..440cfa14c 100644 --- a/payment_status_in_sale/doc/RELEASE_NOTES.md +++ b/payment_status_in_sale/doc/RELEASE_NOTES.md @@ -4,3 +4,8 @@ #### Version 18.0.1.0.0 ##### ADD - Initial commit for Sale Order Payment Status + +#### 25.06.2025 +#### Version 18.0.1.0.0 +##### ADD +- Bug fixed to ensure the correct payment status is reflected when credit notes are created. \ No newline at end of file diff --git a/payment_status_in_sale/models/sale_order.py b/payment_status_in_sale/models/sale_order.py index 62e750a05..687f549c6 100644 --- a/payment_status_in_sale/models/sale_order.py +++ b/payment_status_in_sale/models/sale_order.py @@ -95,13 +95,19 @@ class SaleOrder(models.Model): @api.depends('invoice_ids') def _compute_amount_due(self): """The function is used to compute the amount due from the invoice and - if payment is registered.""" + if payment is registered, accounting for exchange rate differences and credit notes.""" for rec in self: - amount_due = 0 - for order in rec.invoice_ids: - amount_due = amount_due + (order.amount_total - - order.amount_residual) - rec.amount_due = rec.amount_total - amount_due + total_invoiced = 0 + total_paid = 0 + for invoice in rec.invoice_ids: + if invoice.move_type == 'out_invoice': # Regular invoices + total_invoiced += invoice.amount_total + total_paid += invoice.amount_total - invoice.amount_residual + elif invoice.move_type == 'out_refund': # Credit notes + total_invoiced -= invoice.amount_total + total_paid -= ( + invoice.amount_total - invoice.amount_residual) + rec.amount_due = total_invoiced - total_paid def action_open_business_doc(self): """ This method is intended to be used in the context of an