Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
5 Trả lời
31581 Lượt xem

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

Any kind examples would be appreciated

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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

@Yenthe: Its your link in the answer :)

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 21
3142
1
thg 12 19
4114
2
thg 1 19
6570
1
thg 4 15
4549
1
thg 3 23
6017