Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions partner_credit_limit/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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:
Expand Down