Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
5 Antwoorden
31651 Weergaven

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

Any kind examples would be appreciated

Avatar
Annuleer
Beste antwoord

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
Annuleer

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

@Yenthe: Its your link in the answer :)

Beste antwoord

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

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
sep. 21
3183
1
dec. 19
4189
2
jan. 19
6620
1
apr. 15
4573
1
mrt. 23
6050