Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
6969 Prikazi


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
Opusti
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
Opusti
Related Posts Odgovori Prikazi Aktivnost
2
apr. 20
15857
3
dec. 19
5047
1
nov. 24
2860
2
dec. 23
14876
0
okt. 23
33