Odoo Help

0

Cron function messing argument!!

By
Mostafa Mohamed Abdel Monaem
on 4/10/15, 11:57 PM 1,676 views

Hi there i try to make cron function to change statues of student but it gives me an error that my function take 5 argument and only 4 given ! i don't know why

here is my function :

def get_age_comp(self, cr, uid,ids ,context={}):
student_ids=self.search(cr, uid,[('gender', '=like', 'm'), ('status', '=like', 'under_Age'),
('birth_date', '<', date.today() - relativedelta(years=20))])
if student_ids:
self.write(cr, uid, student_ids, {'status': 'get_card'}, context=context)
return True

here is my xml to call it :

<record id="ir_cron_actions" model="ir.cron">
                  <field name="name">compare</field>
                  <field eval="True" name="active"/>
                  <field name="user_id" ref="base.user_root"/>
                  <field name="interval_number">1</field>
                  <field name="interval_type">minutes</field>
                  <field name="numbercall">-1</field>
                  <field eval="'fci.student'" name="model"/>
                  <field eval="'get_age_comp'" name="function"/>
                  <field eval="'()'" name="args"/>
              </record>

Thanks

1

Hi,

Its solution is very simple.

In your function defination you have given arguments like : def get_age_comp(self, cr, uid,ids ,context={}) here this function takes 5 arguments but when this function is calling from cron job at that time cron only pass  "self, cr, uid,context=context" 4 arguments.

So, to over come this make your function defination like below.

def get_age_comp(self, cr, uid,ids=None,context={}):

    student_ids=self.search(cr, uid,[('gender', '=like', 'm'), ('status', '=like', 'under_Age'), ('birth_date', '<', date.today() - relativedelta(years=20))])

    if student_ids:

        self.write(cr, uid, student_ids, {'status': 'get_card'}, context=context)

    return True


Great :D solved thanks could i have some help here, i will be thankful :D http://stackoverflow.com/questions/29573912/ovride-write-function

Mostafa Mohamed Abdel Monaem
on 4/11/15, 5:46 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 4/10/15, 11:57 PM
Seen: 1676 times
Last updated: 4/11/15, 5:44 AM