This question has been flagged
1 Reply
5746 Views

I am trying to get the id of newly created record in res.partner in my automated actions but couldnt figure out how to do it? Seems like there is nothing documented for odoo 10 something like this :


record=self.pool.get('res.partner').browse(cr, uid, ids, context=context)


Does anyone have any idea how to achieve this in odoo 10?




Avatar
Discard
Best Answer

This depends on how you are creating the partners and how you are triggering the automated action.

If the automated action is set to run on the creation of a partner, it will call the nominated server action on the newly created records, therefore the records variable in the server action will be populated, so records.ids will get you the ids of the newly created records (It should only be 1 created at a time, so it should be safe to use record and record.id).

If you are creating the partner record inside an automated action, the create method returns the recordset, so you should be assigning a variable to the result of the create method, ie. partner = env['res.partner'].create({}) then use partner.id.

Avatar
Discard