[tryton-dev] Open a view as result of button click
Hi all, I would like to know if is possible to open another view when a button placed in a form view is clicked. For example: I'm in a form view of a model named 'foo' and through a button click i want to create an instance of another model named 'bar' and show the form view of this instance. Would it be possible?? Thanks in advance *Carlos Gálvez* Developer *carlos.gal...@nan-tic.com * *http://www.NaN-tic.com <http://www.nan-tic.com/> * *Telf: (+34) 935 531 803 <+34%20935%2053%2018%2003> * *http://twitter.com/nan_tic <http://twitter.com/nan_tic> * *http://www.nan-tic.com/blog <http://www.nan-tic.com/blog>* -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/CAOq2ZJpDaXtRwo%3DbngJPOXZjC6k_ZqSuNnbABtZks%3DzqNEnzRw%40mail.gmail.com.
Re: [tryton-dev] Open a view as result of button click
Hi Sergi, 2018-06-28 14:47 GMT+02:00 Sergi Almacellas Abellana : > > > Yes, it is possible. You should use the button_action decorator to > returns an wizard with an StateAction from the model of the new created > instance. > > You should set the res_id of the action on the wizard to the ids of the > new created instances. Finally, I did not use a "button_action" decorator to return an assistant because I was not interested in having a wizard dirtying my code, but his suggestions showed me the way. The way I have done it is returning on my Modelview.button an Action id that points to an act_window that open the desired view: return Action.get_action_id(ModelData.get_id('mymodule', 'myaction')) and adding a domain to this act_window: Yours gratefully, *Carlos Gálvez* Developer *carlos.gal...@nan-tic.com * *http://www.NaN-tic.com <http://www.nan-tic.com/> * *Telf: (+34) 935 531 803 <+34%20935%2053%2018%2003> * *http://twitter.com/nan_tic <http://twitter.com/nan_tic> * *http://www.nan-tic.com/blog <http://www.nan-tic.com/blog>* -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/CAOq2ZJo%3DgLUmwz3MgQHibsJijVbfB7KyQ5Hr2yevUkXhXKv-%2BQ%40mail.gmail.com.
Re: [tryton-dev] Open a view as result of button click
2018-06-29 10:39 GMT+02:00 Cédric Krier : > > button_action is not limited to wizard, it can be used for any action. > > This would be cleaner to use the button_action decorator. > 2018-06-29 11:36 GMT+02:00 Sergi Almacellas Abellana : > > > This is the same as button_acciont('mymodule.myaction') which is simplier. > > > > and adding a domain to this act_window: > > > > > > Of course, if the new created records are related to the current records > a domain can be used to remove the wizard. > > Just for the record if myfield is a many2one field, there is no need to > include the '.id' part and this will avoid and extra join to the target > table. > > You're right, i tried with a button_action and I obtained the same result with a more clean code. Thanks to both of you! *Carlos Gálvez* Developer *carlos.gal...@nan-tic.com * *http://www.NaN-tic.com <http://www.nan-tic.com/> * *Telf: (+34) 935 531 803 <+34%20935%2053%2018%2003> * *http://twitter.com/nan_tic <http://twitter.com/nan_tic> * *http://www.nan-tic.com/blog <http://www.nan-tic.com/blog>* -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/CAOq2ZJoacWiZJ%3D%2BCvQyqPyHOxRWv5uqhBRCmw61BQ65fDfsdcg%40mail.gmail.com.