Skip to content

Commit

Permalink
[FIX] account_payment: warn when payment can't be matched
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
odony committed Jan 30, 2019
1 parent 0060026 commit e61b0ca
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addons/account/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ def open_payment_matching_screen(self):
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'})
Expand Down

0 comments on commit e61b0ca

Please sign in to comment.