12345678910111213141516171819202122232425262728293031323334 |
- # -*- encoding: utf-8 -*-
- from openerp import models, fields, api
- class account_invoice(models.Model):
- _inherit = 'account.invoice'
- _name = 'account.invoice'
- enable_credit = fields.Boolean('Habilitar Credito')
- _defaults = {
- 'enable_credit': False,
- }
- @api.one
- @api.onchange('credito')
- def cambiar_estado_credito(self):
- self.contado = not self.credito
- @api.one
- @api.onchange('contado')
- def cambiar_estado_contado(self):
- if self.enable_credit == False:
- self.contado =True
- else:
- self.credito = not self.contado
- @api.one
- def habilitar_check(self):
- invoice = self.env['account.invoice'].search([('id', '=', self.id)])
- if invoice:
- if invoice.enable_credit == False:
- invoice.write({'enable_credit' : True})
- else:
- invoice.write({'enable_credit' : False, 'credito' : False, 'contado' : True })
|