This question has been flagged
1 Reply
3283 Views
  • I created the custom module and override mail.template

  • I changed the "report_template" to my custom sale order report id instead of original

  • This code in base is noupdate="1", so I delete the sale order report from user interface and upgrade my custom module.

But the pdf does not change 

code sample 

<record id="sale.email_template_edi_sale" model="mail.template">

            <field name="report_template" ref="custom_itc_sale_quotation_header"/>

        </record>

Notes


is any problem in my code?How to set custom report there?

is any other method(from python) to solve this?


Avatar
Discard
Best Answer

Hi Acha Aslam, you can replace your custom mail template to sale by refering the below code,

<field name="report_template" ref="kitchen_order_print.report_custom_kitchen_order"/>

Here you have to mention your custom report name, ie, module_name.report_id .

<record id="sale.email_template_edi_sale" model="mail.template">
<field name="name">Sales Order - Send by Email</field>
<field name="email_from">${(object.user_id.email and '%s &lt;%s&gt;' % (object.user_id.name, object.user_id.email) or '')|safe}</field>
<field name="subject">NIyas</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="auto_delete" eval="True"/>
<field name="report_template" ref="kitchen_order_print.report_custom_kitchen_order"/>
<field name="report_name">${(object.name or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="body_html"></field>
</record>
Avatar
Discard
Author

Hi Niyas,

Thanks for the answer.I changed my code like this but pdf attachment is not there.I write the code in my custom module's xml view.Finally, I copy your example to my code and replace model name and id of the custom report but only the body is loaded.the pdf attachment does not load.What is the problem?

Hi Aslam, I have checked with the above code and i got everything working fine, default report template is getting replaced with my custom template. In your case is it showing any error or something ?

Author

Hi Niyas,

There no errors in my code.I did the same things that you did, but could not load the report.is any idea about this?

Author

Hi Niyas,

there is a warning in log file.

odoo.addons.base.ir.ir_model: Creating the ir.model.data report_sale_order in module sale instead of itc_custom..

What is the reason behind this warning?

I just now removed the report then i try to send by email, then the attachment seems to be empty.

So follow this procedure it may help you,

first install the custom report, then install the module for replacing the existing report in the mail

Author

Hi Niyas,

I have used 1 custom module for custom report and replacing existing report in mail.

is want to create another module for replacing existing report in mail?

Hi, i tried in two different modules, i already have installed a custom report in the db. i just added the code to replace the report template in the current module. and i followed the above procedure and it works.

Author

Thanks, Niyas, I will try that way.