Skip to Content
Menu
This question has been flagged
3 Replies
17032 Views

Hello, I am using odoo 11.

I can't really understand why i keep getting this error. I used 'scaffold' to create a new custom module, and I wrote minimal content in the following files (what I wished to do is to add a column in the treeview for lot/serial number section):

models.py

# -*- coding: utf-8 -*-

from odoo import models, fields, api


class CustomLot(models.Model):
    _inherit = 'stock.production.lot'
    _name = 'stock.production.lot'
    
views.xml
<odoo>
  <data>
    <record id="custom_lot_view" model="ir.ui.view">
      <field name="name">custom.lot.view</field>
      <field name="model">stock.production.lot</field>
      <field name="inherit_id" ref="stock.view_production_lot_tree"/>
      <field name="arch" type="xml">         
        <xpath expr="//field[@name='product_id']" position="before">
          <p>test</p>
        </xpath>
      </field>
    </record>
  </data>
</odoo> 

For some reason i keep getting the "Invalid view definition" error, and I can't understand what causes it. Maybe it's a dependence problem, so i tried adding dependences in the manifest (to no avail... i tried "stock", "'account_accountant", "sale_stock").

The details of the error:
  File "/opt/odoo/odoo/odoo/addons/base/ir/ir_ui_view.py", line 343, in _check_xml
    raise ValidationError(_('Invalid view definition'))
odoo.tools.convert.ParseError: "Invalid view definition
None" while parsing /opt/odoo/odoo/custom_addons/custom_lot/views/views.xml:3, near
<record id="custom_lot_view" model="ir.ui.view">
      <field name="name">custom.lot.view</field>
      <field name="model">stock.production.lot</field>
      <field name="inherit_id" ref="stock.view_production_lot_tree"/>
      <field name="arch" type="xml">         
        <xpath expr="//field[@name='product_id']" position="before">
          <p>PUPPA</p>
        </xpath>
      </field>
    </record>
I'm really a bit baffled. This is like the sixth custom module i'm defining, and I never had this specific problem. probably i'm doing some very stupid error, but I cannot see where or what.

Thank you very much in advnace for any help.



Avatar
Discard
Best Answer

Remove that P tag and add a real field.

It should be fine.

Regards,

Avatar
Discard
Author

You are right, sir. Thank you very much and please pardon the stupid question... i tried the '<p>' trick in other situations without problems so i didn't think it could be the cause of the error. I'll keep it in mind for the future. Thanks again.

Best Answer

Remove the <p> tag.

You can use <p> in QWEB templates but not in generic view.

Avatar
Discard
Related Posts Replies Views Activity
2
Sep 23
6538
1
May 19
5216
4
Dec 23
11963
1
Nov 18
4945
5
Aug 24
42961