Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2594 Zobrazení

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>

Avatar
Zrušit
Autor

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! 

Nejlepší odpověď

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

Avatar
Zrušit
Autor

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

Related Posts Odpovědi Zobrazení Aktivita
1
bře 15
5324
2
zář 23
8420
1
čvc 22
7366
2
bře 22
6433
1
led 21
8024