Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
9 Odpovědi
41727 Zobrazení

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
Zrušit

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?

Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

hi,

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

Avatar
Zrušit
Nejlepší odpověď

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
Zrušit

WHAT ? govorish pa Angliski tovorishch ?

Related Posts Odpovědi Zobrazení Aktivita
2
říj 18
3662
1
říj 17
3919
1
bře 15
4405
2
bře 15
6441
2
dub 23
3848