Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
7254 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
úno 22
5552
2
zář 15
4614
3
srp 15
8063
0
kvě 15
3109
2
lis 23
18653