Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
3225 Tampilan

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.

Avatar
Buang

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

Jawaban Terbai

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

Avatar
Buang
Penulis

Thank you very much

Post Terkait Replies Tampilan Aktivitas
5
Jun 20
31685
1
Des 19
4224
2
Des 23
14721
0
Okt 23
33
3
Okt 23
788