From 10dea70486002b484e7156ff0c8ccf7903376502 Mon Sep 17 00:00:00 2001 From: Ilyas Date: Tue, 25 Jun 2024 09:40:33 +0500 Subject: [PATCH] [FIX] sale_commission_product_criteria_domain: consider credit note --- sale_commission_product_criteria/models/account_move.py | 2 +- .../models/account_invoice_line_agent.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sale_commission_product_criteria/models/account_move.py b/sale_commission_product_criteria/models/account_move.py index 1b1bce762..675012bcb 100644 --- a/sale_commission_product_criteria/models/account_move.py +++ b/sale_commission_product_criteria/models/account_move.py @@ -25,7 +25,7 @@ def _compute_amount(self): inv_line.product_id, inv_line.quantity, ) - if line.invoice_id.move_type == 'out_refund': + if line.invoice_id.move_type == "out_refund": line.amount = -amount else: line.amount = amount diff --git a/sale_commission_product_criteria_domain/models/account_invoice_line_agent.py b/sale_commission_product_criteria_domain/models/account_invoice_line_agent.py index be5ccb476..335248af0 100644 --- a/sale_commission_product_criteria_domain/models/account_invoice_line_agent.py +++ b/sale_commission_product_criteria_domain/models/account_invoice_line_agent.py @@ -19,12 +19,16 @@ def _compute_amount(self): and line.commission_id.commission_type == "product_restricted" ): inv_line = line.object_id - line.amount = line._get_single_commission_amount( + amount = line._get_single_commission_amount( line.commission_id, inv_line.price_subtotal, inv_line.product_id, inv_line.quantity, ) + if line.invoice_id.move_type == "out_refund": + line.amount = -amount + else: + line.amount = amount else: res = super(AccountInvoiceLineAgent, line)._compute_amount() return res