From 6059a7e20cce0f6377b956c4636fcd5c94f86d5e Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Fri, 23 Dec 2022 14:39:51 +0000 Subject: [PATCH] [FIX] hr_expense: mark expense paid by company as paid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expenses paid by company are marked as paid but the related journal entry is not paid and cannot be paid Steps to reproduce: 1. Install Expenses and Accounting 2. Create an expense payable to company and set an amount 3. Create report 4. Submit report 5. Approve report 6. Post journal entries 7. Open the related journal entry 8. Attempt to register payment: an error is raised Solution: Mark the journal entries created for the expense as paid if the expense is paid by the company opw-3075818 closes odoo/odoo#109375 X-original-commit: f5dd4e3326a17c1f6d06630503d1ede8cc6c59fe Signed-off-by: William André (wan) --- addons/hr_expense/models/account_move.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/hr_expense/models/account_move.py b/addons/hr_expense/models/account_move.py index 78d0da96aeb..febf7cb8d55 100644 --- a/addons/hr_expense/models/account_move.py +++ b/addons/hr_expense/models/account_move.py @@ -37,6 +37,13 @@ class AccountMove(models.Model): return _("Expense entry Created") return super()._creation_message() + @api.depends('expense_sheet_id.payment_mode') + def _compute_payment_state(self): + company_paid = self.filtered(lambda m: m.expense_sheet_id.payment_mode == 'company_account') + for move in company_paid: + move.payment_state = move._get_invoice_in_payment_state() + super(AccountMove, self - company_paid)._compute_payment_state() + @api.depends('expense_sheet_id') def _compute_needed_terms(self): # EXTENDS account