I want to override a function called 'user_has_groups' in the class from the file openerp/models.py (line no 1365),
from openerp.models import BaseModel
def my_user_has_groups(self, cr, uid, groups, context=None):
#my code
BaseModel.user_has_groups = my_user_has_groups
But it says the following error
TypeError: my_user_has_groups() takes at least 4 arguments (2 given)
and also i tried this line
BaseModel.user_has_groups = lambda cr, uid, groups, context: my_user_has_groups(cr, uid, groups, context)
and now the error is
QWebException: <lambda>() got multiple values for keyword argument 'groups'
How I can achieve this? Please enlighten me.
I've cleaned up your question since the code was a mess and full of '\' characters. Know that a nicely formatted question will get you more reactions :)
I suggest looking at the environment. Looks like an issue with the passing of the cr and uid. Perhaps you could try passing them to the my_user_has_groups explicitly. Something like: BaseModel.user_has_groups = my_user_has_groups(self, cr, uid, context=none) Either that or try converting the whole environment context to the new model. I am not entirely sure how to achieve this though. Refer to the ORM on api changes: The big differences between the old and new APIs are: values of the Environment (cursor, user id and context) are passed explicitly to methods instead
@Yenthe.. thanks bro..
@Mai Ecarde Thanks for the reply.. Now I tried this code BaseModel.user_has_groups = lambda cr, uid, groups, context: my_user_has_groups(cr, uid, groups, context) But results the following error QWebException: () got multiple values for keyword argument 'groups'