Odoo Help

Welcome!

This community 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.

1

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

By
layal abishalhla
on 3/10/14, 6:10 AM 828 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 ?

1

René Schuster

--René Schuster--
1560
| 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):
    res={};
    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'),
}

Regards

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

0 follower(s)

Stats

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