Skip to content
Snippets Groups Projects
Commit d7563d25 authored by tranngocson1996's avatar tranngocson1996
Browse files

[IMP] hr_expense: Add hook method for inherit


After paying the expense report, the lines are reconciled right away but
with this old code I can't inherit the custom reconciliation lines. So I
provide a hook method to be able to inherit and customize the lines that
want to be reconciled.

closes odoo/odoo#81267

Signed-off-by: default avatarKevin Baptiste <kba@odoo.com>
parent 4f1ee57c
No related branches found
No related tags found
No related merge requests found
......@@ -102,6 +102,9 @@ class HrExpenseSheetRegisterPaymentWizard(models.TransientModel):
'communication': self.communication
}
def _prepare_lines_to_reconcile(self, lines):
return lines.filtered(lambda l: l.account_id.internal_type == 'payable' and not l.reconciled)
def expense_post_payment(self):
self.ensure_one()
company = self.company_id
......@@ -119,10 +122,7 @@ class HrExpenseSheetRegisterPaymentWizard(models.TransientModel):
expense_sheet.message_post(body=body)
# Reconcile the payment and the expense, i.e. lookup on the payable account move lines
account_move_lines_to_reconcile = self.env['account.move.line']
for line in payment.move_line_ids + expense_sheet.account_move_id.line_ids:
if line.account_id.internal_type == 'payable' and not line.reconciled:
account_move_lines_to_reconcile |= line
account_move_lines_to_reconcile = self._prepare_lines_to_reconcile(payment.move_line_ids + expense_sheet.account_move_id.line_ids)
account_move_lines_to_reconcile.reconcile()
return {'type': 'ir.actions.act_window_close'}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment