Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
31685 มุมมอง

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

Any kind examples would be appreciated

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง

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

@Yenthe: Its your link in the answer :)

คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 21
3232
1
ธ.ค. 19
4227
2
ม.ค. 19
6662
1
เม.ย. 15
4590
1
มี.ค. 23
6068