Im trying to add an email template to my custom module, When I add the email template like below I get an error.
odoo.tools.convert.ParseError: "insert or update on table "mail_template" violates foreign key constraint "mail_template_model_id_fkey"
The only way I can get the template installed to odoo is by removing the model_id field.
Ways Ive tried model_id: it_onboarding.it_onboarding ,it_onboarding.model_it_onboarding, model_it_onboarding, it_onboarding. All of those variations on the model name give External ID errors except it_onboarding.it_onboarding which give the foreign key constraint error.
Module name: it_onboarding.it_onboarding
Filename: data/it_request_approval_email.xml
Email Template:
<record id="it_request_email_template" model="mail.template">
<field name="name">New IT Request ${object.reference}</field>
<field name="model_id" ref="it_onboarding.it_onboarding"/>
<field name="subject">${object.reference} needs approval</field>
<field name="email_from">dummy@mail.com</field>
<field name="email_to">dummy@mail.com</field>
<field name="auto_delete" eval="False"/>
<field name="user_signature" eval="False"/>
<field name="body_html" type="html">
<div>
${object.reference} has been received and needs approval
</div>
</field>
Grateful for any ideas
File Structure
-it_onboarding
--controllers
--data
--it_request_approval_email.xml
--sequence.xml
--models
--reports
--security
--static
--views
--__init__.py
--__manifest__.py
Manifest
"data": [
'security/ir.model.access.csv',
'security/security.xml',
'data/sequence.xml',
'views/views.xml',
'views/templates.xml',
'views/it_user_view.xml',
'reports/it_user_report.xml',
'reports/it_request_report.xml',
'reports/approval_email_report.xml',
'data/it_request_approval_email.xml',
],