콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
5 답글
31803 화면

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
3318
1
12월 19
4354
2
1월 19
6798
1
4월 15
4666
1
3월 23
6231