Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
3149 Visualizações

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
Cancelar

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

Melhor resposta

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
Cancelar
Autor

Thank you very much

Publicações relacionadas Respostas Visualizações Atividade
5
jun. 20
31591
1
dez. 19
4133
2
dez. 23
14645
0
out. 23
33
3
out. 23
788