account_invoice.py 970 B

12345678910111213141516171819202122232425262728293031323334
  1. # -*- encoding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class account_invoice(models.Model):
  4. _inherit = 'account.invoice'
  5. _name = 'account.invoice'
  6. enable_credit = fields.Boolean('Habilitar Credito')
  7. _defaults = {
  8. 'enable_credit': False,
  9. }
  10. @api.one
  11. @api.onchange('credito')
  12. def cambiar_estado_credito(self):
  13. self.contado = not self.credito
  14. @api.one
  15. @api.onchange('contado')
  16. def cambiar_estado_contado(self):
  17. if self.enable_credit == False:
  18. self.contado =True
  19. else:
  20. self.credito = not self.contado
  21. @api.one
  22. def habilitar_check(self):
  23. invoice = self.env['account.invoice'].search([('id', '=', self.id)])
  24. if invoice:
  25. if invoice.enable_credit == False:
  26. invoice.write({'enable_credit' : True})
  27. else:
  28. invoice.write({'enable_credit' : False, 'credito' : False, 'contado' : True })