Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
8070 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 21
11238
0
thg 1 17
2379
1
thg 1 17
2908
0
thg 9 23
41
4
thg 3 23
16811