[FIX] *: fix typo in route kw

The common mistake of method instead of method leads to the parameter being ignored.
Add a warning to ensure no other controllers are defined this way

closes odoo/odoo#71571

X-original-commit: d0048ef115985a24eec1e47ceb146f4a98f71b38
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
Martin Trigaux
2021-06-03 13:33:43 +00:00
parent 20955462f0
commit b4f81c18d6
2 changed files with 5 additions and 1 deletions
@@ -7,7 +7,7 @@ from odoo.http import request
class PortalRating(http.Controller):
@http.route(['/website/rating/comment'], type='json', auth="user", method=['POST'], website=True)
@http.route(['/website/rating/comment'], type='json', auth="user", methods=['POST'], website=True)
def publish_rating_comment(self, rating_id, publisher_comment):
rating = request.env['rating.rating'].search([('id', '=', int(rating_id))])
if not rating:
+4
View File
@@ -514,6 +514,10 @@ def route(route=None, **kw):
else:
routes = [route]
routing['routes'] = routes
wrong = routing.pop('method', None)
if wrong:
kw.setdefault('methods', wrong)
_logger.warning("<function %s.%s> defined with invalid routing parameter 'method', assuming 'methods'", f.__module__, f.__name__)
@functools.wraps(f)
def response_wrap(*args, **kw):