Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

default_get in the new API, how?

By
E.M.
on 2/12/16, 12:14 PM 1,419 views

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

3

Jignesh Mehta

--Jignesh Mehta--
2081
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 2/13/16, 6:25 AM

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,


0
Priyesh
On 2/12/16, 6:33 PM
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!

Priyesh
on 2/13/16, 10:57 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/12/16, 12:14 PM
Seen: 1419 times
Last updated: 2/13/16, 6:25 AM