跳至内容
菜单
此问题已终结
9 回复
8871 查看

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?

形象
丢弃
最佳答案

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

}

 

形象
丢弃
最佳答案

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

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.

编写者 最佳答案

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

形象
丢弃
最佳答案

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.

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

编写者

I get context is not defined.

编写者

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 = {} ....

相关帖文 回复 查看 活动
2
2月 16
8616
3
6月 19
5205
1
3月 15
6793
3
2月 24
12579
2
8月 22
8856