diff --git a/addons/hr_expense/wizard/account_payment_register.py b/addons/hr_expense/wizard/account_payment_register.py index a44a23fbc8e..b8a0322ae41 100644 --- a/addons/hr_expense/wizard/account_payment_register.py +++ b/addons/hr_expense/wizard/account_payment_register.py @@ -10,6 +10,15 @@ class AccountPaymentRegister(models.TransientModel): # BUSINESS METHODS # ------------------------------------------------------------------------- + @api.model + def _get_line_batch_key(self, line): + # OVERRIDE to set the bank account defined on the employee + res = super()._get_line_batch_key(line) + expense_sheet = self.env['hr.expense.sheet'].search([('payment_mode', '=', 'own_account'), ('account_move_id', 'in', line.move_id.ids)]) + if expense_sheet.employee_id.bank_account_id and not line.move_id.partner_bank_id: + res['partner_bank_id'] = expense_sheet.employee_id.bank_account_id.id + return res + def _create_payments(self): # OVERRIDE to set the 'done' state on expense sheets. payments = super()._create_payments()