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.

0

How to open a popup view its active_id value?

By
James Ford
on 3/22/16, 12:05 PM 397 views

Hey guys, I'm creating a button that opens a popup , but the view you want to open has different functions and the only way to differentiate is with the active_id attribute that appears in the URL. I mean, I want to open the stock.picking.form view, but this view has 3 different functions. It is the same view for three different functions. As shown in the figure below :

http://es.zimagez.com/zimage/inventario0.php

This is a URL of stock.picking.form active_id=2: http://localhost:8069/web?&debug=#view_type=form&model=stock.picking&action=250&active_id=2

I want to open the view that has active_id = 2 . How I can open this view popup ? This is the code of the function of the button:

@api.multi

def action_stock_picking(self):

self.ensure_one()

picking_form = self.env.ref('stock.view_picking_form', False)

ctx = dict(

default_model='stock.picking',

default_res_id=self.id,

default_composition_mode='comment',

mark_invoice_as_sent=True,

)

return {

'name': _('Formulario de Inventario: Recepciones'),

'type': 'ir.actions.act_window',

'view_type': 'form',

'view_mode': 'form',

'res_model': 'stock.picking',

'views': [(picking_form.id, 'form')],

'view_id': picking_form.id,

'target': 'new',

'context': ctx,

}

And this button code in the view.xml:

<button name="action_stock_picking" string="Inventario" type="object" icon="fa-arrow-right"/>

Thanks for all , I appreciate any help to solve this problem. Thanks.

0

Temur

--Temur--
2894
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 3/22/16, 12:37 PM


add "res_id" entry in the returned dictionary, set value of this entry to the id of the record you want to open..


some_id = self.id # OR context.get('active_id'), OR whatever id you want to open
return {
'name': _('Formulario de Inventario: Recepciones'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'stock.picking',
'res_id': some_id, 
'views': [(picking_form.id, 'form')],
'view_id': picking_form.id,
'target': 'new',
'context': ctx,
}

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: 3/22/16, 12:05 PM
Seen: 397 times
Last updated: 3/22/16, 12:37 PM