跳至內容
選單
此問題已被標幟
2 回覆
7266 瀏覽次數

How can you do this:

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

In the new API?

頭像
捨棄
最佳答案

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)

頭像
捨棄
最佳答案

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))

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
2月 22
5566
2
9月 15
4621
3
8月 15
8066
0
5月 15
3110
2
11月 23
18661