Search code examples
cronwarningsodooodoo-8

Raise warning in cron method


I have created a cron which executes a method. Now in that method i want to raise a warning if some value is missing.

Right now my method raise warning(tried Warning and except_orm) but it will log warning to terminal only no warning message appear on GUI.

Am i missing something?

Here is sample code:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="ir_cron_test_warning" model="ir.cron">
            <field name="name">Test Warning</field>
            <field name="interval_number">1</field>
            <field name="interval_type">minutes</field>
            <field name="numbercall">1</field>
            <field name="active" eval="True"/>
            <field name="model">test.warning</field>
            <field name="function">test_warning_exception</field>
            <field name="args">()</field>
        </record>
    </data>
</openerp>

Method:

class test_warning(models.Model): _name = 'test.warning'

@api.model
def test_warning_exception(self):
    aurl = self.env['ir.config_parameter'].get_param('my_path')
    if not aurl:
        raise Warning(_('Please add mypath to System Parameters1111'))

Regards,


Solution

  • errors and warnings from the cron job will be bypassed by the orm. so you should either make sure only the correct data is taken in the cron function or it should be avoided.