Skip to Content
Menu
This question has been flagged
2 Replies
6384 Views

Hey, i have made a custom porta view for myself which displays attendance and then i had another class in controller which calls another template with a diff url and i am trying to open the detail of one attendance by clicking on it. Just as it happens in Sale order for portal. I am unable to open the page when i click the link as it gives me error as "Page 404 not found". 

Here is the code for my redirection, Kindly check and tell


class NewAttendView(http.Controller):
@http.route('/attendance_line/{{order.id}}', type='http', auth='public', website=True)
def this_attend_detail(self, **kwargs):
new_attend_detail = request.env['op.attendance.sheet'].sudo().search([])
return request.render('attendance_website.attendance_lines', {'attendance_line': new_attend_detail})

@http.route('/attendance_line/{{order.id}}', type='http', auth='public', website=True)
def that_attend_rights(self, new_attend_detail=None):
new_attend_detail = request.env['op.attendance.sheet'].browse()
return request.render('attendance_website.attendance_lines', {'attendance_line': new_attend_detail})
XML line of code
<a t-attf-href="/attendance_line/{{order.id}}?{{keep_query()}}">
Avatar
Discard
Best Answer

I don't think controller route evaluate jinja syntax 
try

@http.route('/attendance_line/<int: order_id>', .......
​def this_attend_detail(self, order_id, **kwargs):
 
if you want bowser object directly then
​@http.route('/attendance_line/​<model("your.model"):order>​', .......
​def this_attend_detail(self, order, **kwargs):
Avatar
Discard
Author

Hey thanks for replying! Its still not working. I think its something wrong with the url in xml. You thinks its fine? Kindly help me resolving this problem. Thanks

Author

Well your first solution is working now. Thank you soo much. Can you tell me what would be the reason of me getting empty template when going to that url?

Best Answer

Since Odoo routing is based in werkzeug you can refer to the doc on how to format routes in Werkzeug: \https://werkzeug.palletsprojects.com/en/1.0.x/routing/

Avatar
Discard
Author

Thanks for replying. I'll look into it.

Related Posts Replies Views Activity
1
Dec 23
4426
2
Dec 22
1966
1
Jun 21
1809
0
Jun 21
1806
1
Jan 24
484