7

In Odoo one can extend or include on a class (in Javascript). What is the difference in Odoo between extend and include?

1 Answers1

21

When you extend, instances from the parent class remain untouched, but instances from the new child class will have the extended features.

OTOH, when you include, you are adding the new features to the prototype of the parent class, which means that automatically all instances of such class include the extended behavior.


You know, JS works with prototypes; i wrote about class and instance just to make it easier to understand.

Yajo
  • 5,808
  • 2
  • 30
  • 34
  • 1
    Thank You for the answer! :) – Developer Marius Žilėnas Apr 18 '18 at 07:09
  • "include" is a very powerfull feature that should never be included. ;-) If two modules take a common parent to create their widgets, One could change the behavior of the other, that was made only knowing parent. – yucer Apr 06 '20 at 18:20
  • Actually the point is that you should always `return this._super.apply(this, arguments)` to avoid that problem. But the whole odoo ecosystem drains its power from monkey-patching itself, so `include` instead that never being used, it should be used wisely. – Yajo Apr 07 '20 at 10:48