Odoo Help

1

many2many relation syntax

By
omprakash
on 6/7/13, 11:11 AM 6,774 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
923
| 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

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: 6/7/13, 11:11 AM
Seen: 6774 times
Last updated: 7/10/15, 3:25 AM