微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Odoo 模型继承问题

如何解决Odoo 模型继承问题

我正在开发一个从电子邮件营销模块继承的自定义视图并添加一些电子邮件的模板,我找不到如何修改原始视图终端给我这个错误

2021-06-22 20:18:26,442 48472 INFO odoo odoo.modules.loading: Loading module eroom_email_templates (37/42) 
2021-06-22 20:18:26,513 48472 INFO odoo odoo.modules.registry: module eroom_email_templates: creating or updating database tables 
2021-06-22 20:18:26,570 48472 INFO odoo odoo.modules.loading: loading eroom_email_templates/views/load_templates.xml 
2021-06-22 20:18:26,573 48472 WARNING odoo odoo.modules.loading: Transient module states were reset 
2021-06-22 20:18:26,621 48472 ERROR odoo odoo.modules.registry: Failed to load registry 
2021-06-22 20:18:26,621 48472 CRITICAL odoo odoo.service.server: Failed to initialize database `odoo`. 
Traceback (most recent call last):
  File "/home/developer/crm/odoo/tools/convert.py",line 677,in _tag_root
    f(rec)
  File "/home/developer/crm/odoo/tools/convert.py",line 492,in _tag_record
    model = env[rec_model]
  File "/home/developer/crm/odoo/api.py",line 473,in __getitem__
    return self.registry[model_name]._browse(self,(),())
  File "/home/developer/crm/odoo/modules/registry.py",line 177,in __getitem__
    return self.models[model_name]
KeyError: 'ir.iu.view'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/developer/crm/odoo/service/server.py",line 1198,in preload_registries
    registry = Registry.new(dbname,update_module=update_module)
  File "/home/developer/crm/odoo/modules/registry.py",line 89,in new
    odoo.modules.load_modules(registry._db,force_demo,status,update_module)
  File "/home/developer/crm/odoo/modules/loading.py",line 453,in load_modules
    processed_modules += load_marked_modules(cr,graph,File "/home/developer/crm/odoo/modules/loading.py",line 346,in load_marked_modules
    loaded,processed = load_module_graph(
  File "/home/developer/crm/odoo/modules/loading.py",line 221,in load_module_graph
    load_data(cr,idref,mode,kind='data',package=package)
  File "/home/developer/crm/odoo/modules/loading.py",line 69,in load_data
    tools.convert_file(cr,package.name,filename,noupdate,kind)
  File "/home/developer/crm/odoo/tools/convert.py",line 733,in convert_file
    convert_xml_import(cr,module,fp,noupdate)
  File "/home/developer/crm/odoo/tools/convert.py",line 799,in convert_xml_import
    obj.parse(doc.getroot())
  File "/home/developer/crm/odoo/tools/convert.py",line 719,in parse
    self._tag_root(de)
  File "/home/developer/crm/odoo/tools/convert.py",line 681,in _tag_root
    raise ParseError('while parsing %s:%s,near\n%s' % (
odoo.tools.convert.ParseError: while parsing /home/developer/crm/custom-addons/eroom_email_templates/views/load_templates.xml:4,near
<record model="ir.iu.view" id="mailing_mailing_form_email_templates">
            <field name="name">mailing.mailing.form.email.templates</field> <!-- field name -->
            <field name="model">mailing.mailing</field> <!-- the model where the field belongs to-->
            <field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_form"/> <!-- the ref field -->
            <field name="arch" type="xml">
                <xpath expr="//field[@name='body_arch']" position="after"> <!-- add content's routes -->
                    <group>
                        <!--   email templates Box -->
                        <field name="email_templates" widget="html_frame"/>
                    </group>
                </xpath>
            </field>
        </record>

我的 module.py 内容是:

from odoo import models,fields,api


class EmailTemplates(models.Model):
   _inherit = 'mailing.mailing'
   _description = 'extension of the email marketing add custom email templates '

   email_template = fields.Html(string="TEST-22")

我的xml内容是:

<odoo>
    <data>
       <record model="ir.iu.view" id="mailing_mailing_form_email_templates">
            <field name="name">mailing.mailing.form.email.templates</field> <!-- field name -->
            <field name="model">mailing.mailing</field> <!-- the model where the field belongs to-->
            <field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_form"/> <!-- the ref field -->
            <field name="arch" type="xml">
                <xpath expr="//field[@name='body_arch']" position='after'> <!-- add content's routes -->
                    <group>
                        <!--   email templates Box -->
                        <field name="email_templates" widget="html_frame" />
                    </group>
                </xpath>
            </field>
        </record>
    </data>
</odoo>

此外,我正在尝试添加一个小部件来显示我的电子邮件模板,但我不知道如何定义我的模板、草稿、发送和发送电子邮件的路径以在其中显示,或者我是否应该使用自定义小部件为此,我尝试创建一个新模块以使用我的模块对其进行修改,但这给了我同样的错误

感谢您的帮助

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。