Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
13017 มุมมอง

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
User input in cron model แก้ไขแล้ว
3
ก.ค. 19
78
3
ก.ย. 23
5404
Libary managment แก้ไขแล้ว
2
พ.ค. 23
2089
.create() for a Many2many? แก้ไขแล้ว
2
ธ.ค. 18
9628
2
ส.ค. 17
6708