繁体   English   中英

尝试安装模块时,为什么会出现错误“找不到模型:product.print.zpl.barcode”?

[英]Why am I getting the error “model not found : product.print.zpl.barcode” when I try to install a module?

我想安装我的自定义模块product_print_zpl_barcode ,但是当我按下安装按钮时,它显示此错误:

ParseError: "Invalid view definition

D\xe9tails de l'erreur :
Mod\xe8le non trouv\xe9 : product.print.zpl.barcode

Contexte de l'erreur :
Vue `product_print_zpl_barcode.form`
[view_id: 847, xml_id: n/a, model: product.print.zpl.barcode, parent_id: n/a]
None" while parsing [...]/openerp/addons/product_print_zpl_barcode/views/product_print_zpl_barcode_view.xml:5, near

product_print_zpl_barcode_view.xml

<record id="product_print_zpl_barcode_form" model="ir.ui.view">
    <field name="name">product_print_zpl_barcode.form</field>
    <field name="model">product.print.zpl.barcode</field>
    <field name="arch" type="xml">
        <form string="Generate and Print Product Barcode">
            <group name="step1" string="Configuration">
                <field name="state" invisible="1"/>
                <field name="currency_id" invisible="1"/>
                <field name="product_id"/>
                <field name="product_name" attrs="{'readonly': [('state', '=', 'step2')]}"/>
                <field name="pricelist_id" attrs="{'readonly': [('state', '=', 'step2')]}"/>
                <field name="price_uom"/>
                <field name="label_size" attrs="{'readonly': [('state', '=', 'step2')]}"/>
                <field name="nomenclature_id" attrs="{'readonly': [('state', '=', 'step2')]}"/>
                <field name="rule_id"/>
                <field name="barcode_type"/>
                <field name="barcode"/>
                <field name="copies" attrs="{'readonly': [('state', '=', 'step2')]}"/>
            </group>
            <group string="Enter Quantity" attrs="{'invisible': [('barcode_type', '=', 'product')]}">
                <div name="qty_uom">
                    <field name="quantity" attrs="{'readonly': [('state', '=', 'step2')]}" class="oe_inline"/>
                    <field name="uom_id" class="oe_inline"/>
                </div>
            </group>
            <group name="step2" states="step2" string="Label">
                <field name="price"/>
                <field name="zpl_file" filename="zpl_filename"/>
                <field name="zpl_filename" invisible="1"/>
                <field name="zpl_printer_id" required="1"/>
            </group>
            <footer>
                <button name="generate" type="object" string="Generate Label" class="btn-primary" states="step1"/>
                <button special="cancel" string="Cancel" class="oe_link" states="step1"/>
                <button name="print_zpl" type="object" string="Print" class="btn-primary" states="step2"/>
                <button name="print_zpl" type="object" string="Print and New" class="btn-primary" context="{'print_and_new': True}" attrs="{'invisible': ['|', ('state', '!=', 'step2'), ('barcode_type', '=', 'product')]}"/>
                <button special="cancel" string="Close" class="oe_link" states="step2"/>
            </footer>
        </form>
    </field>
</record>

<record id="product_print_zpl_barcode_action" model="ir.actions.act_window">
    <field name="name">Generate Barcode</field>
    <field name="res_model">product.print.zpl.barcode</field>
    <field name="view_mode">form</field>
    <field name="target">new</field>
</record>

我想创建一个新模型product.print.zpl.barcode但是即使创建了动作,Odoo也无法识别新模型。 这是

因此,请确保您以正确的方式添加了模型。 您必须考虑到

  • 将此包含在/your_module/__init__.py

     import models 
  • 将此包含在/your_module/models/__init__.py

     import model_name 
  • /your_module/models/model_name.py文件中包括您的模型:

     from openerp import models, fields class YourModel(models.Model): _name = 'a.model.name' field1 = fields.Char() 
  • 要重新加载python文件,您需要重新启动服务器

  • 要重新加载xml文件,您需要使用--update=your_module参数重新启动服务。 您可以通过按模块表单上的“ 更新”按钮进行此更新。

注意 :如果从类models.TransientModel继承,则将不时删除表中的数据。 常用的是向导。 如果需要持久模型,则需要从models.Model继承

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM