account_invoice.py 576 B

1234567891011121314151617181920
  1. # -*- encoding: utf-8 -*-
  2. from openerp import models, fields, api, _
  3. from openerp.exceptions import Warning
  4. class account_invoice(models.Model):
  5. _inherit = "account.invoice"
  6. is_a_expense = fields.Boolean(string="Es un gasto")
  7. @api.model
  8. def _get_default(self):
  9. x = self._context.get('is_a_expense')
  10. if x == True:
  11. return self.env['account.journal'].search([('code','=','GASTO')], limit=1)
  12. else:
  13. return super(account_invoice, self)._default_journal()
  14. _defaults = {
  15. 'journal_id': _get_default
  16. }