问题
I am trying to build a custom module and i have run into the following error, i added the models to 'depends':[]
and ended up with KeyError: 'ir.actions.views'
when i remove the models from the 'depends':[]
, i get the error below:
2020-02-15 06:58:28,956 8372 ERROR mask_agro odoo.modules.registry: Failed to load registry
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/modules/registry.py", line 60, in __new__
return cls.registries[db_name]
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: 'mask_agro'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/odoo/odoo/modules/loading.py", line 417, in load_modules
force, status, report, loaded_modules, update_module, models_to_check)
File "/opt/odoo/odoo/odoo/modules/loading.py", line 313, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/opt/odoo/odoo/odoo/modules/loading.py", line 188, in load_module_graph
model_names = registry.load(cr, package)
File "/opt/odoo/odoo/odoo/modules/registry.py", line 240, in load
model = cls._build_model(self, cr)
File "/opt/odoo/odoo/odoo/models.py", line 470, in _build_model
ModelClass._build_model_attributes(pool)
File "/opt/odoo/odoo/odoo/models.py", line 535, in _build_model_attributes
cls._inherits.update(base._inherits)
ValueError: dictionary update sequence element #0 has length 1; 2 is required
2020-02-15 06:58:28,983 8372 INFO mask_agro werkzeug: 127.0.0.1 - - [15/Feb/2020 06:58:28] "GET /web HTTP/1.1" 500 - 9 0.057 1.418
2020-02-15 06:58:29,007 8372 ERROR mask_agro werkzeug: Error on request:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/modules/registry.py", line 60, in __new__
return cls.registries[db_name]
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: 'mask_agro'
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 1471, in dispatch
odoo.registry(db).check_signaling()
File "/opt/odoo/odoo/odoo/__init__.py", line 117, in registry
return modules.registry.Registry(database_name)
File "/opt/odoo/odoo/odoo/modules/registry.py", line 62, in __new__
return cls.new(db_name)
File "/opt/odoo/odoo/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/odoo/odoo/modules/loading.py", line 417, in load_modules
force, status, report, loaded_modules, update_module, models_to_check)
File "/opt/odoo/odoo/odoo/modules/loading.py", line 313, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/opt/odoo/odoo/odoo/modules/loading.py", line 188, in load_module_graph
model_names = registry.load(cr, package)
File "/opt/odoo/odoo/odoo/modules/registry.py", line 240, in load
model = cls._build_model(self, cr)
File "/opt/odoo/odoo/odoo/models.py", line 470, in _build_model
ModelClass._build_model_attributes(pool)
File "/opt/odoo/odoo/odoo/models.py", line 535, in _build_model_attributes
cls._inherits.update(base._inherits)
ValueError: dictionary update sequence element #0 has length 1; 2 is required
manifest file
{
'name': 'Farm Management',
'version':'12.0.1.0.0',
'summary':'Record and manage farm Information',
'category':'Tools',
'author':'Tumukunde Arnold',
'maintainer': 'ADD Consultancy',
'company':'ADD Consultancy',
'website':'https://www.add.ug',
'depends':['base'],
'data':[
'security/ir.model.access.csv',
'views/farm_view.xml',
'views/diseases_view.xml',
'views/feed_records_view.xml',
'views/feeds_view.xml',
'views/fvaccination_records_view.xml',
'views/vaccines_view.xml',
],
'images':[],
'license':'AGPL-3',
'installable':True,
'application':False,
'auto_install':False,
}
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')
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','Deficiency'), ('hereditary','Hereditary'), ('physiological','Physiological')], 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'), ('quarantine','Quarantine')], string='Threat Level')
cure = fields.Many2many('vaccine.vaccine', related='v_name', string='Cure')
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', related='name', string='Feed Animal',)
feed_name = fields.Many2many('feed.feed', related='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,)
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')
vaccination_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', related='name', string='Vacinated Animal',)
vaccine_name = fields.Many2many('vaccine.vaccine', related='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',)
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')
diseases_view.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="disease_menu_action" model="ir.actions.act_window">
<field name="name">Diseases</field>
<field name="res_model">disease.disease</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 Disease Record
</p>
</field>
</record>
<!--disease tree view-->
<record id="disease_tree_view" model="ir.ui.view">
<field name="name">Disease Tree</field>
<field name="model">disease.disease</field>
<field name="arch" type="xml">
<tree string="Diseases">
<field name="d_name"/>
<field name="d_type"/>
<field name="s_vector"/>
<field name="threat_level"/>
<field name="cure"/>
</tree>
</field>
</record>
<!--disease form view-->
<record id="disease_free_view" model="ir.ui.view">
<field name="name">Disease Form</field>
<field name="model">disease.disease</field>
<field name="arch" type="xml">
<form string="Disease">
<sheet>
<div class="oe_title">
<h1>
<field name="d_name"/>
</h1>
</div>
<group>
<group>
<field name="d_type"/>
<field name="s_vector"/>
</group>
<group>
<field name="threat_level"/>
<field name="cure"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<menuitem id="disease_menu" name="Diseases"
parent="farm_view.farm_menu" action="disease_menu_action"/>
</data>
</odoo>
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="main_farm_menu" name="Farm Management" />
<menuitem id="farm_menu" name="Farm Management"
parent="main_farm_menu"/>
<menuitem id="farm_animal_menu" name="Farm Animals"
parent="farm_menu" action="farm_menu_action"/>
</data>
</odoo>
I have tried a few solutions but none have worked. I think the issue is with my inheritance in the models and manifest dependencies but am at a dead end. Here is a link to the module files
来源:https://stackoverflow.com/questions/60236792/how-do-i-fix-valueerror-dictionary-update-sequence-element-0-has-length-1-2-i