Skip to Content
Menu
This question has been flagged
9 Replies
41497 Views

i have a problem when executing a method ,

def wtc_approval(self, cr, uid, ids,vals, context=None):
        user = self.pool.get("res.users").browse(cr, uid, uid)['groups_id']
        line = self.browse(cr, uid, ids, context=context)
    
        for x in user:
            if line.app_line.group_id == x :
                line.app_line.write({
                                       'sts':'2',
                                       'pelaksana':uid,
                                       'tanggal':datetime.today()
                                       })
            print "adaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",x
   
        return True

it said

ValueError

Expected singleton: wtc.approval.line(166, 167, 168, 169)

what should i do ?

 

Avatar
Discard

If you use the list of Objects or List in the place of single value python will raise the error. Try use x.id instead of x. Also ensure that print line.app_line.group_id & print x.id should be single values(Not Links or Pointer).

Just an idea: def self.browse() ...

i suppose you are using V8 ?

Hi, please let me know if my answer helps you to solve the problem?

Best Answer

Hi, Ajeng


I have checked the above code and found you are passing "ids" parameter inside "wtc_approval" method and ids parameter may contain more than one ids that's why you are getting this issue. You can write your code like below,

def wtc_approval(self, cr, uid, ids,vals, context=None):
        user = self.pool.get("res.users").browse(cr, uid, uid)['groups_id']
        lines = self.browse(cr, uid, ids, context=context)
    
        for x in user:    
            for line in lines:
                if line.app_line.group_id == x :
                    line.app_line.write({
                                           'sts':'2',
                                           'pelaksana':uid,
                                           'tanggal':datetime.today()
                                           })
            print "adaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",x
        return True

Feel free to ask in case you still have the same issue.

Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited
Avatar
Discard
Best Answer

hi,

here you have to itereate line because it contains more than one record. Thats reason for Error

Avatar
Discard
Best Answer

Hola resolvi el problema para esto dirigete a mi pagina ahi explico como hacer algo similar.

@api.multi

def onchange_get_organizer_account(self,auxType):

if auxType:

ids=self.env['gol.organizer.account'].search([['organizerType', '=', auxType]])

auxIds=[]

for item in ids:

auxIds.append(item.id)

print ids

print auxIds

return {'domain':{'organizerAccount':[('id','in',auxIds)]}}

@api.onchange('organizerAccount','code')

def getCode(self):

if self.organizerAccount:

self.code=self.organizerAccount.code



Para mayor informacion accede ami pagina eln la cual descrivo con mayor detenimiento


https://github.com/Leningsv/Odoo/wiki/Dominios,-Busquedas-(env,-browse,-search),-Filtros,-Agrupamientos

Avatar
Discard

WHAT ? govorish pa Angliski tovorishch ?

Related Posts Replies Views Activity
2
Oct 18
3429
1
Oct 17
3688
1
Mar 15
4235
2
Mar 15
6220
2
Apr 23
3563