[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) <nim@odoo.com>
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2020-08-07 13:42:14 +00:00
parent c18b1598cf
commit 7ec2153ca9
@@ -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'}