How can i solve KeyError: 'ir.actions.view' odoo?
How can i solve KeyError: 'ir.actions.view' odoo?
我是 odoo 的新手,正在尝试构建自定义模块。我删除了一些视图上的菜单项,但我仍然遇到同样的错误。当我尝试向 farm_menu
添加子菜单时出现以下错误。我如何使菜单像这样工作?
动物
*饲料
*喂食记录
非常感谢您的帮助。
错误
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/tools/cache.py", line 88, in lookup
r = d[key]
File "/opt/odoo/odoo/odoo/tools/func.py", line 69, in wrapper
return func(self, *args, **kwargs)
File "/opt/odoo/odoo/odoo/tools/lru.py", line 44, in __getitem__
a = self.d[obj].me
KeyError: ('ir.ui.menu', <function IrUiMenu.load_menus at 0x7f3f849090d0>, 2, None, ('en_US',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/tools/cache.py", line 88, in lookup
r = d[key]
File "/opt/odoo/odoo/odoo/tools/func.py", line 69, in wrapper
return func(self, *args, **kwargs)
File "/opt/odoo/odoo/odoo/tools/lru.py", line 44, in __getitem__
a = self.d[obj].me
KeyError: ('ir.ui.menu', <function IrUiMenu._visible_menu_ids at 0x7f3f848fc730>, frozenset({1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 79, 80, 81, 82, 84, 85}), None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/api.py", line 1049, in get
value = self._data[key][field][record._ids[0]]
KeyError: 62
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/fields.py", line 1005, in __get__
value = record.env.cache.get(record, self)
File "/opt/odoo/odoo/odoo/api.py", line 1051, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('ir.ui.menu(62,).action', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mustaf/.local/lib/python3.6/site-packages/werkzeug/serving.py", line 304, in run_wsgi
execute(self.server.app)
File "/home/mustaf/.local/lib/python3.6/site-packages/werkzeug/serving.py", line 292, in execute
application_iter = app(environ, start_response)
File "/opt/odoo/odoo/odoo/service/server.py", line 434, in app
return self.app(e, s)
File "/opt/odoo/odoo/odoo/service/wsgi_server.py", line 142, in application
return application_unproxied(environ, start_response)
File "/opt/odoo/odoo/odoo/service/wsgi_server.py", line 117, in application_unproxied
result = odoo.http.root(environ, start_response)
File "/opt/odoo/odoo/odoo/http.py", line 1320, in __call__
return self.dispatch(environ, start_response)
File "/opt/odoo/odoo/odoo/http.py", line 1293, in __call__
return self.app(environ, start_wrapped)
File "/home/mustaf/.local/lib/python3.6/site-packages/werkzeug/middleware/shared_data.py", line 220, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/odoo/http.py", line 1488, in dispatch
result = ir_http._dispatch()
File "/opt/odoo/odoo/addons/auth_signup/models/ir_http.py", line 19, in _dispatch
return super(Http, cls)._dispatch()
File "/opt/odoo/odoo/addons/web_editor/models/ir_http.py", line 22, in _dispatch
return super(IrHttp, cls)._dispatch()
File "/opt/odoo/odoo/addons/http_routing/models/ir_http.py", line 403, in _dispatch
result = super(IrHttp, cls)._dispatch()
File "/opt/odoo/odoo/odoo/addons/base/models/ir_http.py", line 207, in _dispatch
return cls._handle_exception(e)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_http.py", line 177, in _handle_exception
return request._handle_exception(exception)
File "/opt/odoo/odoo/odoo/http.py", line 776, in _handle_exception
return super(HttpRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo/odoo/http.py", line 314, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/odoo/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/opt/odoo/odoo/odoo/addons/base/models/ir_http.py", line 203, in _dispatch
result = request.dispatch()
File "/opt/odoo/odoo/odoo/http.py", line 835, in dispatch
r = self._call_function(**self.params)
File "/opt/odoo/odoo/odoo/http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 941, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 519, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 457, in web_client
context = request.env['ir.http'].webclient_rendering_context()
File "/opt/odoo/odoo/addons/web/models/ir_http.py", line 17, in webclient_rendering_context
'menu_data': request.env['ir.ui.menu'].load_menus(request.debug),
File "</home/mustaf/.local/lib/python3.6/site-packages/decorator.py:decorator-gen-31>", line 2, in load_menus
File "/opt/odoo/odoo/odoo/tools/cache.py", line 93, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 234, in load_menus
menu_roots = self.get_user_roots()
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 204, in get_user_roots
return self.search([('parent_id', '=', False)])
File "/opt/odoo/odoo/odoo/models.py", line 1562, in search
res = self._search(args, offset=offset, limit=limit, order=order, count=count)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 135, in _search
menus = menus._filter_visible_menus()
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 125, in _filter_visible_menus
visible_ids = self._visible_menu_ids(request.debug if request else False)
File "</home/mustaf/.local/lib/python3.6/site-packages/decorator.py:decorator-gen-28>", line 2, in _visible_menu_ids
File "/opt/odoo/odoo/odoo/tools/cache.py", line 93, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 94, in _visible_menu_ids
action_menus = menus.filtered(lambda m: m.action and m.action.exists())
File "/opt/odoo/odoo/odoo/models.py", line 4901, in filtered
return self.browse([rec.id for rec in self if func(rec)])
File "/opt/odoo/odoo/odoo/models.py", line 4901, in <listcomp>
return self.browse([rec.id for rec in self if func(rec)])
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 94, in <lambda>
action_menus = menus.filtered(lambda m: m.action and m.action.exists())
File "/opt/odoo/odoo/odoo/fields.py", line 1009, in __get__
self.determine_value(record)
File "/opt/odoo/odoo/odoo/fields.py", line 1112, in determine_value
record._prefetch_field(self)
File "/opt/odoo/odoo/odoo/models.py", line 2843, in _prefetch_field
result = records.read([f.name for f in fs], load='_classic_write')
File "/opt/odoo/odoo/odoo/models.py", line 2781, in read
self._read_from_database(stored, inherited)
File "/opt/odoo/odoo/odoo/models.py", line 2934, in _read_from_database
values = [convert(value, target, validate=False) for value in values]
File "/opt/odoo/odoo/odoo/models.py", line 2934, in <listcomp>
values = [convert(value, target, validate=False) for value in values]
File "/opt/odoo/odoo/odoo/fields.py", line 2032, in convert_to_cache
if record.env[res_model].browse(int(res_id)).exists():
File "/opt/odoo/odoo/odoo/api.py", line 831, in __getitem__
return self.registry[model_name]._browse((), self)
File "/opt/odoo/odoo/odoo/modules/registry.py", line 176, in __getitem__
return self.models[model_name]
KeyError: 'ir.actions.view'
animals.py
from odoo import models, fields
class FarmAnimalsFarmAnimals(models.Model):
_name ='farmanimal.farmanimal'
name= fields.Char(string='Name', required=True)
photo = fields.Binary(string='Image')
sex = fields.Selection([('male','Male'),('female','Female')], string='Sex')
animal_dob = fields.Date(string='Date of birth/entry')
animal_type = fields.Selection(
[('cow','Cow'), ('bull','Bull'), ('goat','Goat'), ('sheep','Sheep'),
('fish','Fish'), ('rabbit','Rabbit'), ('chicken','Chicken'), ('turkey','Turkey'),
('ducks','Ducks'),('quells','Quells'),('camel','Camel'), ('horse','Horse'),],
string='Animal Type')
feeds.py
from odoo import models, fields
class FeedsFeeds(models.Model):
_name ='feed.feed'
f_name = fields.Char(string='Feed Name', required=True)
f_photo = fields.Binary(string='Product Image')
feed_records.py
from odoo import models, fields
class FeedRecordsFeedRecords(models.Model):
_name ='feedrecord.feedrecord'
_inherits={'farmanimal.farmanimal','feed.feed'}
feed_animal = fields.Many2one( 'farmanimal.farmanimal','feed_animal_default_rel','name', string='Feed Animal',)
feed_name = fields.Many2many('feed.feed', 'feed_default_rel', 'f_name', string='Consumed Feed(s)',)
amount = fields.Integer(string='Amount(In Grams)',)
feed_date_time = fields.Datetime(string='Date and Time',default=fields.Datetime.now,)
vaccines.py
from odoo import models, fields
class VaccinesVaccines(models.Model):
_name ='vaccine.vaccine'
v_name = fields.Char(string='Vaccine Name', required=True)
v_photo = fields.Binary(string='Product Image')
vaccinations_records.py
from odoo import models, fields
class VaccinationRecordsVaccinationRecords(models.Model):
_name ='vaccinationrecord.vaccinationrecord'
_inherits={'farmanimal.farmanimal','vaccine.vaccine'}
vaccinated_animal = fields.Many2one( 'farmanimal.farmanimal','vaccinated_animal_default_rel','name', string='Vacinated Animal',)
vaccine_name = fields.Many2many('vaccine.vaccine', 'vaccine_default_rel', 'v_name', string='Vaccine(s)',)
vaccination_date_time = fields.Datetime(string='Date and Time',default=fields.Datetime.now,)
next_vaccination_date = fields.Date(string='Next Date',)
diseases.py
from odoo import models, fields
class DiseasesDiseases(models.Model):
_name ='disease.disease'
_inherits='vaccine.vaccine'
d_name= fields.Char(string='Name', required=True)
d_type = fields.Selection(
[('infectious disease','Infectious Disease'), ('deficiency disease','Deficiency Disease'), ('hereditary disease','Hereditary Disease'), ('physiological diseases','Physiological Diseases')], string='Disease Type')
s_vector = fields.Selection(
[('airborne','Airborne'), ('foodborne','Foodborne'), ('infectious','Infectious'), ('lifestyle','Lifestyle'), ('non-communicable','Non-communicable')],
string='Spread Vector')
threat_level = fields.Selection(
[('high','High'), ('medium','Medium'), ('low','Low'), ('immediate quarantine','Immediate Quarantine')], string='Threat Level')
cure = fields.Many2many('vaccine.vaccine', 'disease_cure_default_rel', 'v_name', string='Cure')
farm_view.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="farm_menu_action" model="ir.actions.act_window">
<field name="name">Animals</field>
<field name="res_model">farmanimal.farmanimal</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="or_view_nocontent_create">Create The First Animal
</p>
</field>
</record>
<!--farm animals tree view-->
<record id="farm_tree_view" model="ir.ui.view">
<field name="name">Animal Tree</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<tree string="Animals">
<field name="name"/>
<field name="sex"/>
<field name="animal_type"/>
<field name="animal_dob"/>
</tree>
</field>
</record>
<!--farm animals kanban view-->
<record id="farm_kanban_view" model="ir.ui.view">
<field name="name">farmanimal.farmanimal.kanban</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<kanban class="o_res_farm_kanban">
<field name="id"/>
<field name="name"/>
<field name="sex"/>
<field name="animal_type"/>
<field name="animal_dob"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_global_click">
<div class="o_kanban_image">
<img alt="Avatar" t-att-src="kanban_image('farmanimal.farmanimal','photo',record.id.raw_value)"/>
</div>
<div class="oe_kanban_details">
<strong class="o_kanban_record_title">
<field name="name"/>
</strong>
<div t-if="record.animal_type.value">
<t t-esc="record.animal_type.value"/>
</div>
<div t-if="record.sex.value">
<t t-esc="record.sex.value"/>
</div>
<div t-if="record.animal_dob.value">
<t t-esc="record.animal_dob.value"/>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!--farm animals form view-->
<record id="farm_free_view" model="ir.ui.view">
<field name="name">Animal Form</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<form string="Animal">
<sheet>
<field name="photo" widget="image" class="oe_left oe_avatar" />
<div class="oe_title">
<h3>
<field name="name"/>
</h3>
</div>
<group>
<group>
<field name="animal_type"/>
<field name="sex"/>
</group>
<group>
<field name="animal_dob"/>
</group>
</group>
<notebook>
<page string="Feeding Records">
</page>
<page string="Vaccination Records">
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<menuitem id="farm_menu" name="Farm Management" action="farm_menu_action"/>
<menuitem id="farm_animal_menu" parent="farm_menu" name="Farm Animals"/>
</data>
</odoo>
farm_records_view.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="farm_menu_action" model="ir.actions.act_window">
<field name="name">Animals</field>
<field name="res_model">farmanimal.farmanimal</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="or_view_nocontent_create">Create The First Animal
</p>
</field>
</record>
<!--farm animals tree view-->
<record id="farm_tree_view" model="ir.ui.view">
<field name="name">Animal Tree</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<tree string="Animals">
<field name="name"/>
<field name="sex"/>
<field name="animal_type"/>
<field name="animal_dob"/>
</tree>
</field>
</record>
<!--farm animals kanban view-->
<record id="farm_kanban_view" model="ir.ui.view">
<field name="name">farmanimal.farmanimal.kanban</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<kanban class="o_res_farm_kanban">
<field name="id"/>
<field name="name"/>
<field name="sex"/>
<field name="animal_type"/>
<field name="animal_dob"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_global_click">
<div class="o_kanban_image">
<img alt="Avatar" t-att-src="kanban_image('farmanimal.farmanimal','photo',record.id.raw_value)"/>
</div>
<div class="oe_kanban_details">
<strong class="o_kanban_record_title">
<field name="name"/>
</strong>
<div t-if="record.animal_type.value">
<t t-esc="record.animal_type.value"/>
</div>
<div t-if="record.sex.value">
<t t-esc="record.sex.value"/>
</div>
<div t-if="record.animal_dob.value">
<t t-esc="record.animal_dob.value"/>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!--farm animals form view-->
<record id="farm_free_view" model="ir.ui.view">
<field name="name">Animal Form</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<form string="Animal">
<sheet>
<field name="photo" widget="image" class="oe_left oe_avatar" />
<div class="oe_title">
<h3>
<field name="name"/>
</h3>
</div>
<group>
<group>
<field name="animal_type"/>
<field name="sex"/>
</group>
<group>
<field name="animal_dob"/>
</group>
</group>
<notebook>
<page string="Feeding Records">
</page>
<page string="Vaccination Records">
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<menuitem id="farm_menu" name="Farm Management" action="farm_menu_action"/>
<menuitem id="farm_animal_menu" parent="farm_menu" name="Farm Animals"/>
</data>
</odoo>
feed_records_view.py
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="feeding_menu_action" model="ir.actions.act_window">
<field name="name">Feeding Record</field>
<field name="res_model">feedrecord.feedrecord</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="or_view_nocontent_create">Create The First Feeding Record
</p>
</field>
</record>
<!--Feed tree view-->
<record id="feed_tree_view" model="ir.ui.view">
<field name="name">Feeding Record Tree</field>
<field name="model">feedrecord.feedrecord</field>
<field name="arch" type="xml">
<tree string="Feeding Record">
<field name="feed_animal"/>
<field name="feed_name"/>
<field name="amount"/>
<field name="feed_date_time"/>
</tree>
</field>
</record>
<!--feeding form view-->
<record id="feeding_free_view" model="ir.ui.view">
<field name="name">Feeding Record Form</field>
<field name="model">feedrecords.feedrecords</field>
<field name="arch" type="xml">
<form string="Feeding Records">
<sheet>
<div class="oe_title">
<h1>
<field name="feed_animal"/>
</h1>
</div>
<group>
<group>
<field name="feed_name"/>
<field name="amount"/>
<field name="feed_date_time"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
</data>
</odoo>
feeds_view.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="feeds_menu_action" model="ir.actions.act_window">
<field name="name">Feeds</field>
<field name="res_model">feed.feed</field>
<field name="view_type">form</field>
<field name="view_mode">kaban,tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="or_view_nocontent_create">Create The First Feed
</p>
</field>
</record>
<!--Feed tree view-->
<record id="feed_tree_view" model="ir.ui.view">
<field name="name">Feeds</field>
<field name="model">feed.feed</field>
<field name="arch" type="xml">
<tree string="Feeds">
<field name="f_name"/>
</tree>
</field>
</record>
<!--feed kanban view-->
<record id="feed_kanban_view" model="ir.ui.view">
<field name="name">feed.feed.kanban</field>
<field name="model">feed.feed</field>
<field name="arch" type="xml">
<kanban class="o_res_farm_kanban">
<field name="id"/>
<field name="f_name"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_global_click">
<div class="o_kanban_image">
<img alt="Avatar" t-att-src="kanban_image('feed.feed','f_photo',record.id.raw_value)"/>
</div>
<div class="oe_kanban_details">
<strong class="o_kanban_record_title">
<field name="f_name"/>
</strong>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!--feeding form view-->
<record id="feed_free_view" model="ir.ui.view">
<field name="name">Feeds</field>
<field name="model">feed.feed</field>
<field name="arch" type="xml">
<form string="Feeds">
<sheet>
<field name="f_photo" widget="image" class="oe_left oe_avatar" />
<div class="oe_title">
<h1>
<field name="f_name"/>
</h1>
</div>
</sheet>
</form>
</field>
</record>
</data>
</odoo>
您需要重新审视您定义 menuitem
的方式。参考一下the Odoo documentation
父级 菜单不应有任何 action
。仅应为最终(子)菜单分配操作。
例如,而不是你目前拥有的:
<menuitem id="farm_menu" name="Farm Management"
action="farm_menu_action"/>
<menuitem id="farm_animal_menu" name="Farm Animals"
parent="farm_menu"/>
你应该这样做:
<menuitem id="farm_menu" name="Farm Management"/>
<menuitem id="farm_animal_menu" name="Farm Animals"
parent="farm_menu"
action="farm_menu_action"/>
我是 odoo 的新手,正在尝试构建自定义模块。我删除了一些视图上的菜单项,但我仍然遇到同样的错误。当我尝试向 farm_menu
添加子菜单时出现以下错误。我如何使菜单像这样工作?
动物
*饲料
*喂食记录
非常感谢您的帮助。
错误
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/tools/cache.py", line 88, in lookup
r = d[key]
File "/opt/odoo/odoo/odoo/tools/func.py", line 69, in wrapper
return func(self, *args, **kwargs)
File "/opt/odoo/odoo/odoo/tools/lru.py", line 44, in __getitem__
a = self.d[obj].me
KeyError: ('ir.ui.menu', <function IrUiMenu.load_menus at 0x7f3f849090d0>, 2, None, ('en_US',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/tools/cache.py", line 88, in lookup
r = d[key]
File "/opt/odoo/odoo/odoo/tools/func.py", line 69, in wrapper
return func(self, *args, **kwargs)
File "/opt/odoo/odoo/odoo/tools/lru.py", line 44, in __getitem__
a = self.d[obj].me
KeyError: ('ir.ui.menu', <function IrUiMenu._visible_menu_ids at 0x7f3f848fc730>, frozenset({1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 79, 80, 81, 82, 84, 85}), None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/api.py", line 1049, in get
value = self._data[key][field][record._ids[0]]
KeyError: 62
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/fields.py", line 1005, in __get__
value = record.env.cache.get(record, self)
File "/opt/odoo/odoo/odoo/api.py", line 1051, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('ir.ui.menu(62,).action', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mustaf/.local/lib/python3.6/site-packages/werkzeug/serving.py", line 304, in run_wsgi
execute(self.server.app)
File "/home/mustaf/.local/lib/python3.6/site-packages/werkzeug/serving.py", line 292, in execute
application_iter = app(environ, start_response)
File "/opt/odoo/odoo/odoo/service/server.py", line 434, in app
return self.app(e, s)
File "/opt/odoo/odoo/odoo/service/wsgi_server.py", line 142, in application
return application_unproxied(environ, start_response)
File "/opt/odoo/odoo/odoo/service/wsgi_server.py", line 117, in application_unproxied
result = odoo.http.root(environ, start_response)
File "/opt/odoo/odoo/odoo/http.py", line 1320, in __call__
return self.dispatch(environ, start_response)
File "/opt/odoo/odoo/odoo/http.py", line 1293, in __call__
return self.app(environ, start_wrapped)
File "/home/mustaf/.local/lib/python3.6/site-packages/werkzeug/middleware/shared_data.py", line 220, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/odoo/http.py", line 1488, in dispatch
result = ir_http._dispatch()
File "/opt/odoo/odoo/addons/auth_signup/models/ir_http.py", line 19, in _dispatch
return super(Http, cls)._dispatch()
File "/opt/odoo/odoo/addons/web_editor/models/ir_http.py", line 22, in _dispatch
return super(IrHttp, cls)._dispatch()
File "/opt/odoo/odoo/addons/http_routing/models/ir_http.py", line 403, in _dispatch
result = super(IrHttp, cls)._dispatch()
File "/opt/odoo/odoo/odoo/addons/base/models/ir_http.py", line 207, in _dispatch
return cls._handle_exception(e)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_http.py", line 177, in _handle_exception
return request._handle_exception(exception)
File "/opt/odoo/odoo/odoo/http.py", line 776, in _handle_exception
return super(HttpRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo/odoo/http.py", line 314, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/odoo/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/opt/odoo/odoo/odoo/addons/base/models/ir_http.py", line 203, in _dispatch
result = request.dispatch()
File "/opt/odoo/odoo/odoo/http.py", line 835, in dispatch
r = self._call_function(**self.params)
File "/opt/odoo/odoo/odoo/http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 941, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 519, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 457, in web_client
context = request.env['ir.http'].webclient_rendering_context()
File "/opt/odoo/odoo/addons/web/models/ir_http.py", line 17, in webclient_rendering_context
'menu_data': request.env['ir.ui.menu'].load_menus(request.debug),
File "</home/mustaf/.local/lib/python3.6/site-packages/decorator.py:decorator-gen-31>", line 2, in load_menus
File "/opt/odoo/odoo/odoo/tools/cache.py", line 93, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 234, in load_menus
menu_roots = self.get_user_roots()
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 204, in get_user_roots
return self.search([('parent_id', '=', False)])
File "/opt/odoo/odoo/odoo/models.py", line 1562, in search
res = self._search(args, offset=offset, limit=limit, order=order, count=count)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 135, in _search
menus = menus._filter_visible_menus()
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 125, in _filter_visible_menus
visible_ids = self._visible_menu_ids(request.debug if request else False)
File "</home/mustaf/.local/lib/python3.6/site-packages/decorator.py:decorator-gen-28>", line 2, in _visible_menu_ids
File "/opt/odoo/odoo/odoo/tools/cache.py", line 93, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 94, in _visible_menu_ids
action_menus = menus.filtered(lambda m: m.action and m.action.exists())
File "/opt/odoo/odoo/odoo/models.py", line 4901, in filtered
return self.browse([rec.id for rec in self if func(rec)])
File "/opt/odoo/odoo/odoo/models.py", line 4901, in <listcomp>
return self.browse([rec.id for rec in self if func(rec)])
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_menu.py", line 94, in <lambda>
action_menus = menus.filtered(lambda m: m.action and m.action.exists())
File "/opt/odoo/odoo/odoo/fields.py", line 1009, in __get__
self.determine_value(record)
File "/opt/odoo/odoo/odoo/fields.py", line 1112, in determine_value
record._prefetch_field(self)
File "/opt/odoo/odoo/odoo/models.py", line 2843, in _prefetch_field
result = records.read([f.name for f in fs], load='_classic_write')
File "/opt/odoo/odoo/odoo/models.py", line 2781, in read
self._read_from_database(stored, inherited)
File "/opt/odoo/odoo/odoo/models.py", line 2934, in _read_from_database
values = [convert(value, target, validate=False) for value in values]
File "/opt/odoo/odoo/odoo/models.py", line 2934, in <listcomp>
values = [convert(value, target, validate=False) for value in values]
File "/opt/odoo/odoo/odoo/fields.py", line 2032, in convert_to_cache
if record.env[res_model].browse(int(res_id)).exists():
File "/opt/odoo/odoo/odoo/api.py", line 831, in __getitem__
return self.registry[model_name]._browse((), self)
File "/opt/odoo/odoo/odoo/modules/registry.py", line 176, in __getitem__
return self.models[model_name]
KeyError: 'ir.actions.view'
animals.py
from odoo import models, fields
class FarmAnimalsFarmAnimals(models.Model):
_name ='farmanimal.farmanimal'
name= fields.Char(string='Name', required=True)
photo = fields.Binary(string='Image')
sex = fields.Selection([('male','Male'),('female','Female')], string='Sex')
animal_dob = fields.Date(string='Date of birth/entry')
animal_type = fields.Selection(
[('cow','Cow'), ('bull','Bull'), ('goat','Goat'), ('sheep','Sheep'),
('fish','Fish'), ('rabbit','Rabbit'), ('chicken','Chicken'), ('turkey','Turkey'),
('ducks','Ducks'),('quells','Quells'),('camel','Camel'), ('horse','Horse'),],
string='Animal Type')
feeds.py
from odoo import models, fields
class FeedsFeeds(models.Model):
_name ='feed.feed'
f_name = fields.Char(string='Feed Name', required=True)
f_photo = fields.Binary(string='Product Image')
feed_records.py
from odoo import models, fields
class FeedRecordsFeedRecords(models.Model):
_name ='feedrecord.feedrecord'
_inherits={'farmanimal.farmanimal','feed.feed'}
feed_animal = fields.Many2one( 'farmanimal.farmanimal','feed_animal_default_rel','name', string='Feed Animal',)
feed_name = fields.Many2many('feed.feed', 'feed_default_rel', 'f_name', string='Consumed Feed(s)',)
amount = fields.Integer(string='Amount(In Grams)',)
feed_date_time = fields.Datetime(string='Date and Time',default=fields.Datetime.now,)
vaccines.py
from odoo import models, fields
class VaccinesVaccines(models.Model):
_name ='vaccine.vaccine'
v_name = fields.Char(string='Vaccine Name', required=True)
v_photo = fields.Binary(string='Product Image')
vaccinations_records.py
from odoo import models, fields
class VaccinationRecordsVaccinationRecords(models.Model):
_name ='vaccinationrecord.vaccinationrecord'
_inherits={'farmanimal.farmanimal','vaccine.vaccine'}
vaccinated_animal = fields.Many2one( 'farmanimal.farmanimal','vaccinated_animal_default_rel','name', string='Vacinated Animal',)
vaccine_name = fields.Many2many('vaccine.vaccine', 'vaccine_default_rel', 'v_name', string='Vaccine(s)',)
vaccination_date_time = fields.Datetime(string='Date and Time',default=fields.Datetime.now,)
next_vaccination_date = fields.Date(string='Next Date',)
diseases.py
from odoo import models, fields
class DiseasesDiseases(models.Model):
_name ='disease.disease'
_inherits='vaccine.vaccine'
d_name= fields.Char(string='Name', required=True)
d_type = fields.Selection(
[('infectious disease','Infectious Disease'), ('deficiency disease','Deficiency Disease'), ('hereditary disease','Hereditary Disease'), ('physiological diseases','Physiological Diseases')], string='Disease Type')
s_vector = fields.Selection(
[('airborne','Airborne'), ('foodborne','Foodborne'), ('infectious','Infectious'), ('lifestyle','Lifestyle'), ('non-communicable','Non-communicable')],
string='Spread Vector')
threat_level = fields.Selection(
[('high','High'), ('medium','Medium'), ('low','Low'), ('immediate quarantine','Immediate Quarantine')], string='Threat Level')
cure = fields.Many2many('vaccine.vaccine', 'disease_cure_default_rel', 'v_name', string='Cure')
farm_view.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="farm_menu_action" model="ir.actions.act_window">
<field name="name">Animals</field>
<field name="res_model">farmanimal.farmanimal</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="or_view_nocontent_create">Create The First Animal
</p>
</field>
</record>
<!--farm animals tree view-->
<record id="farm_tree_view" model="ir.ui.view">
<field name="name">Animal Tree</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<tree string="Animals">
<field name="name"/>
<field name="sex"/>
<field name="animal_type"/>
<field name="animal_dob"/>
</tree>
</field>
</record>
<!--farm animals kanban view-->
<record id="farm_kanban_view" model="ir.ui.view">
<field name="name">farmanimal.farmanimal.kanban</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<kanban class="o_res_farm_kanban">
<field name="id"/>
<field name="name"/>
<field name="sex"/>
<field name="animal_type"/>
<field name="animal_dob"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_global_click">
<div class="o_kanban_image">
<img alt="Avatar" t-att-src="kanban_image('farmanimal.farmanimal','photo',record.id.raw_value)"/>
</div>
<div class="oe_kanban_details">
<strong class="o_kanban_record_title">
<field name="name"/>
</strong>
<div t-if="record.animal_type.value">
<t t-esc="record.animal_type.value"/>
</div>
<div t-if="record.sex.value">
<t t-esc="record.sex.value"/>
</div>
<div t-if="record.animal_dob.value">
<t t-esc="record.animal_dob.value"/>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!--farm animals form view-->
<record id="farm_free_view" model="ir.ui.view">
<field name="name">Animal Form</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<form string="Animal">
<sheet>
<field name="photo" widget="image" class="oe_left oe_avatar" />
<div class="oe_title">
<h3>
<field name="name"/>
</h3>
</div>
<group>
<group>
<field name="animal_type"/>
<field name="sex"/>
</group>
<group>
<field name="animal_dob"/>
</group>
</group>
<notebook>
<page string="Feeding Records">
</page>
<page string="Vaccination Records">
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<menuitem id="farm_menu" name="Farm Management" action="farm_menu_action"/>
<menuitem id="farm_animal_menu" parent="farm_menu" name="Farm Animals"/>
</data>
</odoo>
farm_records_view.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="farm_menu_action" model="ir.actions.act_window">
<field name="name">Animals</field>
<field name="res_model">farmanimal.farmanimal</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="or_view_nocontent_create">Create The First Animal
</p>
</field>
</record>
<!--farm animals tree view-->
<record id="farm_tree_view" model="ir.ui.view">
<field name="name">Animal Tree</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<tree string="Animals">
<field name="name"/>
<field name="sex"/>
<field name="animal_type"/>
<field name="animal_dob"/>
</tree>
</field>
</record>
<!--farm animals kanban view-->
<record id="farm_kanban_view" model="ir.ui.view">
<field name="name">farmanimal.farmanimal.kanban</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<kanban class="o_res_farm_kanban">
<field name="id"/>
<field name="name"/>
<field name="sex"/>
<field name="animal_type"/>
<field name="animal_dob"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_global_click">
<div class="o_kanban_image">
<img alt="Avatar" t-att-src="kanban_image('farmanimal.farmanimal','photo',record.id.raw_value)"/>
</div>
<div class="oe_kanban_details">
<strong class="o_kanban_record_title">
<field name="name"/>
</strong>
<div t-if="record.animal_type.value">
<t t-esc="record.animal_type.value"/>
</div>
<div t-if="record.sex.value">
<t t-esc="record.sex.value"/>
</div>
<div t-if="record.animal_dob.value">
<t t-esc="record.animal_dob.value"/>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!--farm animals form view-->
<record id="farm_free_view" model="ir.ui.view">
<field name="name">Animal Form</field>
<field name="model">farmanimal.farmanimal</field>
<field name="arch" type="xml">
<form string="Animal">
<sheet>
<field name="photo" widget="image" class="oe_left oe_avatar" />
<div class="oe_title">
<h3>
<field name="name"/>
</h3>
</div>
<group>
<group>
<field name="animal_type"/>
<field name="sex"/>
</group>
<group>
<field name="animal_dob"/>
</group>
</group>
<notebook>
<page string="Feeding Records">
</page>
<page string="Vaccination Records">
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<menuitem id="farm_menu" name="Farm Management" action="farm_menu_action"/>
<menuitem id="farm_animal_menu" parent="farm_menu" name="Farm Animals"/>
</data>
</odoo>
feed_records_view.py
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="feeding_menu_action" model="ir.actions.act_window">
<field name="name">Feeding Record</field>
<field name="res_model">feedrecord.feedrecord</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="or_view_nocontent_create">Create The First Feeding Record
</p>
</field>
</record>
<!--Feed tree view-->
<record id="feed_tree_view" model="ir.ui.view">
<field name="name">Feeding Record Tree</field>
<field name="model">feedrecord.feedrecord</field>
<field name="arch" type="xml">
<tree string="Feeding Record">
<field name="feed_animal"/>
<field name="feed_name"/>
<field name="amount"/>
<field name="feed_date_time"/>
</tree>
</field>
</record>
<!--feeding form view-->
<record id="feeding_free_view" model="ir.ui.view">
<field name="name">Feeding Record Form</field>
<field name="model">feedrecords.feedrecords</field>
<field name="arch" type="xml">
<form string="Feeding Records">
<sheet>
<div class="oe_title">
<h1>
<field name="feed_animal"/>
</h1>
</div>
<group>
<group>
<field name="feed_name"/>
<field name="amount"/>
<field name="feed_date_time"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
</data>
</odoo>
feeds_view.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="feeds_menu_action" model="ir.actions.act_window">
<field name="name">Feeds</field>
<field name="res_model">feed.feed</field>
<field name="view_type">form</field>
<field name="view_mode">kaban,tree,form</field>
<field name="domain">[]</field>
<field name="help" type="html">
<p class="or_view_nocontent_create">Create The First Feed
</p>
</field>
</record>
<!--Feed tree view-->
<record id="feed_tree_view" model="ir.ui.view">
<field name="name">Feeds</field>
<field name="model">feed.feed</field>
<field name="arch" type="xml">
<tree string="Feeds">
<field name="f_name"/>
</tree>
</field>
</record>
<!--feed kanban view-->
<record id="feed_kanban_view" model="ir.ui.view">
<field name="name">feed.feed.kanban</field>
<field name="model">feed.feed</field>
<field name="arch" type="xml">
<kanban class="o_res_farm_kanban">
<field name="id"/>
<field name="f_name"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_global_click">
<div class="o_kanban_image">
<img alt="Avatar" t-att-src="kanban_image('feed.feed','f_photo',record.id.raw_value)"/>
</div>
<div class="oe_kanban_details">
<strong class="o_kanban_record_title">
<field name="f_name"/>
</strong>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!--feeding form view-->
<record id="feed_free_view" model="ir.ui.view">
<field name="name">Feeds</field>
<field name="model">feed.feed</field>
<field name="arch" type="xml">
<form string="Feeds">
<sheet>
<field name="f_photo" widget="image" class="oe_left oe_avatar" />
<div class="oe_title">
<h1>
<field name="f_name"/>
</h1>
</div>
</sheet>
</form>
</field>
</record>
</data>
</odoo>
您需要重新审视您定义 menuitem
的方式。参考一下the Odoo documentation
父级 菜单不应有任何 action
。仅应为最终(子)菜单分配操作。
例如,而不是你目前拥有的:
<menuitem id="farm_menu" name="Farm Management"
action="farm_menu_action"/>
<menuitem id="farm_animal_menu" name="Farm Animals"
parent="farm_menu"/>
你应该这样做:
<menuitem id="farm_menu" name="Farm Management"/>
<menuitem id="farm_animal_menu" name="Farm Animals"
parent="farm_menu"
action="farm_menu_action"/>