Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
12741 Vizualizări

hello 

i want to know what is active id and what is the use of active id 


how can i print the active id 

i add one many 2 one field res.partner

and now i add smart button which give me the sale order which res.partner i selected.


my problem is it will give me the all of the sale order but i want only sale order which res.partner i selected.

any one can help me!

thank you in advance


Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

active_id is the current record's id. You can get the active_id from the context as this:
active_id =  self.env.context.get('active_id')

The use cases are explained in this video in detail Active Id In Odoo Development


And for getting sale orders of the partner selected try this solution:

In your python file:


partner_id = fields.Many2one('res.partner', string='Customer')

def get_sale_orders(self):
return {
'name': _('Sale Orders'),
'type'
: 'ir.actions.act_window',
'res_model'
: 'sale.order',
'view_mode'
: 'kanban,tree,form',
'domain'
: [('partner_id', '=', self.partner_id.id)],
}

In your xml file define the button(type=object) and partner_id field:

Pass the domain: 

'domain': [('partner_id', '=', self.partner_id.id)] , while returning from the button function

Thank you

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
oct. 22
3193
3
oct. 22
12140
1
dec. 23
1490
0
sept. 22
2281
0
apr. 22
2732