mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[MIG] website_sale_signifyd: for Odoo 14.0, improved error handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
'name': 'Signifyd Connector',
|
'name': 'Signifyd Connector',
|
||||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||||
'version': '13.0.1.0.0',
|
'version': '14.0.1.0.0',
|
||||||
'category': 'Sale',
|
'category': 'Sale',
|
||||||
'description': """
|
'description': """
|
||||||
Automate Order Fraud Detection with the Signifyd API.
|
Automate Order Fraud Detection with the Signifyd API.
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class SignifydCase(models.Model):
|
|||||||
disposition = vals.get('guarantee_disposition', False)
|
disposition = vals.get('guarantee_disposition', False)
|
||||||
for case in self.filtered(lambda c: c.order_id and original_disposition[c] != disposition):
|
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),
|
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
|
return res
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ class SignifydConnector(models.Model):
|
|||||||
_name = 'signifyd.connector'
|
_name = 'signifyd.connector'
|
||||||
_description = 'Interact with Signifyd API'
|
_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')
|
test_mode = fields.Boolean(string='Test Mode')
|
||||||
user_key = fields.Char(string='Team/Username')
|
user_key = fields.Char(string='Team/Username', required=True)
|
||||||
secret_key = fields.Char(string='API Key')
|
secret_key = fields.Char(string='API Key', required=True)
|
||||||
user_key_test = fields.Char(string='TEST Team/Username')
|
user_key_test = fields.Char(string='TEST Team/Username')
|
||||||
secret_key_test = fields.Char(string='TEST API Key')
|
secret_key_test = fields.Char(string='TEST API Key')
|
||||||
webhooks_registered = fields.Boolean(string='Successfully Registered Webhooks')
|
webhooks_registered = fields.Boolean(string='Successfully Registered Webhooks')
|
||||||
@@ -106,6 +106,12 @@ class SignifydConnector(models.Model):
|
|||||||
else:
|
else:
|
||||||
notification['params']['type'] = 'danger'
|
notification['params']['type'] = 'danger'
|
||||||
notification['params']['message'] = res.content.decode('utf-8')
|
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
|
self.webhooks_registered = False
|
||||||
return notification
|
return notification
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user