Odoo Help

Welcome!

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.

1

many2many relation syntax

By
omprakash
on 6/7/13, 11:11 AM 5,864 views

Hi Friends ,

I like to know about Fields Type / Relation Fields - many2many syntax

From the existing code : server/openerp/addons/base/res/res_partner.py

  1. class res_partner(osv.osv, format_address):

    _columns= {
             ..............
              'category_id': fields.many2many('res.partner.category', id1='partner_id', id2='category_id', string='category'),
    
    .......
               }
    
  2. class res_partner_category(osv.osv):

    _columns={ ............

              'partner_ids': fields.many2many('res.partner', id1='category_id', id2='partner_id', string='Partners'),
            }
    

    Actually my doubt is from the syntax i can't understand id1 & id2 . Please explain me .

Thanks & Regards

OMPRAKASH.A

0

Hiral Patel (hip)

--Hiral Patel (hip)--
Tiny ERP Pvt Ltd
http://www.odoo.com
913
| 2 1 5
India
--Hiral Patel (hip)--


Hiral Patel (hip)
On 6/7/13, 12:03 PM

id1 is actual.object.id and id2 is other.object.id. Actual object.id and other.object.id are the fields' names used in the relation table, and 'res.partner.category' is the relational object.

The syntax of M2M is fields.many2many('other.object.name', 'relation object', 'actual.object.id', 'other.object.id', 'Field Name')

*'other.object.name' is optional for v7.

Thank you

Hi Hiral Patel , Thanks for immediate reply .. I have doubt in < id1 is actual.object.id and id2 is other.object.id. Actual object.id and other.object.id are the fields' names used in the relation table, > from this point what is relation table from this example & where i can find it ?

omprakash
on 6/7/13, 12:54 PM

You can find this in the 6.0 documentation. The second argument is the relation name (and table name). https://doc.openerp.com/v6.0/developer/2_5_Objects_Fields_Methods/field_type.html/ ... fields.many2many('other.object.name', 'relation object', ... Where: relation object is the table that makes the link (...) Example: 'category_ids': fields.many2many( 'res.partner.category', 'res_partner_category_rel', 'partner_id', 'category_id', 'Categories'),

HUYREKA Solutions, Gregor Huyskens
on 7/14/13, 5:08 AM

I want to use partner's name from 'partner_ids' field which is a 'many2many' field in the 'partner.ledger.webkit' model, in the attachment prefix for the report 'Partner Ledger Report' example 'object.company_id.name.pdf'. Please help!

evon_dun
on 10/7/13, 3:31 AM

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)

Stats

Asked: 6/7/13, 11:11 AM
Seen: 5864 times
Last updated: 7/10/15, 3:25 AM