Skip to Content
Menu
This question has been flagged
2 Replies
2975 Views

Hi,

I have mail template whenever some state is change in module ..
but mail is containing is old state ..

and please tell me how to send attachment(print report(like sale order or purchase order))  with mail.Automatically create pdf report and send with mail..

Please tell me 

how to resolve two problem.



<? xml version = "1.0" encoding = "utf-8"?>

<odoo>

<record id = "support_ticket_mail_template" model = "mail.template">

            <field name = "name"> Support Ticket Update </field>

            <field name = "model_id" ref = "my_module.model_support_ticket"> </field>

            <field name = "email_from"> <! [CDATA [$ {object.company_id.name} <${object.company_id.emailteit>] ""> </field>

            <field name = "email_to"> $ {object.email_from | safe} </field>

            <field name = "subject"> Support Ticket (# $ {object.sequence or object.name}) </field>

            <field name = "auto_delete" eval = "False" />

            <field name = "built_in" eval = "True" />

            <field name = "body_html"> <! [CDATA [

            Hi

                % if object.partner_id:

                    <p> Dear $ {object.partner_id.name}, </p>

                % endif

                % if object.stage_id.id! = 7:

                <p> Your ticket has been updated, the status has changed to <b> "[$ {(object.stage_id.name)}]" </b>

                <br/> Ticket state no: $ {(object.stage_id.id)}, $ {(object.stage_id)}, $ {object.stage_id.name}

                 If you want to get more detailed information, <b> View Ticket Online: </b> <a href="inside.unipiece.com.tw/my/ticket/"> here </a> <br/>

                 </p>

                <p> Best Regards <br/>

  UniPiece Support System Bot

            </p>

            % endif


            % if object.stage_id.id == 7:

            <p>

                Your ticket has been closed, we've attached the detail information as the attached file.

                For providing better customer experience, please help rate our service this time below:

                <br/> Ticket state no: $ {object.stage_id.id}, $ {object.stage_id}, $ {object.stage_id.name}

                If you want to get more detailed information, please click

                   <a href="inside.unipiece.com.tw/my/ticket/"> here </a> 

                 </p>

                <p> Best Regards <br/>

  UniPiece Support System Bot

            </p>

            % endif

            ]]>

            </field>

        </record>


</odoo>

Avatar
Discard

Sending mail on some event: https://goo.gl/z16PBZ

Best Answer

Hi, Himanshu

Query 1: You can trigger mail function after super of write function like below example,

@api.multi
def write(self, vals):
    res = super(ModelName, self).write(vals)
    if 'state' in vals:
        res.send_mail()
    return res

Query 2:  In case you want to add attachment along with your mail then you can simply add below line of code.

<field name="report_template" ref="report_your_report"/>
<field name="report_name">${object.name or ''}</field> 


Thanks,
Ashish Singh(Team Lead)(Odoo)
Webkul Software Private Limited
Avatar
Discard