diff --git a/modules/cragr/web/pages.py b/modules/cragr/web/pages.py index 9080bebca1f93fdb976028b0c34375105ac8f9b4..e6d496cc900e6a5aaca9ba2ebe2fbfd9c75947d1 100644 --- a/modules/cragr/web/pages.py +++ b/modules/cragr/web/pages.py @@ -1211,15 +1211,19 @@ def parse_recipients(self, items, assume_internal=False): yield rcpt break elif opt.attrib['value'].startswith('E'): - rcpt = Recipient() - rcpt._index = opt.attrib['value'] - rcpt._raw_label = ' '.join(lines) - rcpt.category = 'Externe' - rcpt.label = lines[0] - rcpt.iban = lines[1].upper() - rcpt.id = rcpt.iban - rcpt.enabled_at = datetime.now().replace(microsecond=0) - yield rcpt + if len(lines) > 1: + # In some cases we observed beneficiaries without label, we skip them + rcpt = Recipient() + rcpt._index = opt.attrib['value'] + rcpt._raw_label = ' '.join(lines) + rcpt.category = 'Externe' + rcpt.label = lines[0] + rcpt.iban = lines[1].upper() + rcpt.id = rcpt.iban + rcpt.enabled_at = datetime.now().replace(microsecond=0) + yield rcpt + else: + self.logger.warning('The recipient associated with the iban %s has got no label' % lines[0]) def submit_accounts(self, account_id, recipient_id, amount, currency): emitters = [rcpt for rcpt in self.iter_emitters() if rcpt.id == account_id and not rcpt.iban]