Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
5 Odpovědi
31662 Zobrazení

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

Any kind examples would be appreciated

Avatar
Zrušit
Nejlepší odpověď

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
Zrušit

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

@Yenthe: Its your link in the answer :)

Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
zář 21
3195
1
pro 19
4193
2
led 19
6629
1
dub 15
4584
1
bře 23
6058