|
@@ -6,3 +6,15 @@ class account_invoice(models.Model):
|
|
|
_inherit = "account.invoice"
|
|
|
|
|
|
is_a_expense = fields.Boolean(string="Es un gasto")
|
|
|
+
|
|
|
+ @api.model
|
|
|
+ def _get_default(self):
|
|
|
+ x = self._context.get('is_a_expense')
|
|
|
+ if x == True:
|
|
|
+ return self.env['account.journal'].search([('code','=','GASTO')], limit=1)
|
|
|
+ else:
|
|
|
+ return super(account_invoice, self)._default_journal()
|
|
|
+
|
|
|
+ _defaults = {
|
|
|
+ 'journal_id': _get_default
|
|
|
+ }
|