跳至内容
菜单
此问题已终结
1 回复
8564 查看

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
4511
2
12月 24
7683
2
11月 24
28442
2
5月 24
7419
3
3月 24
6832