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.


How do you assign several product.product objects to a One2many field?

on 2/20/16, 11:41 AM 411 views

Hi, I have the following field definition:

product_ids = fields.One2many('product.product', compute='_return_product_ids')

if prod1 prod2 and prod3 are product.product instances, how can I assign products_ids to those prod1, prod2 and prod3?


Axel Mendoza

--Axel Mendoza--
| 6 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 2/20/16, 11:55 AM

You mean returning those products as return values of the product_ids computed function _return_product_ids. First of all a one2many it's not recomended at all for tgis because of the checks against the needed many2one in the relation table used to maintain the parent - child relationship, so better you switch to a many2many computed field.

In the computed function just return the ids of those products in the format of [(6,0,ids)] where ids is the list of those products id. Also note that the compute function only will be called when the record is saved. 

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

1 follower(s)


Asked: 2/20/16, 11:41 AM
Seen: 411 times
Last updated: 2/20/16, 1:59 PM