Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
8679 Lượt xem

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,


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
@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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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?,

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 25
4596
2
thg 12 24
7759
2
thg 11 24
28515
2
thg 5 24
7468
3
thg 3 24
6902