Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
13031 Visualizzazioni

How to call a create method from other methods.

@api.model def process_demo_scheduler_queue(self):
        print "at the top"
        self.test1(1)

       _logger.info("here")
        print "at bottom"


 @api.noguess

@api.model def test1(self,vals):
        print "ki"

       attachment = super(scheduler_demo, self).create(vals)

       print attachment

       return attachment

This code not working. Any help??


Avatar
Abbandona
Risposta migliore

dear Annadurai,


if you need to call create method within a same model just you can use :

self.create(vals)

vals is a dictionary have keys and values for required fields at least like this:
vals= {'field1':value, 'field2': value}

if you need to call create method from another model just you must declare object with this model and call create method like this:

model2_obj= self.env['model2.model2']
model2_obj.create(vals)


 I hope i helped you....

Avatar
Abbandona
Autore

Thank you Ayam

Risposta migliore

Thank you, this helped.

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
lug 19
78
3
set 23
5412
2
mag 23
2096
2
dic 18
9638
2
ago 17
6719