<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="1">

        <record model="ir.cron" id="ir_cron_import_sale_orders" forcecreate="True">
            <field name="name">Amazon SP - Import Sales Orders</field>
            <field name="active" eval="False"/>
            <field name="state">code</field>
            <field name="user_id" ref="base.user_root"/>
            <field name="interval_number">1</field>
            <field name="interval_type">hours</field>
            <field name="numbercall">-1</field>
            <field name="doall" eval="False"/>
            <field ref="connector_amazon_sp.model_amazon_backend" name="model_id"/>
            <field name="code">model._scheduler_import_sale_orders()</field>
        </record>

        <record model="ir.cron" id="ir_cron_export_product_inventory" forcecreate="True">
            <field name="name">Amazon SP - Export Product Inventory</field>
            <field name="active" eval="False"/>
            <field name="state">code</field>
            <field name="user_id" ref="base.user_root"/>
            <field name="interval_number">8</field>
            <field name="interval_type">hours</field>
            <field name="numbercall">-1</field>
            <field name="doall" eval="False"/>
            <field ref="connector_amazon_sp.model_amazon_backend" name="model_id"/>
            <field name="code">model._scheduler_export_product_inventory()</field>
        </record>

        <record model="ir.cron" id="ir_cron_export_product_price" forcecreate="True">
            <field name="name">Amazon SP - Export Product Price</field>
            <field name="active" eval="False"/>
            <field name="state">code</field>
            <field name="user_id" ref="base.user_root"/>
            <field name="interval_number">24</field>
            <field name="interval_type">hours</field>
            <field name="numbercall">-1</field>
            <field name="doall" eval="False"/>
            <field ref="connector_amazon_sp.model_amazon_backend" name="model_id"/>
            <field name="code">model._scheduler_export_product_price()</field>
        </record>

        <record model="ir.cron" id="ir_cron_queue_job_watchdog" forcecreate="True">
            <field name="name">Amazon SP - Queue Job Watchdog</field>
            <field name="active" eval="True"/>
            <field name="state">code</field>
            <field name="user_id" ref="base.user_root"/>
            <field name="interval_number">10</field>
            <field name="interval_type">minutes</field>
            <field name="numbercall">-1</field>
            <field name="doall" eval="False"/>
            <field ref="connector_amazon_sp.model_amazon_backend" name="model_id"/>
            <field name="code">
# find queue jobs that were started more than X min ago
offset = 60 * 10
now = datetime.datetime.now().replace(microsecond=0)
start = now - datetime.timedelta(seconds=offset)
# uncomment and run manually to see the results
# raise Warning('now: ' + str(now) + ' start: ' + str(start))

jobs = env['queue.job'].search([
  ('state', '=', 'started'),
  ('date_started', '&lt;', str(start)),
  ('channel', 'like', 'amazon'),
  ])

# uncomment and run manually to see the results
# raise Warning(str(jobs))

if jobs:
  jobs.requeue()
            </field>
        </record>

        <record id="excep_wrong_total_amount" model="exception.rule">
            <field name="name">Total Amount differs from Amazon</field>
            <field name="description">The amount computed in Odoo doesn't match with the amount in Amazon.

Cause:
The taxes are probably different between Odoo and Amazon. A fiscal position could have changed the final price.

Resolution:
Check your taxes and fiscal positions configuration and correct them if necessary.</field>
            <field name="sequence">30</field>
            <field name="model">sale.order</field>
            <field name="rule_group">sale</field>
            <field name="code">failed = sale.amazon_bind_ids and abs(sale.amount_total - sale.amazon_bind_ids[0].total_amount) >= 0.01</field>
            <field name="active" eval="True"/>
        </record>

        <record model="ir.actions.server" id="action_submit_product">
            <field name="name">Submit Product</field>
            <field name="model_id" ref="model_amazon_product_product"/>
            <field name="binding_model_id" ref="model_amazon_product_product" />
            <field name="state">code</field>
            <field name="code">
records.button_submit_product()
            </field>
        </record>

        <record model="ir.actions.server" id="action_update_inventory">
            <field name="name">Update Inventory</field>
            <field name="model_id" ref="model_amazon_product_product"/>
            <field name="binding_model_id" ref="model_amazon_product_product" />
            <field name="state">code</field>
            <field name="code">
records.button_update_inventory()
            </field>
        </record>

        <record model="ir.actions.server" id="action_update_price">
            <field name="name">Update Price</field>
            <field name="model_id" ref="model_amazon_product_product"/>
            <field name="binding_model_id" ref="model_amazon_product_product" />
            <field name="state">code</field>
            <field name="code">
records.button_update_price()
            </field>
        </record>

    </data>
</odoo>
