Discussion:
[tryton] Instantiate a model object
Khurram Shahzad
2018-03-29 07:19:08 UTC
Permalink
Dear All,

I have defined a model class with some attributes, methods for setting
default values and on_change() event listener. How can I instantiate it so
that I can have its attributes initialized automatically by default_???
methods and when user make some change to fields, the on_change() event
gets fired.

In fact, I will show a list of such objects to user and when user is done
with entering data, and save them when he clicks 'Process' button of wizard.
--
Regards,
Khurram.
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/CAM3N3CwTAR5Wi0JagnU7CthuBiEvrqG_TZe0ckQ%2BFfOZ7FGCbg%40mail.gmail.com.
Sergi Almacellas Abellana
2018-03-29 09:30:09 UTC
Permalink
Post by Khurram Shahzad
Dear All,
I have defined a model class with some attributes, methods for setting
default values and on_change() event listener. How can I instantiate it
so that I can have its attributes initialized automatically by
default_??? methods and when user make some change to fields, the
on_change() event gets fired.
When you instantiate a model from code default values and on_change are
not applied. This is done on client side.
Post by Khurram Shahzad
In fact, I will show a list of such objects to user and when user is
done with entering data, and save them when he clicks 'Process' button
of wizard.
What is the user behavior here? It has to create the records or it has
to update some data?

Best way is to show a One2Many field on the wizard. If the user has to
create the records just leave it empty an let them fill the records. If
you have to modify some existing records, just return the ids of the
records as default value and the client will show the record with all
the values of the view.

In both cases the client will automatically call the defaults and
on_change required for user actions.

Hope it helps.
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/80c05141-04b5-7fba-9f1e-c976a9729054%40koolpi.com.
Khurram Shahzad
2018-03-29 10:01:12 UTC
Permalink
Dear Sergi,

Thanks for the response.
Post by Sergi Almacellas Abellana
Post by Khurram Shahzad
Dear All,
I have defined a model class with some attributes, methods for setting
default values and on_change() event listener. How can I instantiate it
so that I can have its attributes initialized automatically by
default_??? methods and when user make some change to fields, the
on_change() event gets fired.
When you instantiate a model from code default values and on_change are
not applied. This is done on client side.
Post by Khurram Shahzad
In fact, I will show a list of such objects to user and when user is
done with entering data, and save them when he clicks 'Process' button
of wizard.
What is the user behavior here? It has to create the records or it has
to update some data?
In fact, we are working on duty roster management. I run a wizard, which
shows list of employees and months. The user selects a month and an
employee. When employee changes, I fill a One2Many field which contains as
many records as days. Here I want default values for every day, like
default shift. I also want that when user changes a shift for a day, its
time is displayed in next column.
Post by Sergi Almacellas Abellana
Best way is to show a One2Many field on the wizard. If the user has to
create the records just leave it empty an let them fill the records. If
you have to modify some existing records, just return the ids of the
records as default value and the client will show the record with all
the values of the view.
I am doing the same; but I can not leave the records empty. Moreover, I
also want to respond to change events of each record.
Post by Sergi Almacellas Abellana
In both cases the client will automatically call the defaults and
on_change required for user actions.
Hope it helps.
Thanks again.
Regards,
Khurram.
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/CAM3N3CwMfJVrRurw6JTtUv7iFVxMGeFL34UNPHb_igFcFMQz2A%40mail.gmail.com.
Sergi Almacellas Abellana
2018-03-29 11:04:08 UTC
Permalink
Post by Khurram Shahzad
In fact, we are working on duty roster management. I run a wizard, which
shows list of employees and months. The user selects a month and an
employee. When employee changes, I fill a One2Many field which contains
as many records as days. Here I want default values for every day, like
default shift.
Then I will probably ask the employee and the month in a state, generate
the records and then use a StateAction to show the created records so
the user can modify whatever they wants.

If you create the records default values will be automatically applied.

I also want that when user changes a shift for a day, its
Post by Khurram Shahzad
time is displayed in next column.
If you need to re-process the records after some action, you can display
the created records on a One2Many and add another transition to do
whatever you need with them.

Hope it helps.
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/ba2e7941-4c4a-f07a-9cfc-9591d2e1dca8%40koolpi.com.
Khurram Shahzad
2018-03-30 03:06:22 UTC
Permalink
Thanks a lot. That's perfect.
Post by Sergi Almacellas Abellana
Post by Khurram Shahzad
In fact, we are working on duty roster management. I run a wizard, which
shows list of employees and months. The user selects a month and an
employee. When employee changes, I fill a One2Many field which contains
as many records as days. Here I want default values for every day, like
default shift.
Then I will probably ask the employee and the month in a state, generate
the records and then use a StateAction to show the created records so
the user can modify whatever they wants.
If you create the records default values will be automatically applied.
I also want that when user changes a shift for a day, its
Post by Khurram Shahzad
time is displayed in next column.
If you need to re-process the records after some action, you can display
the created records on a One2Many and add another transition to do
whatever you need with them.
Hope it helps.
--
You received this message because you are subscribed to the Google Groups "tryton" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/tryton/CAM3N3Cyo%2BAuY2XFfMH7d7ViwgDVBy3qhTUkfHSkY1PHZY%2Bu-uw%40mail.gmail.com.
Loading...