This question has been flagged
5 Replies
4079 Views

i have created a custome module that has to send and email and upload a report inside it 

i have preceed this way 

on my model.py i have defined a function that a object button has to call for sending email 

def send_job_certifica(self): template_id = self.env.ref('attestation.job_certifica_email_template').id template = self.env['mail.template'].browse(template_id) template.send_mail(self.id, force_send=True) self.state = 'send'

and on my xml file 


 <record id='job_certifica_view_form' model='ir.ui.view'>
            <field name="name">job.certifica.form</field>
            <field name="model">job.certifica</field>
            <field name="arch" type="xml">
               <form>
                <header>
             <button name="send_job_certifica" string="Send" type="object" states="valide" class="oe_highlight"/>
                <field name="state" widget="statusbar"/>                 
                </header>
             </form>
            </field>
</record>
and my email_template 

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="1">

        <record id="job_certifica_email_template" model="mail.template">
            <field name="name">ATTESTATION DE TRAVAIL: envoie par email</field>
             <field name="model_id" ref="attestation.model_job_certifica"/>
            <field name="email_from">xyz@gmail.com</field>
            <field name="email_to">${object.email_id}</field> 
            <field name="subject">Attestation ( Mme/Ms ${object.employee_name})</field>    
            <field name="body_html" type="html">
                <div style="margin: 0px; padding: 0px">
                    <p style="margin: 0px; padding: 0px; font-size: 13px;">
                        Chèr(e) ${object.employee_name}
                        <br /><br/>
                        voilà votre Atesttation de travail
                        <br /><br />
                        n'hzsitez pas de nous contacter si vous avez des questions
                    </p>
                </div>
            </field>
                <field name="report_template" ref="action_report_job"/>
                <field name="report_name">Attestation de travail_${object.name}</field>
        </record>
</data> </odoo>

and here is my repport 

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

	<report
		id="action_report_job"
		string="Attestation"
		model="job.certifica"
		report_type="qweb-pdf"
		name="attestation.job"
		print_report_name="'Attestation'"/>

        <template id="job">
        
        <t t-call="web.html_container">
			<t t-foreach="docs" t-as="o">
			<t t-call="web.external_layout">

                        </t>
                         </t>
    </t>
    </template>
</odoo>

and i declared the form view file and also the repport as well as the template on my __manifest__.py 

and i still got this error 


 "External ID not found in the system: attestation.action_report_job"


what i am still missing ? 

Avatar
Discard
Author

and i ll have to do this whenever i want to install the module ?

why... make the change as described once and hope it will remains as it is

Author

still don't get it, if you mean by importing the filed where i am defining my report (let's say job_report.xml) i already did it in manifest ( data:' ['report/job_report.xml',]

and also in which concerns mail_template.xml (data:'['data/mail_template.xml'])

or you mean there is a UI way to handle this ?

Author

now i get it, you mean to import the field by order, report first and mail_template second ok sir, thank you

Best Answer

Hi,

First import the file where you define this report/action, then the import the file which refer it in manifest.


Thanks

Avatar
Discard