Ir al contenido
Menú
Se marcó esta pregunta
9 Respuestas
42014 Vistas

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
Descartar

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?

Mejor respuesta

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
Descartar
Mejor respuesta

hi,

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

Avatar
Descartar
Mejor respuesta

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
Descartar

WHAT ? govorish pa Angliski tovorishch ?

Publicaciones relacionadas Respuestas Vistas Actividad
2
oct 18
3938
1
oct 17
4177
1
mar 15
4627
2
mar 15
6701
2
abr 23
4199