Skip to Content
Menu
This question has been flagged
5 Replies
31632 Rodiniai

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

Any kind examples would be appreciated

Portretas
Atmesti
Best Answer

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

Portretas
Atmesti

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

@Yenthe: Its your link in the answer :)

Best Answer

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

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
1
rugs. 21
3177
1
gruod. 19
4176
2
saus. 19
6614
1
bal. 15
4571
1
kov. 23
6043