This question has been flagged
1 Reply
12178 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>
Avatar
Discard
Best Answer

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

Avatar
Discard