[IMP] website_sale_signifyd: hibou_professional and improve filter for submitting

This commit is contained in:
Jared Kipe
2021-06-15 10:34:58 -07:00
parent d9178ee8a2
commit bbaedc4f46
11 changed files with 33 additions and 4 deletions

View File

@@ -1,2 +1,4 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from . import controllers
from . import models

View File

@@ -8,9 +8,10 @@ Automate Order Fraud Detection with the Signifyd API.
""",
'website': 'https://hibou.io/',
'depends': [
'website_sale',
'stock',
'delivery',
'hibou_professional',
'stock',
'website_sale',
],
'data': [
'security/ir.model.access.csv',
@@ -23,4 +24,5 @@ Automate Order Fraud Detection with the Signifyd API.
],
'installable': True,
'application': False,
'license': 'OPL-1',
}

View File

@@ -1 +1,3 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from . import signifyd

View File

@@ -1,3 +1,5 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
import json
from odoo.http import Controller, request, route
from odoo.http import Response
@@ -12,10 +14,14 @@ class SignifydWebhooks(Controller):
def _case_update(self):
data = json.loads(request.httprequest.data)
vals = request.env['signifyd.connector'].process_post_values(data)
case = self._get_case(vals.get('case_id'))
case_id = vals.get('case_id')
case = self._get_case(case_id)
if case:
case.update_case_info(vals)
return Response({'response': 'success'}, status=200, mimetype='application/json')
if case_id == 1:
# Special case when verifying webhook.
return Response({'response': 'success'}, status=200, mimetype='application/json')
return Response({'response': 'failed'}, status=500, mimetype='application/json')
def _get_case(self, case_id):

View File

@@ -1,3 +1,5 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from . import partner
from . import sale_order
from . import signifyd

View File

@@ -1,3 +1,5 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from odoo import api, fields, models

View File

@@ -1,3 +1,5 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.http import request
@@ -28,10 +30,13 @@ class SaleOrder(models.Model):
def action_confirm(self):
res = super().action_confirm()
for sale in self.filtered(lambda so: so.state in ('sale', 'done') and not so.signifyd_case_id):
for sale in self.filtered(lambda so: so._should_post_signifyd()):
_case = sale.post_signifyd_case()
return res
def _should_post_signifyd(self):
return self.state in ('sale', 'done') and not self.signifyd_case_id
def post_signifyd_case(self):
if not self.website_id.signifyd_connector_id:
return

View File

@@ -1,3 +1,5 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
import requests
import json
from datetime import datetime as dt

View File

@@ -1,3 +1,5 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
import requests
from datetime import datetime as dt
from base64 import b64encode

View File

@@ -1,3 +1,5 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from odoo import fields, models
from odoo.exceptions import UserError

View File

@@ -1,3 +1,5 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from odoo import api, fields, models