İçereği Atla
Menü
Bu soru işaretlendi
5 Cevaplar
4090 Görünümler

Hi, i have problems.

i want to make sequence and make workflow .

i make 2 method : method 'create' and 'proses_aplikan' .

but i don't know , how to call method 'proses_aplikan'.


i make method create , like this :


def create(self, cr, uid, vals, context=None):

obj = self.pool.get('gelombang.pendaftaran').browse(cr, uid, vals['tahun_akademik_id']).name.name.name    

seq_name = 'A/{0}'.format(obj)

seq = self.pool.get('ir.sequence')

ids = seq.search(cr, uid, [('name','=',seq_name)])

if not ids:

prefix = seq_name

ids = seq.create(cr, uid, {

'name':seq_name,

'prefix': prefix,

'padding': 4,

'implementation': 'no_gap',

})

vals['name'] = seq.get_id(cr,uid,ids)

return super(data_aplikan, self).create(cr, uid, vals, context=context)


and method 'proses_aplikan' , like this :


def proses_aplikan(self, cr, uid, ids, context=None):

self.write(cr, uid, ids,{'context':'aplikan'})



How i call method 'proses_aplikan' to use in method 'create'  ?


thanks in advance ...

Avatar
Vazgeç
En İyi Yanıt

instead of:  return super(data_aplikan, self).create(cr, uid, vals, context=context)

save id returned by the create method:

_id = super(data_aplikan, self).create(cr, uid, vals, context=context)

(here you can check if call of create was successfull: if not _id: return _id )

-then you can call proses_aplikan as follows:

 self.proses_aplikan(cr, uid, [ _id ] )

OR:

if isinstance( _id, (int,long)):
    _ids = [ _id ]
else:
    _ids = _id

self.proses_aplikan(cr, uid, _ids )


and finally return the saved id:

return _id

Avatar
Vazgeç
Üretici

Temur, method 'create' don't have parameter 'ids' ... so, i can't use parameter 'ids'

ah, I see.. so you'll need to call it after calling of create() of super class.... let me update the answer

please refer to updated answer

Üretici

it's work ... thank you very much for your solution ..

En İyi Yanıt

try this :

----------------------------------------------------------------------------------------

def create(self, cr, uid, vals, context=None):

obj = self.pool.get('gelombang.pendaftaran').browse(cr, uid, vals['tahun_akademik_id']).name.name.name

seq_name = 'A/{0}'.format(obj)

seq = self.pool.get('ir.sequence')

ids = seq.search(cr, uid, [('name','=',seq_name)])

if not ids:

prefix = seq_name

ids = seq.create(cr, uid, {

                                 'name':seq_name,

                                 'prefix': prefix,

                                 'padding': 4,

                                 'implementation': 'no_gap',

})

vals['name'] = seq.get_id(cr,uid,ids)

res = super(data_aplikan, self).create(cr, uid, vals, context=context)
self.proses_aplikan(cr,uid,res,context=context)

return res

Avatar
Vazgeç
Üretici

wow extraordinary ... it's work Jeng ... thank you ...