Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How call method ?

By
heru
on 3/31/15, 5:43 AM 475 views

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 ...

1

Temur

--Temur--
2894
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 3/31/15, 5:59 AM

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

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

heru
on 3/31/15, 6:18 AM

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

Temur
on 3/31/15, 6:46 AM

please refer to updated answer

Temur
on 3/31/15, 6:57 AM

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

heru
on 3/31/15, 12:08 PM
0
Ajeng Shilvie
On 3/31/15, 9:06 AM

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

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

heru
on 3/31/15, 12:03 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/31/15, 5:43 AM
Seen: 475 times
Last updated: 3/31/15, 12:23 PM