Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
954 Zobrazení

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
Zrušit
Autor

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.

Related Posts Odpovědi Zobrazení Aktivita
4
čvc 25
1700
1
čvc 25
924
1
dub 25
939
0
bře 25
899
1
bře 25
1000