Ir al contenido
Menú
Se marcó esta pregunta
5 Respuestas
31655 Vistas

How to override create/write method and call your function during this methods?

Any kind examples would be appreciated

Avatar
Descartar
Mejor respuesta

Hi,

You can override the create and write method as follows,

Inherit the corresponding model first, then


from odoo import models, fields, api
 
class ResPartner(models.Model):
    _inherit = 'res.partner'

    @api.model
    def create(self, values):
        res = super(ResPartner, self).create(values)
        # here you can do accordingly
        return res


    @api.multi
    def write(self, values):
        res = super(ResPartner, self).write(values)
        # here you can do accordingly
        return res


For more you can check this: https://www.odoo.yenthevg.com/override-create-functions-odoo/

Thanks

Avatar
Descartar

+1, accepted your answer. Thanks for the good answer.

@Yenthe: Its your link in the answer :)

Mejor respuesta

what happend when i do not return res. just use res = super(ResPartner, self).write(values).

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 21
3187
1
dic 19
4190
2
ene 19
6622
1
abr 15
4576
1
mar 23
6052