跳至内容
菜单
此问题已终结
9 回复
42054 查看

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 ?

 

形象
丢弃

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?

最佳答案

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
形象
丢弃
最佳答案

hi,

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

形象
丢弃
最佳答案

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

形象
丢弃

WHAT ? govorish pa Angliski tovorishch ?

相关帖文 回复 查看 活动
2
10月 18
3978
1
10月 17
4222
1
3月 15
4659
2
3月 15
6739
2
4月 23
4255