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

Hi,

Is it possible to create a record in a model B while creating a record in model A depending on some conditions.

if so, can any one help with the way to do it :)

Thank you.

อวตาร
ละทิ้ง

How to override Odoo functions: https://goo.gl/4BkizH

คำตอบที่ดีที่สุด

Hi,

You can override the create method of the model A and then calling create function of the model B you can create the record.

Sample:

class Model_A(models.Model):
_inherit = 'model.a'

@api.model
def create(self, values):
res = super(Model_A, self).create(values)
vals = {
'field_1': 'test',
'field_2': 'test'
}
self.env['model_b'].create(vals)
return res

Thanks

อวตาร
ละทิ้ง
ผู้เขียน

Thank you very much

Related Posts ตอบกลับ มุมมอง กิจกรรม
override create/write method on odoo 12 แก้ไขแล้ว
5
มิ.ย. 20
31602
1
ธ.ค. 19
4153
Odoo Mail Sending Limit แก้ไขแล้ว
2
ธ.ค. 23
14657
0
ต.ค. 23
33
3
ต.ค. 23
788