콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2726 화면

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
5451
2
9월 23
8535
1
7월 22
7534
2
3월 22
6649
1
1월 21
8137