Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
3 Vastaukset
19308 Näkymät

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
Hylkää
Paras vastaus

Remove that P tag and add a real field.

It should be fine.

Regards,

Avatar
Hylkää
Tekijä

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.

Paras vastaus

Remove the <p> tag.

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

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
syysk. 23
7923
1
toukok. 19
6264
4
jouluk. 23
13287
1
marrask. 18
6244
5
elok. 24
46377