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

I want to pass an ID to a transient wizard model.

This is the code to launch the wizard-popup:


# -*- coding: utf-8 -*-

from openerp import models, fields, api

class StockPicking(models.Model):

_inherit = "stock.picking"

@api.multi

def view_tree_label_picking(self):

return {

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

'name': 'view_tree_label_picking',

'view_type': 'tree',

'view_mode': 'tree',

'res_model': 'label.picking', 

'target': 'new',

}

How do I pass the current stock_picking ID to the transient model?

Imagine profil
Abandonează
Cel mai bun răspuns

you can use this,

see this link: https://github.com/odoo/odoo/blob/9.0/addons/account/models/account_bank_statement.py#L213

return {

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

'name': 'view_tree_label_picking',

'view_type': 'tree',

'view_mode': 'tree',

'res_model': 'label.picking', 

'context': {},

'target': 'new',

}

 

Imagine profil
Abandonează
Cel mai bun răspuns

in context you can pass the current object id or in context itself have the active_id and active_model in pop wizard

Imagine profil
Abandonează
Autor

Could you please further elaborate? Is that following new or old API? Thanks

in new api you can access active id directly self._context.get('active_id') and in old api you can access directly context.get('active_id') where context is the function parameter.

Autor Cel mai bun răspuns

[UPDATE] Despite some colleagues have tried to answer I am still not being able to move the ID from the form to the wizard transient model. I am missing something, thanks anyway for your help. Anyone willing to give a more detailed solution please do, as this not solved yet.

Imagine profil
Abandonează
Cel mai bun răspuns

hi, 

Reference to this post: 

https://www.odoo.com/es_ES/forum/help-1/question/developing-a-new-popup-in-stock-picking-basic-doubts-about-how-to-generate-the-popup-97625

with that question I have also fought x-D with this code:

   context.update({ 'tipo_entrega' : 'ok_con_incidencias', 'delivery_line_id': value that you want, }) 
you can pass the info in the context to popup because you add param 'context':
context ( see -> #python desde donde lanza la acción del botón).

And you obtain the pass value in this line:
record_id = context.get('delivery_line_id') ( see -> #modelo temporal para popup.)

May the Force be with you !!!

Imagine profil
Abandonează
Autor

Thanks, just to gain a better understanding on how development works in Odoo, is the way you suggest following the new or the old API? I am sometimes puzzled on how both APIs are mixed together.

If I'm honest I also do blends between the new and the old api api ... and I venture to say that most people do ... :-) I think the balance is the best way ...

Autor

I get context is not defined.

Autor

New API is reasonablily well documented, old one is not. It is a big issue if you start doing things without fully understanding what you do.

I get context is not defined error?. Try to add this: if context is None: context = {} ....

Related Posts Răspunsuri Vizualizări Activitate
2
feb. 16
8714
3
iun. 19
5348
1
mar. 15
6964
3
feb. 24
12727
2
aug. 22
9050