sal...">

Odoo - "The original field does not exist"

This is my code:

   <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>

      

This is adding a new column to the sales order lines. I get the following error when updating a module:

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>

      

Since there is no reference anywhere in my code to a field called origin, I don't know what the exact problem is. Should adding a column be done differently or am I missing something obvious?

edit: This is the xml code where the xpath refers to:

<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>

      

+3


source to share


2 answers


I think you need to update several things in the xml,

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

      



As this external id sale.view_order_form

belongs to sale.order model not to sale.order.line model.

+3


source


This can happen if you have any view that adds some kind of field origin or does not remove the origin field from the original record. Initially there are three kinds of sale.order model in the database , which modify or add the original one as shown below:

enter image description here

  • sale.order.form adds the original field.
  • sale.order.inherit : there is view 1 and using the origin field . This will be their only one if the sale_crm module is installed .
  • sale.order.journal.view.form _ : inherits view 1 and adds an origin field . This will be their only one if the sale_journal module is installed .


Thus, make sure this view exists correctly before rebuilding your module.

Bests

0


source







All Articles