تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3148 أدوات العرض

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
5
يونيو 20
31591
1
ديسمبر 19
4133
2
ديسمبر 23
14645
0
أكتوبر 23
33
3
أكتوبر 23
788