Odoo Help

0

How to modify Many2many relation table

By
Xia Sun
on 4/21/16, 5:56 AM 1,013 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!


1
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.

Register

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)

Stats

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