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

Using v15EE

Have created a very simple module to add a field to the sales order form view. When I try install the module I get the following error:

Field "bay_fsmdesc" does not exist in model "sale.order"

View error context:
{'file': '/home/odoo/src/user/bay_salefsm_description/views/baysalesorderdescription.xml',
 'line': 3,
 'name': 'sale.order.form.sale.bay',
 'view': ir.ui.view(1568,),
 'view.model': 'sale.order',
 'view.parent': ir.ui.view(800,),
 'xmlid': 'bay_sale_order_customizations_form'}

Module code  and manifest

Manifest:

{'name': "bay_salefsm_description",
'summary': """        """,
'description': """    """,
'author': "sveng",
# Categories can be used to filter modules in modules listing# Check https://github.com/odoo/odoo/blob/master/odoo/addons/base/module/module_data.xml# for the full list'category': 'Uncategorized','version': '15.0.1.0','license': 'OPL-1',
# any module necessary for this one to work correctly'depends': ['sale_management', 'fieldservice', 'fieldservice_sale'],
# always loaded'data': ['views/baysalesorderdescription.xml',   # Add the modified view    ],# only loaded in demonstration mode#'demo': [#    'demo/demo.xml',#],'installable' : True,'application' :  False,
}

models:

from odoo import _, api, fields, models

from odoo.exceptions import ValidationError

classSaleOrder(models.Model):   _inherit="sale.order"
   bay_fsmdesc= fields.Char(string='FSM Order Description')

View:

xml version="1.0" encoding="UTF-8"?><odoo><recordid="bay_sale_order_customizations_form"model="ir.ui.view"><fieldname="name">sale.order.form.sale.bayfield><fieldname="model">sale.orderfield><fieldname="inherit_id"ref="sale.view_order_form"/><fieldname="arch"type="xml"><xpathexpr="//field[@name='partner_shipping_id']"position="after">    <fieldname="bay_fsmdesc"/>xpath>       field>   record>odoo>

アバター
破棄
著作者

This is embarrassing ... although I had the .py file in the _init_ of the models folder ... I did not have the models folder in the root _init_

Grrr, apologies for posting such a simple fail! 

最善の回答

Hi  Sveng,

Ensure that the file is added to the init file.


After adding the field, restart the server for the changes to take effect.


In some cases, even after restarting the Odoo service, the old service instance might still be running or holding onto cached data. Stopping the service and then starting it again can ensure that you are working with a fresh service instance.

Hope it helps,
Kiran K

アバター
破棄
著作者

Tx for that. Am running on Odoo.sh so the rebuild when adding module to source tree should take care of that right?

Have added the sale_order.py file in the models folder to the _init_.py file in that folder like this

from . import (sale_order,)

right from the start ... but still getting error

関連投稿 返信 ビュー 活動
1
3月 15
5319
2
9月 23
8420
1
7月 22
7360
2
3月 22
6428
1
1月 21
8022