Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
5 Odpowiedzi
31679 Widoki

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

Any kind examples would be appreciated

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć

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

@Yenthe: Its your link in the answer :)

Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
wrz 21
3221
1
gru 19
4219
2
sty 19
6656
1
kwi 15
4590
1
mar 23
6064