Skip to Content
Menu
This question has been flagged
1 Reply
2694 Views

i have below code to send message in Automated Action and want to convert into link to open corresponding form view:

record.message_post(body="Internal Transfer created successfully... "+str(record.x_stock_picking_id)+' '+new_stock_picking.name)

it is working correctly to show the stock.picking id and name both. how i can convert new_stock_picking.name into a Link to open Internal Transfer form view with record.x_stock_picking_id (many2one) which contains value of stock.picking id field.

please help.

note: my previous topic has been Deleted without information " why and what was the wrong  " so i cannot repeat the mistake. i am struggling to achieve something and as per my knowledge, i can made mistakes too, so please be humble and inform us.

regards



Avatar
Discard
Author

i tried as below, it is generating related link but it appears as text how i can convert this into actual clickable link?

record.message_post(body=f'{base_url}/web#id={record.x_stock_picking_id.id}&view_type=form&model=stock.picking')

regards

Best Answer

The URL of a form view in Odoo typically follows this format: https:///web#id=&model=&view_type=form. You can replace , , and with your Odoo instance’s URL, the ID of the record you want to open, and the name of the model, respectively.


Here’s how you can modify your code to include a link to the form view of the new_stock_picking record:


https://pastebin.com/xVs2sk6r


In this code, replace with the URL of your Odoo instance. This code creates a link with the text of new_stock_picking.name that opens the form view of the new_stock_picking record when clicked.

Please note that this code assumes that the user who clicks the link has the necessary access rights to view the new_stock_picking record. If the user does not have the necessary access rights, they will see an access error when they click the link.

Avatar
Discard
Author

thank you for reply but i have to enter my odoo instance which is localhost? how i can make it dynamic so it can be access from any instance which make sense.

regards

Author

also tried your given code but its showing in Text not as clickable Link ... what i am missing or doing wrong?

using my code i can copy / paste the link text and can access the currently created new record in Internal Transfer form view.

please help.

regards

Author

thank you @Maciej Burzymowski for your help.

i have implemented Smart Button because after all struggle i just have text of generated link but not a clickable link.

kind regards

Author

problem has resolved, found solution for link when asked on stackoverflow. now the Clickable Link appear in chatter message ... many thanks to CZoellner who help as it should be.

@Admin please, now you can close this topic.

regards.

Related Posts Replies Views Activity
1
Apr 25
1955
1
Mar 25
1768
4
Aug 24
3167
1
Jan 24
1062
1
Dec 23
1832