Odoo Help

Welcome!

This community 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.

0

scheduled actions not working?

By
Jothimani
on 6/3/14, 9:03 AM 3,098 views

Hello everyone,

I wrote a Scheduler actions like below, but not working...

in crm_lead.py

    def compute_lead_type(self, cr, uid, ids, name, args, context=None):
        for record in self.browse(cr, uid, ids, context=context):
            lead_type=record.type
            lead_id=record.id
           
            if lead_type=='lead':           #   Checks the lead ID is converted to opportunity or not
                lead_crm_phonecall_id = self.pool.get('crm.phonecall').search(cr, uid, [('opportunity_id', '=', lead_id)], context=context) #   Checks the lead is scheduled or not
    
                if lead_crm_phonecall_id:   #   Checks the lead ID is available or not in crm.phonecall
                    message_text='This Lead is scheduled'
                else:
                    message_text='This Lead is Not scheduled'
    
                    message = _('Hello this is testing')                
                    self.message_post(cr, uid, [lead_id], message, context=context)
    
        return

in crm_lead_view.xml

        <record forcecreate="True" id="ir_cron_scheduler_checking_lead"
            model="ir.cron">
            <field name="name">Checking status of lead</field>
            <field eval="True" name="active" />
            <field name="interval_number">1</field>
            <field name="interval_type">minutes</field>
            <field name="numbercall">-1</field>
            <field eval="False" name="doall" />
            <field eval="'crm.lead'" name="model" />
            <field eval="'compute_lead_type'" name="function" />
            <field eval="'()'" name="args" />
        </record>

This is not working, please help me,

thanks in advance...

i am using v7

Jothimani
on 6/4/14, 1:53 AM
3
Yogesh
On 6/5/14, 1:28 AM

It is not working because you are doing it worng. You do not have value of ids while running cron job so you need to assign it False. Change your method defination like

 

def compute_lead_type(self, cr, uid, ids = False, name, args, context=None):    
         search_ids = self.pool.get('object.name').search(cr, uid, []) 
         for ids in search_ids:     
              #  write your logic here      

return True

        

 

 

and it will start working. sometimes if it doesn't start. go to scheduler menu click on edit button of scheduler and save it again. it will start working :)

1
Dwight Butler
On 10/3/14, 8:51 AM

I too am having the same problem with scheduled actions not working in version 8, with both time zones set to UTC.

1
Richard
On 6/3/14, 11:19 AM

Which version are you using? I am also having difficulty with all scheduled actions in any version after v7.

0
Dairidi
On 4/24/15, 8:55 AM

You can also write ids=None and it will work

0

I think you need to pass "ids" argument's value from cron record. Because from your code's first line,

for record in self.browse(cr, uid, ids, context=context):

If program doesn't find ids then it will skip that loop. That's why your program doesn't working !

Still let me know anything is still confusing.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 6/3/14, 9:03 AM
Seen: 3098 times
Last updated: 4/24/15, 8:55 AM