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

HI,

Since delegation inheritance does not inherits methods how would I call a method from the model I have inherited from in my new model?

Thanks,

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

Robert explicitly asks about delegation inheritance which indeed does not inherit methods (and it's a problem). But you instead talk about Traditional inheritance which does inherit methods and so requires no explanation.

FYI:
delegation inheritance: Product => Template:

_inherits = {'product.template': 'product_tmpl_id'}

traditional inheritance: Template => mail.thread:

_inherit = ['mail.thread']
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I think you got little confused here,

Delegation Inheritance will inherit methods too.

you just need to call it using self.METHOD_NAME


Best example is mail.thread object which would have been inherited in almost the main objects, So if you notice method message_post is actually defined in mail.thread, while its child class can simply call the method the way it calls its own method

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