This question has been flagged
3 Replies
3308 Views

hi i have my module in which i am allocating asset to employee and employee will return that asset in specific time duration, i want that when there is 2 days left in returning that asset so automatically employee gets alert through email how i can do this in open erp v 7

Avatar
Discard
Best Answer

You can use schedulers to send the alert automatically. First create a scheduler in your module, name the file as scheduler_data.xml and add the following in it.

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

        <record forcecreate="True" id="ir_cron_check_shipping_date" model="ir.cron">
            <field name="name">Asset Reminder</field>
            <field eval="True" name="active" />
            <field eval="False" name="doall" />
            <field name="user_id" ref="base.user_root" />
            <field name="interval_number">1</field>
            <field name="interval_type">days</field>
            <field name="numbercall">-1</field>
            <field eval="your.model.name'" name="model" />
            <field eval="'check_asset_date'" name="function" />
            <field eval="'(False,)'" name="args" />
        </record>
       </data>
</openerp>

In the above, in model field specify the model name (I have given it as your.model.name, replace it with your model name). You can configure the scheduler to execute depending on the intervals available, say days, months, weeks, hours, minutes etc in above code or client side. If you make any changes in client side, it will stay unchanged even if you upgrade the module, because noupdate="1" is set. Then define the email template for the email to be send, you can configure the template in client side or in xml code. Now you need to define the method check_asset_date in your model.

def check_asset_date(self, cr, uid, ids, context+None):
           # Your code to check date goest here
           # Then call the send_mail method of model email.template with desired parameters and you must pass
          # your email template's id by searching and finding the id of the template.
          return True
Avatar
Discard
Best Answer

Hello Bakhtawar,

You just need to write a method to check your condition of date.

In that method you need to create one email template regarding your mail body.

Call that method in scheduler.

Avatar
Discard
Author Best Answer

thanks alot but i have confusion that can i make it through interface of open erp v 7 because it has options of emial , server , scheduler . i have watched a video on youtube in which through automated action and scheduler he was sending email. but automated action is not showing in my open erp interface so kindly tell me wheather can i do it through interface or code is the only options

Avatar
Discard

As far as I know: You can enter the code in the interface. Have you set the technical feature in your user rights?

http://www.youtube.com/watch?v=5dDoPcm6pVM

Author

yes i have enable technical feature but automated action is not showing in the options