-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (34 loc) · 1.15 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import models
class A(models.Model):
_name = 'ica.a' # Define _inherit to specify the class to be inherited dynamically
def abc_method(self):
print("A Method in ABC")
def origin_method(self):
print("Origin Method in ABC")
class B(models.Model):
_inherit = 'ica.a' # Define _inherit to specify the class to be inherited dynamically
def abc_method(self):
super(B, self).abc_method()
print("B Method in ABC")
class C(models.Model):
_name = 'ica.c'
_inherit = 'ica.a' # Define _inherit to specify the class to be inherited dynamically
def abc_method(self):
super(C, self).abc_method()
print("C Method in ABC")
def c_class_only_method(self):
print("c class only method")
if __name__ == '__main__':
print(models.env)
# {'ica.a': <class '__main__.B'>, 'ica.c': <class '__main__.C'>}
icaC = models.env['ica.c']()
# icaC.abc_method()
# A Method in ABC
# B Method in ABC
# C Method in ABC
icaA = models.env['ica.a']()
icaA.abc_method()
# A Method in ABC
# B Method in ABC
icaC.origin_method()
icaC.c_class_only_method()