From 9be45e9fb5f1dd8ef39bf3511e220c01e69efd6a Mon Sep 17 00:00:00 2001 From: Sebastian Kennedy <skennedy@e-mips.com.ar> Date: Tue, 21 May 2019 16:40:44 -0300 Subject: [PATCH] [FIX] commision fixed amount invoicing --- wizard/ranch_purchase_data_invoice_wizard.py | 7 +++++-- wizard/ranch_purchase_data_invoice_wizardd.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/wizard/ranch_purchase_data_invoice_wizard.py b/wizard/ranch_purchase_data_invoice_wizard.py index ff62fb5..47162ea 100644 --- a/wizard/ranch_purchase_data_invoice_wizard.py +++ b/wizard/ranch_purchase_data_invoice_wizard.py @@ -32,7 +32,10 @@ class PurchaseDataInvoiceWizard(models.TransientModel): purchase_data_ids = ctx.get('active_ids') purchase_data_id = purchase_data_ids and purchase_data_ids[0] purchase_data = purchase_data_obj.browse(purchase_data_id) - auction_commision = purchase_data.auction_commision + + commision_line = purchase_data.commision_lines.filtered( + lambda l: l.commision_type == 'auction') + auction_commision = commision_line and commision_line.amount return auction_commision journal_id = fields.Many2one( @@ -345,7 +348,7 @@ class PurchaseDataInvoiceWizard(models.TransientModel): total_amount = sum(final_lines.mapped( lambda x: x.price_unit * x.invoiced_kilos)) - price_unit = total_amount * (self.auction_commision / 100) + price_unit = self.auction_commision # Prorrated for src_account, distrib in self.account_distribution.items(): diff --git a/wizard/ranch_purchase_data_invoice_wizardd.py b/wizard/ranch_purchase_data_invoice_wizardd.py index bdc817e..5d35be4 100644 --- a/wizard/ranch_purchase_data_invoice_wizardd.py +++ b/wizard/ranch_purchase_data_invoice_wizardd.py @@ -32,7 +32,10 @@ class PurchaseDataInvoiceWizard(models.TransientModel): purchase_data_ids = ctx.get('active_ids') purchase_data_id = purchase_data_ids and purchase_data_ids[0] purchase_data = purchase_data_obj.browse(purchase_data_id) - auction_commision = purchase_data.auction_commision + + commision_line = purchase_data.commision_lines.filtered( + lambda l: l.commision_type == 'auction') + auction_commision = commision_line and commision_line.amount return auction_commision journal_id = fields.Many2one( @@ -433,7 +436,7 @@ class PurchaseDataInvoiceWizard(models.TransientModel): product = config_id.product_id total_amount = sum( summary_lines.mapped(lambda x: x.price * x.weight)) - price_unit = total_amount * (self.auction_commision / 100) + price_unit = self.auction_commision # Prorrated for src_account, distrib in self.account_distribution.items(): -- GitLab