When I Install a custom model(apps) in odoo 12 There are no errors and I can use this model. But when I change for example a field width in the formview I receive an KeyError like: File "C:\Bitnami\odoo-12\apps\odoo\Lib\site-packages\odoo-12.0.post20200815-py3.7.egg\odoo\modules\registry.py", line 177, in getitem return self.models [model_name] KeyError : 'qualities'
Whatever I change in formview, I'll still get the same error. PY-source
from odoo import models, fields, api, _
from odoo.tools import ustr
import math
#------------------------------------------------------------------------------
# Setup test module-1
# Skip _name = when inherit product_template -
#------------------------------------------------------------------------------
class Calc(models.Model):
_name = 'calc'
_description = 'Module t.b.v. calculation-functions
qualities_id = fields.Many2one(comodel_name="qualities", string="Karton kwaliteit")
qualities_dikte = fields.Float(string="Golf dikte", related='qualities_id.golfdikte', readonly=True)
qualities_ref = fields.Char(string="Reference", related='qualities_id.reference', readonly=True)
XML-source (part)
<div>
<field name="qualities_id" class="oe_inline" />
<field name="qualities_dikte" class="oe_inline" />
<field name="qualities_ref" class="oe_inline" />
</div>```
What can be the problem. Any advice would be welcome.
Thanks in advanced.
Problem at this line:
qualities_id = fields.Many2one(comodel_name="qualities", string="Karton kwaliteit")
When we declare any field with Many2one datatype, Odoo looks for the destination database table. In your case, table names are qualities.
Following way we can resolve it:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.