Odoo Help

Welcome!

This community 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.

1

Custom Server action to send trigger message

By
Atchuthan - Technical Consultant, Sodexis Inc
on 8/20/13, 10:49 AM 7,046 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:

notebook_server_action.xml:

<!-- 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>
<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>
<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')])]" />
</record>

notebook.py

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'})

notebook_view.xml

<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" />
        </tree>
    </field>
</record>
<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">
            <header>
                <button name="button_confirm" states="draft" string="Confirm"
                    type="object" />
                <field name="state" widget="statusbar" />
            </header>
            <sheet>
                <group>
                    <field name="name" />
                    <field name="note" />
                    <field name="note_date" />
                </group>
            </sheet>
        </form>
    </field>
</record>
<record model="ir.actions.act_window" id="action_notebook_server_actionform">
    <field name="name">notebook.server_action</field>
0
Mind And Go
On 5/14/14, 4:11 PM

Hy,

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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