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 to modify Many2many relation table

Xia Sun
on 4/21/16, 5:56 AM 341 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--
| 2 1 4
Delhi, India
--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

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: 4/21/16, 5:56 AM
Seen: 341 times
Last updated: 4/21/16, 11:03 PM