【问题标题】:odoo - 'Field origin does not exist'odoo - '字段来源不存在'
【发布时间】:2015-08-01 14:07:56
【问题描述】:

这是我的代码:

   <record id="view_order_form_inline" model="ir.ui.view">
            <field name="model">sale.order.line</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='order_line']/tree/field[11]" position="after">
                    <field name="xx_insurance_inline"/>
                </xpath>
            </field>
        </record>

这是在销售订单行中添加一个新列。 更新我的模块时,我收到以下错误:

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

Error details:
Field `origin` does not exist

Error context:
View `sale.order.line form`
[view_id: 1035, xml_id: n/a, model: sale.order.line, parent_id: 647]" while parsing /home/pantera/Custom/xx_khleuven2/view/sale.xml:24, near
<record id="view_order_form_inline" model="ir.ui.view">
            <field name="model">sale.order.line</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='order_line']/tree/field[11]" position="after">
                    <field name="xx_insurance_inline"/>
                </xpath>
            </field>
        </record>

由于在我的代码中没有对名为 origin 的字段的引用,我不知道确切的问题是什么。 应该以不同的方式添加列还是我忽略了一些明显的东西?

编辑: 这是xpath引用的xml代码:

<field name="order_line">
    <form string="Sales Order Lines">
    ....
    </form>
    <tree string="Sales Order Lines" editable="bottom">
         <field name="sequence" widget="handle"/>
         <field name="state" invisible="1"/>
         <field name="th_weight" invisible="1"/>
         <field name="product_id"
                                        context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}"
                                        groups="base.group_user"
                                        on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, False, product_uos_qty, False, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)"/>
               <field name="name"/>
               <field name="product_uom_qty"
                                        context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}"
                                        on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)"/>
                <field name="product_uom"
                                        on_change="product_uom_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, context)"
                                        groups="product.group_uom" options='{"no_open": True}'/>
               <field name="product_uos_qty" groups="product.group_uos" invisible="1"/>
               <field name="product_uos" string="UoS" groups="product.group_uos" invisible="1"/>
               <field name="price_unit"/>
               <field name="tax_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','&lt;&gt;','purchase')]"/>
               <field name="discount" groups="sale.group_discount_per_so_line"/>
               <field name="price_subtotal"/>
       </tree>
  </field>

【问题讨论】:

  • 你解决了吗?我也有同样的问题。

标签: xml odoo odoo-8


【解决方案1】:

我认为您需要更新 xml 中的一些内容,

<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="priority" eval="50" />

因为这个外部 id sale.view_order_form 属于 sale.order 模型而不是 sale.order.line 模型。

【讨论】:

    【解决方案2】:

    这可能发生在您修改了任何添加一些字段基础的视图,或者从原始记录中删除了 origin 字段。最初在数据库中有 sale.order 模型的三个视图,它们正在更改或添加原始视图,如下图所示:

    1. sale.order.form 正在添加来源字段。
    2. sale.order.inherit 是:继承视图 1 并使用 origin 字段添加。只有在安装了模块 sale_crm 时,这才是他们的唯一选择。
    3. sale.order.journal.view.form_ :继承视图 1 并使用添加的 origin 字段。只有安装了模块 sale_journal 时,这将是他们的唯一选择。

    所以在更新您的模块之前,请确保该视图正确存在于数据库中。

    最佳

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-12
      • 1970-01-01
      • 1970-01-01
      • 2021-01-30
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多