Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
9 Vastaukset
41992 Näkymät

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
Hylkää

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?

Paras vastaus

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
Hylkää
Paras vastaus

hi,

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

Avatar
Hylkää
Paras vastaus

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
Hylkää

WHAT ? govorish pa Angliski tovorishch ?

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
lokak. 18
3924
1
lokak. 17
4164
1
maalisk. 15
4609
2
maalisk. 15
6683
2
huhtik. 23
4186