Odoo Help


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.


Edit one2many or reference field from Python?

Carlos Llamacho
on 9/17/13, 12:59 PM 668 views

Can i use ORM methods like create or write to edit fields like a one2many or a reference one? How would i access them?

Let's say i want to create a function that when called creates a new menu, but the menu must have referenced action that is made up of a selection field wich then becomes a many2one, right? How would i call this many2one? Should i set first the selection with create then edit the many2one with write?

 Menu.create(cr, uid, {'name':menu_name, 'parent_id': parent_id[0],
                                        'icon': 'STOCK_JUSTIFY_FILL',
                                        'sequence': 2,
                                        'action': '[ir.actions.act_window]'} , context=None)
new_menu_ids = Menu.search(cr, uid, [('name','=','menu_name')], limit=1, context=None)
Menu.write(cr, uid, new_menu_ids[0], {'action':action_wanted.id}, context=None)


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)


Asked: 9/17/13, 12:59 PM
Seen: 668 times
Last updated: 3/16/15, 8:10 AM