diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 3dfe2416616..e5afb8f9bdc 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -573,6 +573,8 @@ class AccountInvoice(models.Model): to_open_invoices = self.filtered(lambda inv: inv.state != 'open') if to_open_invoices.filtered(lambda inv: inv.state != 'draft'): raise UserError(_("Invoice must be in draft state in order to validate it.")) + if to_open_invoices.filtered(lambda inv: inv.amount_total < 0): + raise UserError(_("You cannot validate an invoice with a negative total amount. You should create a refund instead.")) to_open_invoices.action_date_assign() to_open_invoices.action_move_create() return to_open_invoices.invoice_validate()