跳至内容
菜单
此问题已终结
1 回复
3718 查看

class inherit_details(osv.osv):

_inherit="project.task"

_inherit="sale.order.line"

_columns = {

'description':fields.text('Description',size=10),

'debit': fields.boolean('Debit'),

'credit': fields.boolean('Credit'),

'salesDetail':fields.char('SalesDetails',size=20,required=True),

 'salestax':fields.char('SalesTax',size=10,required=True),

}

inherit_details()

------------------------------------------------xml file--------------------

<record id="inherit1_form_view" model="ir.ui.view">

<field name="name">project.task.form</field>

<field name="model">project.task</field>

<field name="type">form</field>

<field name="inherit_id" ref="project.view_task_form2"></field>

<field name="arch" type="xml">

<xpath expr="/form/sheet/group/group/field[@name='project_id']"

position="before">

<field name="description" />

</xpath>

<xpath expr="//field[@name='user_id']"

position="after">

<field name="debit" type="checkbox"/>

<field name="credit" type="checkbox"/>

</xpath>

</field>

</record>


<record id="saleinherit_form_view" model="ir.ui.view">

<field name="name">sale.order.form</field>

<field name="model">sale.order</field>

<field name="type">form</field>

<field name="inherit_id" ref="sale.view_order_form"></field>

<field name="arch" type="xml">

<xpath expr="/form/sheet/notebook/page[@string='Order Lines']/field[@name='order_line']/tree/field[@name='product_id']"

position="attributes">

<attribute name="string">ProductDetails</attribute>

</xpath>

<xpath expr="/form/sheet/notebook/page[@string='Order Lines']/field[@name='order_line']/tree/field[@name='price_subtotal']"

position="before">

<field name="salesDetail" />

</xpath>

<xpath expr="/form/sheet/notebook/page[@string='Order Lines']/field[@name='order_line']/tree/field[@name='tax_id']"

position="replace">

<field name="salestax" />

</xpath>

</field>

</record> 

-------------------------------------------------------------------Run----------------------------------

if  run above code, it produce error below

ERROR:

ParseError: "ValidateError

Field(s) `arch` failed against a constraint: Invalid view definition

Error details:

Field `credit` does not exist

Error context:

View `project.task.form`

[view_id: 1221, xml_id: Inheritance.inherit1_form_view, model: project.task, parent_id: 785]" while parsing /home/next/workspace/odoo-8/openerp/addons/Inheritance/views/inheritance.xml:5, near

<record id="inherit1_form_view" model="ir.ui.view">

<field name="name">project.task.form</field>

<field name="model">project.task</field>

<field name="type">form</field>

<field name="inherit_id" ref="project.view_task_form2"/>

<field name="arch" type="xml">

<data><xpath expr="/form/sheet/group/group/field[@name='project_id']" position="before">

<field name="description"/>

</xpath>

<xpath expr="//field[@name='user_id']" position="after">

<field name="debit" type="checkbox"/>

<field name="credit" type="checkbox"/>

</xpath>

</data></field>

</record>

形象
丢弃
最佳答案

Arun,

update ur module from terminal using ./openerp-server -u <module_name> this field is not created in DB... once you upgrade it will be add to your table and this error will not come.

形象
丢弃
编写者

if i update the module above error shows

ok, on ir_module_module table in DB, get those records which are in 'to upgrade' state, if found then change their state to 'uninstalled', and then upgrade your module again..

hope it should work