For distributors and manufacturers that sell on credit, one bad customer can wipe out a quarter's margin. Credit limits are one of the first controls finance asks for in an Odoo project, and one of the most misunderstood, because the standard feature warns but does not block.
The standard feature
Enable Accounting ▸ Configuration ▸ Settings ▸ Sales Credit Limit and set a default limit. Each customer can then have its own limit on the contact form (Invoicing tab). When a quotation would push the customer over the limit, Odoo shows a warning banner on the sales order, and on invoices too.
That is useful information, but the salesperson can still confirm the order and the warehouse will happily ship it.
Count the real exposure
The receivable balance alone underestimates the risk. The figure that matters is:
exposure = unpaid invoices
+ confirmed orders not yet invoiced
+ this order
In Odoo terms that's the commercial partner's credit (receivable balance), plus the amount_to_invoice of its confirmed sales orders, plus the amount of the order being confirmed. Always work on the commercial partner, so delivery addresses and contacts of the same company share one limit.
Turning the warning into a control
The workflow I implement most often:
- The salesperson clicks Confirm.
- If the exposure is within the limit, the order confirms as usual.
- If not, the order goes on hold and an activity is created for the credit controller, with the exposure breakdown in the chatter.
- Finance approves (once, for this order) or rejects with a reason.
class SaleOrder(models.Model):
_inherit = 'sale.order'
credit_approved = fields.Boolean(copy=False, tracking=True)
def _credit_exposure(self):
self.ensure_one()
partner = self.partner_id.commercial_partner_id
open_orders = self.search([
('partner_id', 'child_of', partner.id),
('state', '=', 'sale'), ('id', '!=', self.id),
])
return partner.credit + sum(open_orders.mapped('amount_to_invoice')) + self.amount_total
def action_confirm(self):
for order in self:
partner = order.partner_id.commercial_partner_id
if (partner.credit_limit and not order.credit_approved
and order._credit_exposure() > partner.credit_limit):
raise UserError(_("Credit limit exceeded: send %s to finance for approval.", order.name))
return super().action_confirm()
In production I replace the error with a proper Request credit approval button and an approval state, but the check itself stays this simple.
Practical rules that keep sales happy
- Overdue beats limit. Many clients also hold orders when an invoice is overdue by more than N days, even if the customer is under the limit.
- Exempt prepaid orders. If the payment term is immediate or the order is paid in advance, skip the check.
- Review limits regularly. A list view of customers with limit, exposure and usage % makes the monthly credit meeting take ten minutes.
- Log everything. Approvals tracked in the chatter answer the auditor's questions before they are asked.
Conclusion
Use the standard warning to inform, and add a hold-and-approve step to control. With exposure computed correctly, credit limits stop being a number on a form and start protecting your cash flow. Need this in your Odoo? Get in touch.