From e854fe7421df034cb1f5006cebe07b7d04c4e168 Mon Sep 17 00:00:00 2001 From: csnauwaert Date: Fri, 23 Sep 2022 08:24:04 +0000 Subject: [PATCH] [FIX] hr_expense: fix company expense could not be posted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When creating an expense paid by the company, we want the expense to be on a bank journal. This is currently incompatible with the current constraint we have that force expense of type 'in_receip' to be on a purchase journal. Since expense only behave like type 'in_receipt' we can ignore that constraint. closes odoo/odoo#101307 X-original-commit: f95eb814166646ec3113d35b910a677b21737cd1 Signed-off-by: William André (wan) --- addons/hr_expense/models/account_move.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/hr_expense/models/account_move.py b/addons/hr_expense/models/account_move.py index 7e55b1ad218..78d0da96aeb 100644 --- a/addons/hr_expense/models/account_move.py +++ b/addons/hr_expense/models/account_move.py @@ -28,6 +28,10 @@ class AccountMove(models.Model): def is_purchase_document(self, include_receipts=False): return bool(self.expense_sheet_id and include_receipts) or super().is_purchase_document(include_receipts) + # Expenses can be written on journal other than purchase, hence don't include them in the constraint check + def _check_journal_move_type(self): + return super(AccountMove, self.filtered(lambda x: not x.expense_sheet_id))._check_journal_move_type() + def _creation_message(self): if self.line_ids.expense_id: return _("Expense entry Created")