Odoo Help


Custom Server action to send trigger message

Atchuthan - Technical Consultant, Sodexis Inc
on 8/20/13, 10:49 AM 8,022 views

I am trying to understand Server Action in which when a state is changed from draft to confirm, a message is sent to the email provided.

There is no error as such in program, but the mail is not sent to custom email.

The codes are as follows:


<!-- demo automated actions sending message after state transition -->
<record id="filter_draft_lead" model="ir.filters">
    <field name="name">Draft Leads notebook</field>
    <field name="model_id">notebook.server_action</field>
    <field name="domain">[('state','=','confirm')]</field>
    <field name="user_id" eval="False" />
<record id="action_email_reminder_lead" model="ir.actions.server">
    <field name="name">Message @ confirm state</field>
    <field name="model_id" ref="model_notebook_server_action" />
    <field name="condition">True</field>
    <field name="type">ir.actions.server</field>
    <field name="state">email</field>
    <field name="email">object.email</field>
    <field name="subject">Check 1 2 3</field>
    <field name="message">11111111111111</field>
<record id="rule_set_reminder_lead" model="base.action.rule">
    <field name="name">Send mail when status changed to confirm</field>
    <field name="model_id" ref="model_notebook_server_action" />
    <field name="sequence">1</field>
    <field name="filter_id" ref="filter_draft_lead" />
    <field name="trg_date_id" ref="field_notebook_server_action_note_date" />
    <field name="trg_date_range">0</field>
    <field name="trg_date_range_type">minutes</field>
    <field name="server_action_ids" eval="[(6,0,[ref('action_email_reminder_lead')])]" />


class notebook(osv.osv):
    _name = "notebook.server_action"
    _description = "Simple Notebook"
    _columns = {
        'name' : fields.char('Title', size=30, required=True),
        'note' : fields.text('Note'),
        'email': fields.char('Email', size=120, required=True),
        'note_date' : fields.datetime('Date'),
        'state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed')],
            'Status', required=True, readonly=True),
    _defaults = {
        'state': 'draft',
        'note_date' : lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
    def button_confirm(self, cr, uid, ids, context=None):
        return self.write(cr, uid, ids, {'state': 'confirm'})


<record model="ir.ui.view" id="notebook_server_actiontree_view">
    <field name="name">notebook.server_action.tree</field>
    <field name="model">notebook.server_action</field>
    <field name="arch" type="xml">
        <tree string="Notebook">
            <field name="name" />
            <field name="note" />
            <field name="note_date" />
<record model="ir.ui.view" id="notebook_server_actionform_view">
    <field name="name">notebook.server_action.form</field>
    <field name="model">notebook.server_action</field>
    <field name="arch" type="xml">
        <form string="Notebook" version="7.0">
                <button name="button_confirm" states="draft" string="Confirm"
                    type="object" />
                <field name="state" widget="statusbar" />
                    <field name="name" />
                    <field name="note" />
                    <field name="note_date" />
<record model="ir.actions.act_window" id="action_notebook_server_actionform">
    <field name="name">notebook.server_action</field>
Mind And Go
On 5/14/14, 4:11 PM


Sorry if it's a dumb question for you but :

  1. Did your first check that messages could be sent from your OpenERP instance?
  2. Did you check that the partner is welle configured for receiving message and push them through mail?

Have a look there : https://www.youtube.com/watch?v=OoHPgtsM2fA

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 8/20/13, 10:49 AM
Seen: 8022 times
Last updated: 3/31/15, 5:36 PM