From 7ec2153ca978beba70598437ed3ede7cab15f5a7 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Fri, 7 Aug 2020 10:05:00 +0000 Subject: [PATCH] [FIX] hr_expense: fix paid status in expense Create an expense Save, create the report and go through the full flow up to the payment Once paid, the expense sheet will remain in "posted" status, never going to "paid". This occur because the action which update the status react only to invoices https://github.com/odoo/odoo/blob/d9c715c53d51c21fa105aa35f650d54ea909220a/addons/account/models/account_move.py#L4287 https://github.com/odoo/odoo/blob/d9c715c53d51c21fa105aa35f650d54ea909220a/addons/account/models/account_move.py#L4381 opw-2308203 closes odoo/odoo#55633 X-original-commit: fe618a43eb79b7e2b85fa83da7b321055f5ed0b1 Signed-off-by: Nicolas Martinelli (nim) Signed-off-by: agr-odoo --- .../wizard/hr_expense_sheet_register_payment.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/addons/hr_expense/wizard/hr_expense_sheet_register_payment.py b/addons/hr_expense/wizard/hr_expense_sheet_register_payment.py index 37e1f0bf68d..2afd0e82540 100644 --- a/addons/hr_expense/wizard/hr_expense_sheet_register_payment.py +++ b/addons/hr_expense/wizard/hr_expense_sheet_register_payment.py @@ -130,4 +130,19 @@ class HrExpenseSheetRegisterPaymentWizard(models.TransientModel): account_move_lines_to_reconcile |= line account_move_lines_to_reconcile.reconcile() + # Determine is the move is now fully paid. + paid_moves = self.env['account.move'] + for move in account_move_lines_to_reconcile.move_id: + if move.currency_id == self.company_id.currency_id: + is_fully_paid = self.company_id.currency_id.is_zero(move.amount_residual) + else: + is_fully_paid = move.currency_id.is_zero(move.amount_residual_currency) + if is_fully_paid: + paid_moves |= move + expense_sheets = self.env['hr.expense.sheet'].search([ + ('account_move_id', 'in', paid_moves.ids), + ('state', '!=', 'done'), + ]) + expense_sheets.set_to_paid() + return {'type': 'ir.actions.act_window_close'}