From e61b0cac4679f2f57163c2aaaef2c7543fd9b52b Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 30 Jan 2019 22:31:51 +0100 Subject: [PATCH] [FIX] account_payment: warn when payment can't be matched The payment reconciliation screen can't be opened if there is no partner on a payment, and currently crashes with a traceback. Rather than hiding the button which could cause surprises for users, we can raise a proper error to explain why it can't work, for the cases where a payment has no related partner. This could happen for example when a customer paid via a direct /website_payment/pay link. --- addons/account/models/account_payment.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 4c5fc10f637..4716a188ca1 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -434,6 +434,8 @@ class account_payment(models.Model): if move_line.account_id.reconcile: move_line_id = move_line.id break; + if not self.partner_id: + raise UserError(_("Payments without a customer can't be matched")) 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'})