Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
12708 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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,


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
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.
Ảnh đại diện
Huỷ bỏ

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 19
8892
0
thg 9 22
2147
1
thg 8 25
369
2
thg 7 25
2815
3
thg 7 25
630