Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
3146 Переглядів

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

Related Posts Відповіді Переглядів Дія
5
черв. 20
31590
1
груд. 19
4126
Odoo Mail Sending Limit Вирішено
2
груд. 23
14644
0
жовт. 23
33
3
жовт. 23
788