12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- from openerp import models, api, _
- from openerp.exceptions import Warning
- from datetime import datetime, date
- class account_invoice(models.Model):
- _inherit = "account.invoice"
- def invoice_validate(self):
- self.check_limit()
-
- return super(account_invoice, self).invoice_validate()
- @api.one
- def check_limit(self):
- if self.contado == True:
- return True
- available_credit = self.partner_id.credit_limit - self.partner_id.credit
- if self.amount_total > available_credit:
- if not self.user_has_groups('partner_credito_limite.groups_partner_credito_limite'):
- msg = 'No se puede confirmar el Pedido ya que el cliente no tiene crédito suficiente.\
- Pruebe marcar la opción "Contado" o pedir autorización para poder realizar la venta.'
- raise Warning(_(msg))
- return False
- return True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|