コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5379 ビュー

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

アバター
破棄
最善の回答

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
...
アバター
破棄
著作者

It worked, thanks !

関連投稿 返信 ビュー 活動
1
6月 23
2613
2
6月 20
11247
1
12月 23
5591
1
3月 15
4318
1
4月 24
2602