2
votes

I have created an automated action, and it works fine if When to Run is set to On Creation. If i change it to Based on Timed Condition won't trigger.

Automated action enter image description here

Server Action

enter image description here

Scheduled Action enter image description here

How can i do this?

1
are you sure the condition to run the action is satisfied?danidee
The trigger date value is today's date . Example : 30-12-2016KbiR

1 Answers

0
votes

You have to do this via python code. Have u tried that?

I have one example: for partner notification email send: through action:

<record id="action_send_mail_on_partner_creation" model="ir.actions.server">
            <field name="name">Partner Creation action</field>
            <field name="model_id" ref="base.model_res_partner"/>
            <field name="type">ir.actions.server</field>
            <field name="state">code</field>
            <field name="code">self.parnter_create_notification(cr, uid, object, context=context)</field>
        </record>

        <record id="rule_sent_mail_partner_creation" model="base.action.rule">
            <field name="name">Partner Creation Action Rule</field>
            <field name="kind">on_create_or_write</field>
            <field name="model_id" ref="base.model_res_partner"/>
            <field name="sequence">1</field>
            <field name="filter_id" ref="filter_customer"/>
            <field name="active">True</field>
            <field name="server_action_ids" eval="[(6, 0, [ref('action_send_mail_on_partner_creation')])]"/>
        </record>

where method you have to define in PY file would be:

 def parnter_create_notification(self, cr, uid, obj,  context=None):
    if context.get('from_create',False):
        group_obj = self.pool.get('res.groups')
        user_obj = self.pool.get('res.users')
        if obj.customer or obj.supplier:
            manager_ids = group_obj.search(cr, uid, [('name','=', 'Financial Manager')])
            user_ids = group_obj.browse(cr, uid, manager_ids, context=context)[0].users
            email = []
            for id in user_ids:
                email.append(id.email)
            email_to = ','.join(str(e) for e in email)
            tmpl_obj = self.pool.get('email.template')
            tmpl_ids = tmpl_obj.search(cr, uid, [('name','=','Partner E-mail Template')])
            if tmpl_ids:
                tmpl_obj.write(cr, uid, tmpl_ids[0], {'email_to':email_to}, context=context)
                self.pool.get('email.template').send_mail(cr, uid, tmpl_ids[0], obj.id)
    return {}

In Inherited class of res.partner.

you can take this example for your issue.

Hope this will help you.

Thanks, Chandni