@@ -37,14 +37,31 @@ class WebHook(models.Model):
3737 selection = '_get_interface_types' ,
3838 required = True ,
3939 )
40- uri_path = fields .Char (
41- help = 'This is the URI path that is used to call the web hook.' ,
40+ json_uri_path = fields .Char (
41+ help = 'This is the URI path that is used to call the web hook with '
42+ 'a JSON request.' ,
4243 compute = '_compute_uri_path' ,
4344 store = True ,
4445 readonly = True ,
4546 )
46- uri = fields .Char (
47- help = 'This is the URI that is used to call the web hook externally.' ,
47+ http_uri_path = fields .Char (
48+ help = 'This is the URI path that is used to call the web hook with '
49+ 'a form encoded request.' ,
50+ compute = '_compute_uri_path' ,
51+ store = True ,
52+ readonly = True ,
53+ )
54+ json_uri = fields .Char (
55+ string = 'JSON Endpoint' ,
56+ help = 'This is the URI that is used to call the web hook externally. '
57+ 'This endpoint only accepts requests with a JSON mime-type.' ,
58+ compute = '_compute_uri' ,
59+ )
60+ http_uri = fields .Char (
61+ string = 'Form-Encoded Endpoint' ,
62+ help = 'This is the URI that is used to call the web hook externally. '
63+ 'This endpoint should be used with requests that are form '
64+ 'encoded, not JSON.' ,
4865 compute = '_compute_uri' ,
4966 )
5067 token_id = fields .Many2one (
@@ -85,14 +102,18 @@ def _compute_uri_path(self):
85102 # Do not compute slug until saved
86103 continue
87104 name = slugify (record .name or '' ).strip ().strip ('-' )
88- record .uri_path = '/base_web_hook/%s-%d' % (name , record .id )
105+ record .json_uri_path = '/base_web_hook/%s-%d.json' % (
106+ name , record .id ,
107+ )
108+ record .http_uri_path = '/base_web_hook/%s-%d' % (name , record .id )
89109
90110 @api .multi
91111 @api .depends ('uri_path' )
92112 def _compute_uri (self ):
93113 base_uri = self .env ['ir.config_parameter' ].get_param ('web.base.url' )
94114 for record in self .filtered (lambda r : r .uri_path ):
95- record .uri = '%s%s' % (base_uri , record .uri_path )
115+ record .json_uri = '%s%s' % (base_uri , record .json_uri_path )
116+ record .http_uri = '%s%s' % (base_uri , record .http_uri_path )
96117
97118 @api .model
98119 def _get_token_types (self ):
0 commit comments