コンテンツへスキップ
メニュー
この質問にフラグが付けられました
5 返信
31652 ビュー

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
9月 21
3185
1
12月 19
4189
2
1月 19
6621
1
4月 15
4574
1
3月 23
6051