İçereği Atla
Menü
Bu soru işaretlendi
970 Görünümler

I have created a controller for that:

from odoo import http
from odoo.http import request

class SaleOrderView(http.Controller):

@http.route(['/sales/record/sale.order/<int:order_id>'], type='http', auth='public', website=True, methods=['GET'], csrf=False, save_session=False)
def view_record(self, order_id, **kwargs):
print(f"view_record called with order_id={order_id}")

access_token = request.httprequest.args.get('access_token')
stored_token = request.env['ir.config_parameter'].sudo().search([('key', '=', 'access_token')], limit=1)
token = stored_token.value if stored_token else ''

if access_token != token:
return "Access Denied", 403

sale_order = request.env['sale.order'].sudo().browse(order_id)

if not sale_order.exists():
return "Record Not Found", 404

return request.render('odoo_custom.sales_record_approve_view', {'record': sale_order})


and also, I created some static access token in "ir.config_parameter":

unique-access-token-1234

Just consider this static URL link as my read access for some record.

http://localhost:8079/sales/record/sale.order/19647?access_token=unique-access-token-1234

And the issue I am facing is if I add this URL into some anchor tag and included that anchor tag into form view.

<a t-attf-href="http://localhost:8079/sales/record/sale.order/19647?access_token=unique-access-token-1234"
style="font-size: 12px; color: #875A7B; text-decoration: none; border-radius:3px text-align: center; vertical-align: middle;">
Confirm &#10004;
</a>


that time it's working the and template I used in controller is rendering properly. but when I copy the URL and paste into any other browser or incognito mode am getting the not found error and the controller is not being called. give me some tip if anyone have idea.

Thank you, 


Avatar
Vazgeç
Üretici

Solved !!

It would benefit people who stumble upon this thread to share what the problem was, you are able to answer your own question and provide a solution.

İlgili Gönderiler Cevaplar Görünümler Aktivite
4
Tem 25
1709
1
Tem 25
929
1
Nis 25
941
0
Mar 25
903
1
Mar 25
1005