diff --git a/partner_credit_limit/sale.py b/partner_credit_limit/sale.py index 490f212f..bbf70970 100755 --- a/partner_credit_limit/sale.py +++ b/partner_credit_limit/sale.py @@ -23,7 +23,7 @@ def check_limit(self): ('invoiced', '=', False), ('order_id.state', 'not in', ['draft', 'cancel', 'sent'])] order_lines = self.env['sale.order.line'].search(domain) - none_invoiced_amount = sum([x.price_subtotal for x in order_lines]) + none_invoiced_amount = sum([x.price_subtotal * x.tax_id.amount + x.price_subtotal for x in order_lines]) # We sum from all the invoices that are in draft the total amount domain = [ @@ -32,7 +32,7 @@ def check_limit(self): draft_invoices_amount = sum([x.amount_total for x in draft_invoices]) available_credit = self.partner_id.credit_limit - \ - self.partner_id.credit - \ + abs(self.partner_id.credit) - \ none_invoiced_amount - draft_invoices_amount if self.amount_total > available_credit: