Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
5 Replies
31437 Tampilan

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

Any kind examples would be appreciated

Avatar
Buang
Jawaban Terbai

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
Buang

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

@Yenthe: Its your link in the answer :)

Jawaban Terbai

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Sep 21
3043
1
Des 19
4033
2
Jan 19
6429
1
Apr 15
4447
1
Mar 23
5919