[MIG] website_sale_signifyd: for Odoo 14.0, improved error handling

This commit is contained in:
Jared Kipe
2021-08-26 11:13:44 -07:00
parent 1ff7062327
commit 3bb2e86786
3 changed files with 11 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
{
'name': 'Signifyd Connector',
'author': 'Hibou Corp. <hello@hibou.io>',
'version': '13.0.1.0.0',
'version': '14.0.1.0.0',
'category': 'Sale',
'description': """
Automate Order Fraud Detection with the Signifyd API.

View File

@@ -65,7 +65,7 @@ class SignifydCase(models.Model):
disposition = vals.get('guarantee_disposition', False)
for case in self.filtered(lambda c: c.order_id and original_disposition[c] != disposition):
case.order_id.message_post(body=_('Signifyd Updated Record to %s' % disposition),
subtype='website_sale_signifyd.disposition_change')
subtype_xmlid='website_sale_signifyd.disposition_change')
return res
@api.model

View File

@@ -12,10 +12,10 @@ class SignifydConnector(models.Model):
_name = 'signifyd.connector'
_description = 'Interact with Signifyd API'
name = fields.Char(string='Connector Name')
name = fields.Char(string='Connector Name', required=True)
test_mode = fields.Boolean(string='Test Mode')
user_key = fields.Char(string='Team/Username')
secret_key = fields.Char(string='API Key')
user_key = fields.Char(string='Team/Username', required=True)
secret_key = fields.Char(string='API Key', required=True)
user_key_test = fields.Char(string='TEST Team/Username')
secret_key_test = fields.Char(string='TEST API Key')
webhooks_registered = fields.Boolean(string='Successfully Registered Webhooks')
@@ -106,6 +106,12 @@ class SignifydConnector(models.Model):
else:
notification['params']['type'] = 'danger'
notification['params']['message'] = res.content.decode('utf-8')
try:
# trying to make a better error, not be exhaustive with error handling.
object = json.loads(notification['params']['message'])
notification['params']['message'] = '\n'.join([e[0] for e in (object.get('errors') or {}).values()])
except:
pass
self.webhooks_registered = False
return notification