[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.
This commit is contained in:
Olivier Dony
2019-01-30 22:31:51 +01:00
parent 006002646e
commit e61b0cac46
+2
View File
@@ -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'})