0

By default, state is updated as 'sent' after quotation sent through email. I would like to use email function to send notification email and update states other than 'sent' like 'approval required', 'verified' etc.

By default Quotation (draft) -> Send Email -> Quotation (Sent)

I want notification email to be sent; rather the entire quotation using existing email function Quotation (draft) -> Send Email -> Quotation (Approval Required) -> Quotation (Approved) -> Quotation (Sent)

Can anyone suggest how can I do this.

Lekha
  • 11
  • 4
  • You can edit the field `state` of object `sale.order` to add new states. Than you can edit the send method to set state to `approval_required`. – qvpham Aug 08 '18 at 11:33
  • This is what I tried to do. My question is, once I send the email, it automatically updates the status to sent. I want to use default email function but don't want the status to be changed to 'sent' rather new state. – Lekha Aug 20 '18 at 01:34
  • Okay, i have added my answer below. But you should use Odoo 11 for new development – qvpham Aug 20 '18 at 14:34

1 Answers1

0

First you can see the file sale.py # Line 652. When u send a e-mail, it call the wizard mail.compose.message with a context 'mark_so_as_sent': True.

The next, you can look for mail.compose.message in the samme file, you will see it sale.py # Line 1277. So it call the workflow quotation_sent if you send e-mail.

On the file sale_workflow.xml, you will see some thing like that:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="act_sent" model="workflow.activity">
            <field name="wkf_id" ref="wkf_sale"/>
            <field name="name">sent</field>
            <field name="kind">function</field>
            <field name="action">write({'state':'sent'})</field>
        </record>

        <record id="trans_draft_sent" model="workflow.transition">
            <field name="act_from" ref="act_draft"/>
            <field name="act_to" ref="act_sent"/>
            <field name="signal">quotation_sent</field>
        </record>
    </data>
</openerp>

Now you see, you only need to add new state into the state field and edit the workflow:

Python

state = fields.Selection(selection_add=[('not_approval', 'Quotation (Approval Required)')])

XML

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="act_not_approval" model="workflow.activity">
            <field name="wkf_id" ref="wkf_approval"/>
            <field name="name">not_approval</field>
            <field name="kind">function</field>
            <field name="action">write({'state':'not_approval'})</field>
        </record>

        <record id="trans_draft_sent" model="workflow.transition">
            <field name="act_from" ref="act_draft"/>
            <field name="act_to" ref="act_not_approval"/>
            <field name="signal">quotation_sent</field>
        </record>
    </data>
</openerp>
qvpham
  • 1,896
  • 9
  • 17
  • It seems like the correct answer. But I solved by creating new custom object to update status. – Lekha May 23 '19 at 04:22