I making a custom module that will generate email.template.
In Odoo12 this addons working properly, now I want to modify the code that will be used on Odoo13,
Here is the template.xml code:
<odoo><data>
<record id="dotmatrix_invoice" model="mail.template">
<field name="name">Dot Matrix Invoice</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="subject">Dot Matrix Invoice</field>
<field name="body_html"><![CDATA[
${'INVOICE'.rjust(30)} ${object.number}
${''.rjust(80, '-')}
${'Customer:'.rjust(20)} ${object.partner_id.display_name.ljust(20)} ${'Date:'.rjust(20)} ${object.date_invoice}
${' '.rjust(20)} ${object.partner_id.street.ljust(20) if object.partner_id.street else ''.ljust(20) } ${'Salesperson:'.rjust(20)} ${object.user_id.name}
${''.rjust(20)} ${object.partner_id.street2.ljust(20) if object.partner_id.street2 else ''.ljust(20)} ${'Due Date:'.rjust(20)} ${object.date_due}
${''.rjust(20)} ${object.partner_id.city.ljust(20) if object.partner_id.city else ''.ljust(20)} ${'Payment Terms:'.rjust(20)} ${object.payment_term_id.name if object.payment_term_id else ''}
${''.rjust(20)} ${object.partner_id.state_id.name if object.partner_id.state_id else ''} ${object.partner_id.zip}
${''.rjust(20)} ${object.partner_id.country_id.name if object.partner_id.country_id else ''}
${'PRODUCT LINES'}
${''.rjust(80, '-')}
${'Product'.ljust(29)} ${'Qty'.ljust(5)} ${'Price'.rjust(12)} ${'Disc'.rjust(7)} ${'Taxes'.ljust(8)} ${'Subtotal'.rjust(13)}
${''.rjust(80, '-')}
% for l in object.invoice_line_ids:
${l.name[:28].ljust(29)} ${"{:4,.0f}".format(l.quantity).rjust(5)} ${"{:4,.0f}".format(l.price_unit).rjust(12)} ${"{:4,.0f}".format(l.discount).rjust(7)} ${l.invoice_line_tax_ids.name.ljust(8) if l.invoice_line_tax_ids else ''.ljust(8) } ${"{:4,.0f}".format(l.price_subtotal).rjust(13)}
% endfor
${''.rjust(80, '-')}
${'Untaxed Amount:'.rjust(65)} ${"{:4,.0f}".format(object.amount_untaxed).rjust(13)}
${'Tax:'.rjust(65)} ${"{:4,.0f}".format(object.amount_tax).rjust(13)}
${'Total:'.rjust(65)} ${"{:4,.0f}".format(object.amount_total).rjust(13)}
]]></field>
</record>
</data>
</odoo>
But I got this following error:
Error:
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo13/odoo/tools/cache.py", line 85, in lookup
r = d[key]
File "/opt/odoo/odoo13/odoo/tools/func.py", line 69, in wrapper
return func(self, *args, **kwargs)
File "/opt/odoo/odoo13/odoo/tools/lru.py", line 44, in __getitem__
a = self.d[obj].me
KeyError: ('ir.model.data', <function IrModelData.xmlid_lookup at 0x7f65579bed40>, 'account.model_account_invoice')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 712, in parse
self._tag_root(de)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 674, in _tag_root
f(rec)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 674, in _tag_root
f(rec)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 561, in _tag_record
f_val = self.id_get(f_ref)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 657, in id_get
res = self.model_id_get(id_str, raise_if_not_found)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 663, in model_id_get
return self.env['ir.model.data'].xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
File "/opt/odoo/odoo13/odoo/addons/base/models/ir_model.py", line 1671, in xmlid_to_res_model_res_id
return self.xmlid_lookup(xmlid)[1:3]
File "<decorator-gen-25>", line 2, in xmlid_lookup
File "/opt/odoo/odoo13/odoo/tools/cache.py", line 90, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/opt/odoo/odoo13/odoo/addons/base/models/ir_model.py", line 1660, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: account.model_account_invoice
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/odoo/odoo13/odoo/http.py", line 624, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo13/odoo/http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/odoo13/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/opt/odoo/odoo13/odoo/http.py", line 669, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo13/odoo/http.py", line 350, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo13/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo13/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo13/odoo/http.py", line 915, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo13/odoo/http.py", line 515, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo13/addons/web/controllers/main.py", line 1326, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo13/addons/web/controllers/main.py", line 1314, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo13/odoo/api.py", line 387, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo13/odoo/api.py", line 374, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-60>", line 2, in button_immediate_install
File "/opt/odoo/odoo13/odoo/addons/base/models/ir_module.py", line 72, in check_and_log
return method(self, *args, **kwargs)
File "/opt/odoo/odoo13/odoo/addons/base/models/ir_module.py", line 463, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/opt/odoo/odoo13/odoo/addons/base/models/ir_module.py", line 573, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/opt/odoo/odoo13/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/odoo13/odoo/modules/loading.py", line 423, in load_modules
loaded_modules, update_module, models_to_check)
File "/opt/odoo/odoo13/odoo/modules/loading.py", line 315, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/opt/odoo/odoo13/odoo/modules/loading.py", line 225, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package, report=report)
File "/opt/odoo/odoo13/odoo/modules/loading.py", line 68, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 736, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 803, in convert_xml_import
obj.parse(doc.getroot())
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 721, in parse
exc_info[2]
File "/opt/odoo/odoo13/odoo/tools/pycompat.py", line 13, in reraise
raise value.with_traceback(tb)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 712, in parse
self._tag_root(de)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 674, in _tag_root
f(rec)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 674, in _tag_root
f(rec)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 561, in _tag_record
f_val = self.id_get(f_ref)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 657, in id_get
res = self.model_id_get(id_str, raise_if_not_found)
File "/opt/odoo/odoo13/odoo/tools/convert.py", line 663, in model_id_get
return self.env['ir.model.data'].xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
File "/opt/odoo/odoo13/odoo/addons/base/models/ir_model.py", line 1671, in xmlid_to_res_model_res_id
return self.xmlid_lookup(xmlid)[1:3]
File "<decorator-gen-25>", line 2, in xmlid_lookup
File "/opt/odoo/odoo13/odoo/tools/cache.py", line 90, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/opt/odoo/odoo13/odoo/addons/base/models/ir_model.py", line 1660, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
odoo.tools.convert.ParseError: "External ID not found in the system: account.model_account_invoice" while parsing /opt/odoo/odoo13/custom-addons/dotmatrix/views/templates.xml:1, near
<odoo>
<data>
<record id="dotmatrix_invoice" model="mail.template">
<field name="name">Dot Matrix Invoice</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="subject">Dot Matrix Invoice</field>
<field name="body_html">
${'INVOICE'.rjust(30)} ${object.number}
${''.rjust(80, '-')}
${'Customer:'.rjust(20)} ${object.partner_id.display_name.ljust(20)} ${'Date:'.rjust(20)} ${object.date_invoice}
${' '.rjust(20)} ${object.partner_id.street.ljust(20) if object.partner_id.street else ''.ljust(20) } ${'Salesperson:'.rjust(20)} ${object.user_id.name}
${''.rjust(20)} ${object.partner_id.street2.ljust(20) if object.partner_id.street2 else ''.ljust(20)} ${'Due Date:'.rjust(20)} ${object.date_due}
${''.rjust(20)} ${object.partner_id.city.ljust(20) if object.partner_id.city else ''.ljust(20)} ${'Payment Terms:'.rjust(20)} ${object.payment_term_id.name if object.payment_term_id else ''}
${''.rjust(20)} ${object.partner_id.state_id.name if object.partner_id.state_id else ''} ${object.partner_id.zip}
${''.rjust(20)} ${object.partner_id.country_id.name if object.partner_id.country_id else ''}
${'PRODUCT LINES'}
${''.rjust(80, '-')}
${'Product'.ljust(29)} ${'Qty'.ljust(5)} ${'Price'.rjust(12)} ${'Disc'.rjust(7)} ${'Taxes'.ljust(8)} ${'Subtotal'.rjust(13)}
${''.rjust(80, '-')}
% for l in object.invoice_line_ids:
${l.name[:28].ljust(29)} ${"{:4,.0f}".format(l.quantity).rjust(5)} ${"{:4,.0f}".format(l.price_unit).rjust(12)} ${"{:4,.0f}".format(l.discount).rjust(7)} ${l.invoice_line_tax_ids.name.ljust(8) if l.invoice_line_tax_ids else ''.ljust(8) } ${"{:4,.0f}".format(l.price_subtotal).rjust(13)}
% endfor
${''.rjust(80, '-')}
${'Untaxed Amount:'.rjust(65)} ${"{:4,.0f}".format(object.amount_untaxed).rjust(13)}
${'Tax:'.rjust(65)} ${"{:4,.0f}".format(object.amount_tax).rjust(13)}
${'Total:'.rjust(65)} ${"{:4,.0f}".format(object.amount_total).rjust(13)}
</field>
</record>
</data>
</odoo>
It seems the error came from the
<field name="model_id" ref="account.model_account_invoice"/>
So if on Odoo it refer on account.model_account_invoice , What it will be on Odoo13?