Skip to Content
Menu
This question has been flagged
1 Reply
5906 Views


I want to set ir.cron job but by default it is getting Odoobot as a user but I want to set logged in User as a ir.cron job user by default.

Because each user has his own token, so, while running scheduler, it gets none instead of token because the scheduler user is Odoobot.

Note:
As we can change user from scheduler in technical setting, in this case the other user also get the token of scheduler user. or we can create scheduler for each user separately. is there any way to handle this in a single scheduler.
I want just create a generic scheduler which work for each user.
<record id="office365_cron_do_tasts_import" model="ir.cron">
        <field name="name">Auto Office365 tasks import</field>
        <field name="model_id" ref="model_sync_office365"/>
        <field name="state">code</field>
        <field name="active">0</field>
        <field name="code">model.auto_import_tasks()</field>
        <field name='interval_number'>5</field>
        <field name="user_id" ref="base.user_root"/>
        <field name='interval_type'>minutes</field>
        <field name="numbercall">-1</field>
    </record>


Avatar
Discard
Best Answer

Nope, there is no way single schedule can run on behalf of multiple users.
but run single scheduler as Admin (odoobot) and change the method auto_import_tasks where first search all the user from res.user and run your login behalf of the user like

for user in users:
      self.sudo(user).import_office_task()   ​     ​   ​    ​   ​      ​   ​    ​   ​     ​   ​    ​   ​       ​   ​    ​   ​     ​   ​    ​   ​      ​   ​    ​   ​     ​   ​    ​   ​

Avatar
Discard
Related Posts Replies Views Activity
2
Apr 20
13961
3
Dec 19
4259
1
Nov 24
1804
2
Dec 23
12010
0
Oct 23
33