Re: [tryton-dev] Open a view as result of button click

2018-06-29 Thread Carlos Gálvez
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  *

*Telf: (+34) 935 531 803 <+34%20935%2053%2018%2003> *

*http://twitter.com/nan_tic  *

*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.


Re: [tryton-dev] Open a view as result of button click

2018-06-29 Thread Sergi Almacellas Abellana
El 29/06/18 a les 09:52, Carlos Gálvez ha escrit:
> 
> 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'))
> 

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.


-- 
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

-- 
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/b408dab5-6b33-2c24-3c43-c488037d46ac%40koolpi.com.


Re: [tryton-dev] Open a view as result of button click

2018-06-29 Thread Cédric Krier
On 2018-06-29 09:52, Carlos Gálvez wrote:
> 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.

button_action is not limited to wizard, it can be used for any action.

> 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'))

This would be cleaner to use the button_action decorator.

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: cedric.kr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

-- 
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/20180629083908.GK3931%40kei.


Re: [tryton-dev] Open a view as result of button click

2018-06-29 Thread Carlos Gálvez
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  *

*Telf: (+34) 935 531 803 <+34%20935%2053%2018%2003> *

*http://twitter.com/nan_tic  *

*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-28 Thread Sergi Almacellas Abellana
El 28/06/18 a les 14:15, Carlos Gálvez ha escrit:
> Hi all,

Hi Carlos,
> 
> 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??

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.





-- 
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

-- 
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/2b2dab86-a098-83b9-f5f4-a08a4bd510db%40koolpi.com.


[tryton-dev] Open a view as result of button click

2018-06-28 Thread Carlos Gálvez
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  *

*Telf: (+34) 935 531 803 <+34%20935%2053%2018%2003> *

*http://twitter.com/nan_tic  *

*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.