تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
9 الردود
8876 أدوات العرض

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
فبراير 16
8622
3
يونيو 19
5215
1
مارس 15
6802
3
فبراير 24
12591
2
أغسطس 22
8864