使用openerp新模块XML的错误

时间:2014-02-04 09:30:53

标签: xml openerp openerp-7

初始化的.py

import product_specification

OpenERP的的.py

{
'name': "Product Specification",
'version': "1.0",
'author': "iologic",
'category': "Tools",
'depends': ['product'],
'data': ['product_specification.xml'],
'demo': [],
'installable': True,

}

product_specification.py

from openerp.osv import osv, fields
class product_specification(osv.osv):

  _inherit = "product.product"
  _name = "product.specification"

  _columns = {
    'prototype': fields.char('Prototype#', size=20),
    'style': fields.char('Style#', size=20),
    'customer': fields.char('Customer', size=20),
    'body_type': fields.char('Body Type', size=20),
    'program_brand': fields.char('Program/Brand', size=20),
    'color_asstmnt': fields.char('Color Asstmnt', size=200),
    'size_info': fields.integer('Size Info', size=20),
    'description': fields.char('Description', size=500),
    'designer': fields.char('Designer', size=20),
    'factory': fields.char('factory', size=20),
    'pcs_hanger': fields.integer('Pcs/Hanger', size=20),
    'developed_sold': fields.char('Developed/Sold', size=20),

  }


product_specification()

product_specification.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="ir.ui.view" id="product_specification_product">
        <field name="name">product.specification</field>
        <field name="model">product.product</field>
        <field name="arch" type="xml">
          <form string="Create Product Specification" version="7.0">
            <field name="prototype" />
            <field name="style"/>
            <field name="customer"/>
            <field name="body_type" />
            <field name="program_brand"/>
            <field name="color_asstmnt"/>
            <field name="size_info" />
            <field name="description"/>
            <field name="designer"/>
            <field name="factory"/>
            <field name="pcs_hanger" />
            <field name="developed_sold"/>
           </form>
        </field>
    </record>
  </data>
</openerp>

再次面临.XML文件的问题。我不清楚.xml文件&amp;还有bug修复。 OpenERP 7文档在Web中非常低。许多是各种各样的定义。需要一些正确的&amp;工作示例或完整的文档来解决那些令人困惑的问题。

1 个答案:

答案 0 :(得分:0)

更新您的xml,因为您已在product.specification对象中添加了字段,因此您必须在模型中定义该字段。并继承对象中的product.product意味着您可以访问product.specification对象中product.product的所有字段。

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="product_specification_product">
    <field name="name">product.specification</field>
    <field name="model">product.specification</field>
    <field name="arch" type="xml">
      <form string="Create Product Specification" version="7.0">
        <field name="prototype" />
        <field name="style"/>
        <field name="customer"/>
        <field name="body_type" />
        <field name="program_brand"/>
        <field name="color_asstmnt"/>
        <field name="size_info" />
        <field name="description"/>
        <field name="designer"/>
        <field name="factory"/>
        <field name="pcs_hanger" />
        <field name="developed_sold"/>
       </form>
    </field>
</record>
<record id="product_specification_product_act_window" model="ir.actions.act_window">
        <field name="name">Product Specification</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">product.specification</field>
        <field name="view_type">form</field>
        <field name="view_id" ref="product_specification_product"/>
</record>
<menuitem id="menu_product_specification" name="Product Specification" action="product_specification_product_act_window"/>
</data>
</openerp>

希望这会对你有所帮助。