Getting Id of a model object in create() method

41 views
Skip to first unread message

Khurram Shahzad

unread,
Oct 6, 2016, 11:30:04 AM10/6/16
to try...@googlegroups.com
Dear Community,

As per the requirements of our users, we decided to create "sale" when and appointment is saved for a patient. I am able to "create" the "sale" row from "create" method of appointment (actually gnuhealth_appointment). 

Now, I want to relate the "gnuhealth.appointment" row with "sale.sale" row bu storing id of appointment in the "origin" column of "sale.sale". How can I get the "id" of appointment in the create method, as, I think, id is assigned after the row is saved which is done by the last line of create method:

super(Appointment,cls).create(appointments);

Can any body guide me how I can achieve this?

--
 
Regards,
Khurram.

Cédric Krier

unread,
Oct 7, 2016, 4:20:03 AM10/7/16
to try...@googlegroups.com
You need to use the returned value of create which is a list of
instances where the attribute 'id' is filled.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
Reply all
Reply to author
Forward
0 new messages