I have this module that restricts invoicing to customers with overdue invoices. The module works, but it takes about 10 minutes to confirm a sale. In the meantime it hangs everything. This is not practical so we are wondering what could be making it take so long. Here is the code:
@api.model
def create(self, vals):
today = datetime.now().date()
inv_ids = self.search([('partner_id', '=', vals['partner_id']), ('state', '=', 'open'), ('type', '=', 'out_invoice'), ('date_due', '<', today)],)
if inv_ids:
raise Warning("You can not create invoice for this Customer. This customer already has one or more overdue invoices.")
return super(account_invoice, self).create(vals)
Offtopic: You should prevent delivering to customers with overdue invoices, not invoicing. Then it is too late :-)