From c8497e024e9616d7dff580e0c9a90ebbe3fc6ec9 Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Mon, 12 Sep 2022 12:27:47 +0000 Subject: [PATCH] [FIX] product_margin: product margin use partial/reversed payment Current behavior: Partial and reversed payment were not taken into account for the product margin calculation. Steps to reproduce: 1. Create a product with an common avco setup. 2. Go to purchase 1 unit at 10 dollars. 3. Upon confirming the invoice your cost is updated in the product margin report. 4. Create a partial payment on the bill. This creates issues as the product margin report is looking for paid or open not partially paid so it won't show up in the cost calculation. 5. Once the bill is fully paid then it shows up in the cost section of the product margin report again as its payment status moves to Paid. 6. Create a sales order for the unit at 100 dollars. 7. Invoice for the full amount then cancel it by creating a full credit note to put the original invoice in reversed status. This will have only the credit note show up in the turnover calculation as it is in paid status while the original invoice doesn't have a paid or open status so it isn't taken into account. opw-2887240 closes odoo/odoo#108992 X-original-commit: ddca80ebee20f75ee9b9da2828de5a9170ea683e Signed-off-by: Quentin De Paoli Signed-off-by: Engels Robin (roen) --- addons/product_margin/models/product_product.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/product_margin/models/product_product.py b/addons/product_margin/models/product_product.py index 6fe2321eddb..9f6b15c83d0 100644 --- a/addons/product_margin/models/product_product.py +++ b/addons/product_margin/models/product_product.py @@ -105,13 +105,13 @@ class ProductProduct(models.Model): payment_states = () if invoice_state == 'paid': states = ('posted',) - payment_states = ('in_payment', 'paid',) + payment_states = ('in_payment', 'paid', 'reversed') elif invoice_state == 'open_paid': states = ('posted',) - payment_states = ('not_paid', 'in_payment', 'paid') + payment_states = ('not_paid', 'in_payment', 'paid', 'reversed', 'partial') elif invoice_state == 'draft_open_paid': states = ('posted', 'draft') - payment_states = ('not_paid', 'in_payment', 'paid') + payment_states = ('not_paid', 'in_payment', 'paid', 'reversed', 'partial') if "force_company" in self.env.context: company_id = self.env.context['force_company'] else: