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

How would you code this using the new API? (this is an actual excerpt from /addons/stock/wizard/stock_transfer_details.py):

def default_get(self, cr, uid, fields, context=None):
if context is None: context = {}
res = super(stock_transfer_details, self).default_get(cr, uid, fields, context=context)
picking_ids = context.get('active_ids', [])
active_model = context.get('active_model')


Thanks

形象
丢弃
最佳答案

Hello EM,


Please try below code:-


@api.model

def default_get(self, fields):

    res = super(stock_transfer_details, self).default_get(fields)

    picking_obj = self.env['stock.picking'].browse(self._context.get('active_id'))    

     active_model = self._context.get('active_model')


Hope this will helps you.

Thanks,


形象
丢弃
最佳答案
def default_get(self, fields):
    if self._context is None: self._context = {}
    res = super(stock_transfer_details, self).default_get(fields)
    picking_ids = self._context.get('active_ids', [])
    active_model = self._context.get('active_model')

Please try this one and let me know.
形象
丢弃

I missed out 'self' in definition of function, thanks to Jignesh!

相关帖文 回复 查看 活动
1
8月 19
8912
0
9月 22
2169
1
8月 25
382
2
7月 25
2829
3
7月 25
636