Editing a record shown in one2many list

31 views
Skip to first unread message

Khurram Shahzad

unread,
May 16, 2017, 3:42:07 AM5/16/17
to try...@googlegroups.com
Hi all,

I have added following field on the view:

    surgeries = fields.Function(fields.One2Many('gnuhealth.surgery', None, 'Surgeries'), 'get_surgeries')

The function 'get_surgeries' returns the list of surgeries as per foreign key.

The list of surgeries is displayed but when the user opens a surgery record by double clicking on it, the record is not editable and all the action buttons are disabled.

Is there anyway to have this record opened in edit mode?

--
 
Regards,
Khurram.

Sergi Almacellas Abellana

unread,
May 16, 2017, 3:49:35 AM5/16/17
to try...@googlegroups.com
El 16/05/17 a les 09:42, Khurram Shahzad ha escrit:
Function fields are readonly by default unless you provide a setter [1]
for them. You should implement a setter that writes the changes to the
source model.

HIH

[1]
http://doc.tryton.org/4.4/trytond/doc/ref/models/fields.html?highlight=setter#trytond.model.fields.Function.setter


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

Khurram Shahzad

unread,
May 16, 2017, 4:18:21 AM5/16/17
to try...@googlegroups.com
Thank you Sergi. Its fine as long as I have to call write method of the 'Surgery' class from my setter method. But, what about other methods called on click events of buttons on the Surgery form? Will I have to write methods for calling them as well?
--
 
Regards,
Khurram.

Sergi Almacellas Abellana

unread,
May 16, 2017, 5:50:30 AM5/16/17
to try...@googlegroups.com
El 16/05/17 a les 10:18, Khurram Shahzad ha escrit:
> Thank you Sergi. Its fine as long as I have to call write method of the
> 'Surgery' class from my setter method. But, what about other methods
> called on click events of buttons on the Surgery form? Will I have to
> write methods for calling them as well?
No, buttons will be called on Surgery class with the records ids.
Reply all
Reply to author
Forward
0 new messages