Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
19870 Vues

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

Avatar
Ignorer
Meilleure réponse

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

Avatar
Ignorer
Auteur

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 ?

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'),

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!

Publications associées Réponses Vues Activité
2
sept. 15
6884
1
févr. 24
1961
0
juil. 24
3004
0
févr. 23
2011
0
juil. 22
60