Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3159 Vizualizări

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.

Imagine profil
Abandonează

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

Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor

Thank you very much

Related Posts Răspunsuri Vizualizări Activitate
5
iun. 20
31599
1
dec. 19
4148
2
dec. 23
14652
0
oct. 23
33
3
oct. 23
788