Odoo Help

ClueLogics Technologies Pvt. Ltd.
On 5/23/13, 8:25 AM

Hi Aldennis

suppose your one2manyfield name is my_field then

define list in first ex .. r=[]


r.append({'first_field_ino2m':'my vlaue','second......':'my second value'})

you can add more field availble in That one2manyobject for another record just continuous append same after all append completed just add rinmy_field':r,

exm. vals.update({'my_field':r})


This solution allows you to use the on_change even if you just clicked create and haven't saved your record yet. +1 and setted as accepted answerd. Thanks Sandeep

Camptocamp SA
on 8/21/13, 11:43 AM

Thanks @ Sandeep +1

Ankit H Gandhi(AHG)
on 8/3/16, 6:13 AM

hello @Cluelogics @Camptocamp,

My problem in the following link. Can you provide me approprient solution for this problem.


SunArc Technologies, Pawan Sharma
on 10/23/17, 7:18 AM
Sudhir Arya (ERP Harbor Consulting Services)
On 5/23/13, 10:16 AM

You need to return all IDs in one list with your one2many field in values.


return {'value': {'your_one2many_field': list_of_ids}}

For example my_emp_ids is my one2many field of hr.employee and I want to fill it when I will select Department. I want all employees of selected Depratment.

def onchange_department(self, cr, uid, deprt_id):
    employee_ids = self.search(cr, uid, [('department_id', '=', deprt_id)])
    return {'value': {'my_emp_ids': employee_ids}}

I've tried your code , it's working . but the employee filled is not based on their department , but based on the id of class that contain deprt_id . Example : in my departments , Admin have ID 1 , Programmer have ID 2 , Engineer have ID 3 . When I choose Programmer Department , the printed employees on my_emp_ids is not programmer dept employee , but Admin dept employee . When I checked on PostgreSQL Database , the deprt_id shows correct id ( same id with department_id ) . I assume that the printed employee based on id of deprt_id and not the deprt_id . Am I making mistake ? please help

Nanda Kanoko
on 7/15/13, 2:13 AM

This code is full work Thank you @ Sudhir sir +1 and up voted.

Ankit H Gandhi(AHG)
on 11/23/15, 7:15 AM

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)


Asked: 5/23/13, 6:22 AM
Seen: 21449 times
Last updated: 11/7/17, 12:09 AM