How to override method of BaseModel (openerp/models.py) in odoo v9?

拈花ヽ惹草 提交于 2019-12-06 14:16:06

I solved this in another way around, which is given below

from openerp import models, api
class BaseModelExtend(models.AbstractModel):
   _name = 'basemodel.extend'

   def _register_hook(self, cr):            
      @api.cr_uid_context
      def user_has_groups(self, cr, uid, groups, context=None):
         #My code
      models.BaseModel.user_has_groups = user_has_groups
      return super(BaseModelExtend, self)._register_hook(cr)
JeyChou
from openerp.models import BaseModel,api

@api.guess
def my_user_has_groups(self, cr, uid, groups, context=None):
    # your code

BaseModel.user_has_groups = my_user_has_groups
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!