コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
8547 ビュー

I need to count record with certain context.My code goes like this

@api.one
def sale_count(self):
count = self.env['sale.order'].search_count([('state', '=', 'sale')])
self.sale_order = count

And I need context as
'search_default_team_id': [active_id],
'default_team_id': active_id,


アバター
破棄
最善の回答
@api.one
def sale_count(self):
count_list = self.env['sale.order'].search([('state', '=', 'sale')])
    count = len(count_list)
self.sale_order = count

Please try this code, its may help you. Thanks.

アバター
破棄
著作者

Thanks for your reply nikhil, I did used this code, and gave me an error TypeError: object of type 'long' has no len().

Then you give the details of your code,

'self.sale_order' - what is the type of this field?,

関連投稿 返信 ビュー 活動
2
7月 25
4501
2
12月 24
7674
2
11月 24
28439
2
5月 24
7414
3
3月 24
6824