Odoo Help


How to modify Many2many relation table

Xia Sun
on 4/21/16, 5:56 AM 1,308 views

In models.py, i use following code to create an object. Please ignore all Chinese characters in this page.

class Assemblies(models.Model):

_name = 'property.assemblies'

name = fields.Char(string = '电脑名称')

operator = fields.Char(string = '操作人')

person = fields.Char(string = '使用人')

components = fields.Many2many(comodel_name='property.models', relation='property_assembly_rel', string = '组件')

Now I can see the property_assembly_rel table in odoo's postgreSQL database, but I want to modify this table (insert, write...).

I want to use assemblies_rel_obj = http.request.registry['property.hehe']  to get that table object, but unluckily, I know the table name is property_assembly_rel while I don't know the object name of the table.

Can anyone help me? Many thanks!


Prakash Sharma

--Prakash Sharma--
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

Prakash Sharma
On 4/21/16, 6:55 AM
  • if you want to insert in the record of many2many or i say want to insert a record in property_assembly_rel  
    form controller 
     then  you should use  http.request.registry['property.assemblies'] in odoov7 and  

    http.request.env['property.assemblies'] in odoov8 and odoov9

    Follow these pattern :

  • (0, 0, { values }) link to a new record

  • (1, ID, { values }) update  the linked record with id = ID (write values on it)

  • (2, ID) remove and delete the linked record  with id = ID

  • (3, ID) cut the link to the linked record with id = ID

  • (4, ID) link to existing record with id = ID

  • (5) unlink all

  • (6, 0, [IDs]) replace the list of linked IDs


try this link for more info https://www.odoo.com/documentation/8.0/reference/orm.html

Thanks! this perfectly solve my problem.

Xia Sun
on 4/21/16, 11:03 PM

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

1 follower(s)


Asked: 4/21/16, 5:56 AM
Seen: 1308 times
Last updated: 4/21/16, 11:03 PM