Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
18830 Tampilan

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
Buang
Jawaban Terbai

Remove that P tag and add a real field.

It should be fine.

Regards,

Avatar
Buang
Penulis

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.

Jawaban Terbai

Remove the <p> tag.

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Sep 23
7556
1
Mei 19
6033
4
Des 23
13010
1
Nov 18
5847
5
Agu 24
45520