[IMP] hr_expense: use bank account defined on employee in payment
When registering a payment on an expense, we are currently using the first bank account set on the partner if no account is set on the account move. We should use the bank account defined on the employee instead, and fallback on the partner only if it is not set. closes odoo/odoo#72077 X-original-commit: e0335a71afbeb34c5fad9a71bd1b53d5d88d6fa6 Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com> Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user