From 20aaa69eef3f3d3bd8641f3569c608e18305c2bd Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 11 Oct 2017 14:58:57 +0200 Subject: [PATCH] [FIX] account, hr_expense: registering a payment for a multiple lines expense sheet When registering a payment for an expense sheet with several expense lines, only the first line of the expense sheet was linked to the account move line of the payment. So the payment was considered as partially reconciled. Now when a payment is registered for an expense sheet with several expense lines, the user is redirected to the manual reconciliation widget to link the move line of the payment to all the expense lines. In this way, the payment will be considered as fully reconciled. DO NOT FORWARD-PORT! ONLY FOR v10 opw:772505 --- addons/account/models/account_payment.py | 13 +++++++++++++ .../wizard/hr_expense_register_payment.py | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 90424d8bdf8..a2e73bbab01 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -214,6 +214,19 @@ class account_payment(models.Model): # FIXME: ondelete='restrict' not working (eg. cancel a bank statement reconciliation with a payment) move_line_ids = fields.One2many('account.move.line', 'payment_id', readonly=True, copy=False, ondelete='restrict') + def open_payment_matching_screen(self): + # Open reconciliation view for customers/suppliers + action_context = {'company_ids': [self.company_id.id], 'partner_ids': [self.partner_id.commercial_partner_id.id]} + if self.partner_type == 'customer': + action_context.update({'mode': 'customers'}) + elif self.partner_type == 'supplier': + action_context.update({'mode': 'suppliers'}) + return { + 'type': 'ir.actions.client', + 'tag': 'manual_reconciliation_view', + 'context': action_context, + } + @api.one @api.depends('invoice_ids', 'payment_type', 'partner_type', 'partner_id') def _compute_destination_account_id(self): diff --git a/addons/hr_expense/wizard/hr_expense_register_payment.py b/addons/hr_expense/wizard/hr_expense_register_payment.py index b608b234144..6bd7e1d3b44 100644 --- a/addons/hr_expense/wizard/hr_expense_register_payment.py +++ b/addons/hr_expense/wizard/hr_expense_register_payment.py @@ -88,6 +88,10 @@ class HrExpenseRegisterPaymentWizard(models.TransientModel): for line in payment.move_line_ids + expense_sheet.account_move_id.line_ids: if line.account_id.internal_type == 'payable': account_move_lines_to_reconcile |= line - account_move_lines_to_reconcile.reconcile() + # DO NOT FORWARD-PORT! ONLY FOR v10 + if len(expense_sheet.expense_line_ids) > 1: + return payment.open_payment_matching_screen() + else: + account_move_lines_to_reconcile.reconcile() return {'type': 'ir.actions.act_window_close'}