Skip to Content
Menu
This question has been flagged
2 Replies
6335 Views

How can you do this:

_defaults = { 'sale_order_id': lambda self, cr, uid, context: context.get('sale_order_id', False), }

In the new API?

Avatar
Discard
Best Answer

You can use it while defining new field:

 user_id = fields.Many2one('res.users', string='Salesperson', track_visibility='onchange',

readonly=True, states={'draft': [('readonly', False)]},

default=lambda self: self.env.user)

Avatar
Discard
Best Answer

In new API, you can define default at field level.

Try this:

sale_order_id = fields.Many2one('sale.order', default=lambda self: self.env.context.get('sale_order_id', False))

Avatar
Discard
Related Posts Replies Views Activity
2
Feb 22
4288
2
Sep 15
3288
3
Aug 15
6895
0
May 15
2244
2
Nov 23
16911