From 91e9c1fe33242bf83971612baa6a83e04194da71 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 22 Apr 2021 23:58:03 +0200 Subject: [PATCH] account_usability: allow to manually create a journal item in cash and check journals --- account_usability/models/account_move.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/account_usability/models/account_move.py b/account_usability/models/account_move.py index 9f8b6cc..ff2a329 100644 --- a/account_usability/models/account_move.py +++ b/account_usability/models/account_move.py @@ -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'