在odoo中有一个比较有意思的装饰器,可以对底层框架打补丁,如果用得好,可以大大增加odoo的灵活性。
该装饰器定义的位置 :
addons/base_sparse_field/models/fields.py中第8行:
def monkey_patch(cls):
""" Return a method decorator to monkey-patch the given class. """
def decorate(func):
name = func.__name__
func.super = getattr(cls, name, None)
setattr(cls, name, func)
return func
return decorate