Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
8558 Visualizzazioni

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,


Avatar
Abbandona
Risposta migliore
@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.

Avatar
Abbandona
Autore

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

Post correlati Risposte Visualizzazioni Attività
2
lug 25
4509
2
dic 24
7680
2
nov 24
28442
2
mag 24
7418
3
mar 24
6830