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.

1

How do you move an ID to a transient wizard model?

By
E.M.
on 2/12/16, 4:27 AM 701 views

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?

1

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

}

 

0
Krupesh Laiya
On 2/12/16, 4:32 AM

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

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

E.M.
on 2/12/16, 4:43 AM

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.

Krupesh Laiya
on 2/13/16, 6:04 AM
0
E.M.
On 2/12/16, 12:18 PM

[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.

-1
Jose M. González
On 2/12/16, 5:19 AM

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 !!!

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.

E.M.
on 2/12/16, 5:29 AM

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 ...

Jose M. González
on 2/12/16, 5:36 AM

I get context is not defined.

E.M.
on 2/12/16, 5:52 AM

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.

E.M.
on 2/12/16, 5:57 AM

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

Jose M. González
on 2/15/16, 2:49 AM

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: 2/12/16, 4:27 AM
Seen: 701 times
Last updated: 2/15/16, 2:49 AM