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

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
أغسطس 19
8886
0
سبتمبر 22
2146
1
أغسطس 25
363
2
يوليو 25
2809
3
يوليو 25
630