Odoo Help


adding an item in one2many field whenever an item is added to another one2many field

layal abishalhla
on 3/10/14, 6:10 AM 1,251 views

In my custom module i have two one2many fields. My aim is to whenever i add an item to the one2many field 'A' I want it automatically to be added in the one2many field 'B'. any help please ?


René Schuster

--René Schuster--
| 5 5 8
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster
On 3/10/14, 6:37 AM

You could make field B a function field and 'mirror' field A, if both fields should show exactly the same.

def _get_A(self, cr, uid, ids, field_name, arg, context=None):
    for obj in self.browse(cr, uid, ids, context=context):
        res[obj.id] = obj.field_A
    return res

columns = {
    'field_A': fields.many2one(.......),
    'field_B': fields.function(_get_A, type="many2one", obj='field_a_model', method=True, string='Field B Name'),


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 3/10/14, 6:10 AM
Seen: 1251 times
Last updated: 3/16/15, 8:10 AM