Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
8605 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ค. 25
4549
2
ธ.ค. 24
7710
How to ORDER BY? [Odoo 10] แก้ไขแล้ว
2
พ.ย. 24
28451
2
พ.ค. 24
7429
3
มี.ค. 24
6851