deisy 5 lat temu
rodzic
commit
12552a2c8d
1 zmienionych plików z 12 dodań i 0 usunięć
  1. 12 0
      models/account_invoice.py

+ 12 - 0
models/account_invoice.py

@@ -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
+    }