콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3270 화면

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
31755
1
12월 19
4299
2
12월 23
14831
0
10월 23
33
3
10월 23
788