From b0286bb4dc0dfd728f70d8b9f9e40c7c27c0fc8c Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Mon, 17 Sep 2018 13:45:13 -0700 Subject: [PATCH] IMP `hr_payroll_payment` Allow some balances to be reconciled in advance externally (i.e. only pay non-reconciled lines) --- hr_payroll_payment/hr_payroll_register_payment.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hr_payroll_payment/hr_payroll_register_payment.py b/hr_payroll_payment/hr_payroll_register_payment.py index 3114702d..4c7ee6a2 100755 --- a/hr_payroll_payment/hr_payroll_register_payment.py +++ b/hr_payroll_payment/hr_payroll_register_payment.py @@ -39,10 +39,11 @@ class HrPayrollRegisterPaymentWizard(models.TransientModel): context = dict(self._context or {}) active_ids = context.get('active_ids', []) payslip = self.env['hr.payslip'].browse(active_ids) - amount = 0.0 - for line in payslip.move_id.line_ids: - if line.account_id.internal_type == 'payable' and line.partner_id.id == payslip.employee_id.address_home_id.id: - amount += abs(line.balance) + amount = -sum(payslip.move_id.line_ids.filtered(lambda l: ( + l.account_id.internal_type == 'payable' + and l.partner_id.id == payslip.employee_id.address_home_id.id + and not l.reconciled) + ).mapped('balance')) return amount @api.model @@ -142,7 +143,7 @@ class HrPayrollRegisterPaymentWizard(models.TransientModel): if line.account_id.internal_type == 'payable': account_move_lines_to_reconcile |= line for line in payslip.move_id.line_ids: - if line.account_id.internal_type == 'payable' and line.partner_id.id == self.partner_id.id: + if line.account_id.internal_type == 'payable' and line.partner_id.id == self.partner_id.id and not line.reconciled: account_move_lines_to_reconcile |= line account_move_lines_to_reconcile.reconcile()