Search code examples
importodooodoo-11

Scheduled Import in Odoo


Is there any way to schedule imports in odoo? Basically i need to import a certain xlsx file in contacts section of odoo every 2 hours.

Since i'm fairly new to python i'm trying to find a way that doesn't involve a lot of coding.

I'm using odoo version 11.0


Solution

  • In Odoo 11.0 You can make "Scheduled Actions".

        <?xml version="1.0" encoding="utf-8"?>
        <odoo>
            <data noupdate="0">
                <record id="scheduler_id" model="ir.cron">
                    <field name="name">Scheduler Name</field>
                    <field eval="True" name="active"/>
                    <field name="user_id" ref="base.user_root"/>
                    <field name="interval_number">2</field>
                    <field name="interval_type">hours</field>
                    <field name="numbercall">-1</field>
                    <field eval="False" name="doall"/>
                    <field name="state">code</field>
                    <field name="model_id" ref="model_name"/>
                    <field name="code">action = env["model.name"].process_scheduler_queue()</field>
                </record>
           </data>
        </odoo>
    **
    

    process_scheduler_queue is function which you have to made in your model's py file, also in that function you need to add your import contacts code,so scheduler will be run at every 2 hours interval and your contacts will be imported.