Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
5 Răspunsuri
31639 Vizualizări

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

Any kind examples would be appreciated

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează

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

@Yenthe: Its your link in the answer :)

Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
sept. 21
3179
1
dec. 19
4181
2
ian. 19
6617
1
apr. 15
4571
1
mar. 23
6044