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

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
6月 20
31600
1
12月 19
4151
2
12月 23
14656
0
10月 23
33
3
10月 23
788