Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
3151 Visualizzazioni

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.

Avatar
Abbandona

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

Risposta migliore

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

Avatar
Abbandona
Autore

Thank you very much

Post correlati Risposte Visualizzazioni Attività
5
giu 20
31592
1
dic 19
4140
2
dic 23
14645
0
ott 23
33
3
ott 23
788