コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
13047 ビュー

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


アバター
破棄
最善の回答

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

アバター
破棄
著作者

Thank you Ayam

最善の回答

Thank you, this helped.

アバター
破棄
関連投稿 返信 ビュー 活動
3
7月 19
78
3
9月 23
5414
2
5月 23
2099
2
12月 18
9642
2
8月 17
6729