콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
8402 화면

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

아바타
취소
베스트 답변

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

관련 게시물 답글 화면 활동
1
11월 21
11666
0
2월 17
2547
1
1월 17
3160
0
9월 23
41
4
3월 23
17203