Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
19867 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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!

Powiązane posty Odpowiedzi Widoki Czynność
2
wrz 15
6883
1
lut 24
1961
0
lip 24
3003
0
lut 23
2011
0
lip 22
60