I am looking for the technique how to add specific functionality/action to a tree view.
in a tree view I have added a button
<tree>
<button name="fn1" type="object" string="F1" />
then I have added a method for this button in my model
def fn1(self):
All fine to this point
Problem 1 (from view to a method)
I assume that when I click on a button on the record I would somehow get the record id in which button is clicked on. But...
Normally models method def would have REC as parameter and would consist of a marked record set, but in this case no record set has been passed to a method. How do I know on which record button I have clicked on? Is there some modifier in the view definition to instruct button to send record id to an action method?
Problem 2 (from a method to a resulting page)
There is technique to navigate to a specific form using this kind of button, by making method return data in this fashion:
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'my.cloud.files',
'views': [(False, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'context': {},
}
this renders a popup form (in described case it is not even a record from which click is originated but it looks like 'create' form), apart from this:
I do not want to use any of existing ODOO forms, what I want to navigate to a dynamic url I am going to build within this model method.
In more detail what I want is to construct URL from the record I have clicked on, and navigate browser to that URL i have built. To build URL I will be using using a field from my model. For example I have field in the model which is called ID and it has value 123 so I would build a URL like http://site/path/123. This is trivial to make in python but later instruction to ODOO to go to that 'dynamic' url is something I cannot find how to do.
how should 'return' look like to go to my url ?
Kindly advise.
Đức Hậu Trần
Thank you for your answer. Need to try these hints.
One small clarification, please. Following code looks to me to be a part of a Model definition. Is this correct understanding?
fb_link = fields.Html ( string= "FB link", compute="get_fb_link" )
(have not enough karma to comment on your post)
you can see my module at link. https://drive.google.com/file/d/1A0ghYag1jU9MqCNWaTMcbaurYgErSHDp/view?usp=sharing
Hope this idea will help:
1- http://learnopenerp.blogspot.com/2020/01/open-wizard-on-button-click-in-odoo.html
2- https://goo.gl/Baw9Zt