Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3165 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you very much

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 6 20
31602
1
thg 12 19
4156
2
thg 12 23
14658
0
thg 10 23
33
3
thg 10 23
788