تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
5 الردود
31628 أدوات العرض

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).

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
سبتمبر 21
3175
1
ديسمبر 19
4175
2
يناير 19
6614
1
أبريل 15
4570
1
مارس 23
6043