Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
7972 Tampilan

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

Avatar
Buang
Jawaban Terbai

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


Avatar
Buang
Penulis

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

Post Terkait Replies Tampilan Aktivitas
1
Nov 21
11139
0
Jan 17
2288
1
Jan 17
2833
0
Sep 23
41
4
Mar 23
16706