Skip to Content
Menu
This question has been flagged
1 Odpoveď
5392 Zobrazenia

I'm writing a model that needs to create a record in product.template model when installed. this is the xml file

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
      <record id="adding_ticket_product" model="product.template">
        <field name="name">Airline Ticket</field>
        <field name="type">service</field>
        <field name="sale_ok">True</field>
        <field name="purchase_ok">True</field>
        <field name="sale_line_warn">no-message</field>
      </record>
    </data>
</odoo>

and this is call for it in the __manifest__.py file:

data: [

    'views/product_product.xml',

]

but when ever I try to upgrade my model with the xml file I got the following error:

Odoo Server Error
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 3686, in create
    raise ValueError("Invalid field %r on model %r" % (key, self._name))
ValueError: Invalid field 'sale_line_warn' on model 'product.template'

During handling of the above exception, another exception occurred:


odoo.tools.convert.ParseError: "Invalid field 'sale_line_warn' on model 'product.template'" while parsing /usr/lib/python3/dist-packages/odoo/c_addons/airlines_system/views/ticket_product.xml:2, near
<odoo>
    <data>
      <record model="product.template" id="adding_ticket_product">
        <field name="name">Airline Ticket</field>
        <field name="type">service</field>
        <!-- <field name="sale_ok">True</field> -->
        <!-- <field name="purchase_ok">True</field> -->
        <!-- <field name="categ_id">5</field> -->
        <field name="sale_line_warn">no-message</field>
        <!-- <field name="sale_line_warn">1</field> -->
      </record>
    </data>
</odoo>
and I made sure that sale_line_warn (a selection field) does have the "no-message" option, because it is the default value.
Any idea how to fix this ? Thanks  in Advance

Avatar
Zrušiť
Best Answer

Does your module declare dependency on sale module? That's where sale_line_warn field is defined.

Update your __manifest__.py so that it contains:

...
'depends': ['sale', 'stock'], # possibly some other dependencies
...
Avatar
Zrušiť
Autor

It worked, thanks !

Related Posts Replies Zobrazenia Aktivita
1
jún 23
2619
2
jún 20
11280
1
dec 23
5601
1
mar 15
4331
1
apr 24
2620