NaGeL182
NaGeL182

Reputation: 904

Openerp scheduler method with arguments: How to create them?

I created a new Module for OpenERP 7.0 which basically is a placeholder for a scheduler action.

Now when I created my method with this:

def _method_name(self, cr, uid):

It worked fine. But I need some extra arguments to it. I used this:

def _method_name(self, cr, uid, arg1, arg2, arg3, arg4):

This should work, right? Frankly I have no idea. Also I don't know what to write in the Openerp's scheduler action's argument line. Do I need to pass self, cr, uid as well? Or is it enough to pass my own?

Upvotes: 1

Views: 2755

Answers (1)

Yajushi
Yajushi

Reputation: 1185

Explanation for self, cr, uid params:

self - It is Python concept, "self" in python refers to the instance variable. It is a reference to the current object. It is equivalent to "this" in other languages.

cr - current database cursor in openerp, used in openerp for builtin methods like search, write etc. we need to pass this param for the built in methods which required it in their schema.

uid - logged in user id, required to manage rules and access rights.

  • self is required one

  • for normal functions cr and uid are optional parameters.

  • but as per the ir.cron object schema, it requires cr and uid parameters in scheduler method (In ver 6 not sure for ver 7)

you can add extra parameters using variables or positional args or keyword args.

If possible define variable with default values.

E.g :

def run_scheduler(self, cr, uid, arg1=False, arg2=False, context=None, kargs*):
    #your code here

Hope, it could help.

Upvotes: 3

Related Questions