account_usability: allow to manually create a journal item in cash and check journals

This commit is contained in:
Alexis de Lattre
2021-04-22 23:58:03 +02:00
parent dff4e47cf5
commit 91e9c1fe33

View File

@@ -5,6 +5,7 @@
from odoo import api, fields, models
from odoo.tools import float_is_zero
from odoo.tools.misc import format_date
from odoo.osv import expression
class AccountMove(models.Model):
@@ -157,6 +158,24 @@ class AccountMove(models.Model):
for x in sales]
inv.sale_dates = ", ".join(dates)
# allow to manually create moves not only in general journals,
# but also in cash journal and check journals (= bank journals not linked to a bank account)
@api.depends('company_id', 'invoice_filter_type_domain')
def _compute_suitable_journal_ids(self):
for move in self:
if move.invoice_filter_type_domain:
super(AccountMove, move)._compute_suitable_journal_ids()
else:
company_id = move.company_id.id or self.env.company.id
domain = expression.AND([
[('company_id', '=', company_id)],
expression.OR([
[('type', 'in', ('general', 'cash'))],
[('type', '=', 'bank'), ('bank_account_id', '=', False)]
])
])
move.suitable_journal_ids = self.env['account.journal'].search(domain)
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'