[英]Why I have error in Odoo while using product.template
I'm trying to run a test task from the site https://www.odoo.com/documentation/15.0/developer/howtos/website.html我正在尝试从网站https://www.odoo.com/documentation/15.0/developer/howtos/website.html运行测试任务
models.py模型.py
from odoo import models, fields, api
class Teachers(models.Model):
_name = 'academy.teachers'
name = fields.Char()
biography = fields.Html()
course_ids = fields.One2many('academy.courses', 'teacher_id', string="Courses")
class Courses(models.Model):
_name = 'academy.courses'
_inherit = 'product.template'
teacher_id = fields.Many2one('academy.teachers', string="Teacher")
but when start odoo i have error但是当启动odoo时我有错误
TypeError: Many2many fields academy.courses.taxes_id and product.template.taxes_id use the same table and columns - - -
don't understand how to remove this error Бany2many fields academy.courses.taxes_id and product.template.taxes_id use the same table and columns
不明白如何消除这个错误
Бany2many fields academy.courses.taxes_id and product.template.taxes_id use the same table and columns
When you inherit the product.template
models and set the _name
attribute, Odoo will copy the fields with all their attributes, and in case of taxes_id
, supplier_taxes_id
and route_ids
, the relation
is set manually which will be the same in academy.courses
model.当您继承
product.template
模型并设置_name
属性时,Odoo 将复制字段及其所有属性,对于taxes_id
、 supplier_taxes_id
和route_ids
, relation
是手动设置的,这与academy.courses
model 中的关系相同。
When Odoo will try to check whether other fields use the same schema it will fail and raise the error you see in the log.当 Odoo 尝试检查其他字段是否使用相同的模式时,它将失败并引发您在日志中看到的错误。
Edit:编辑:
There are many references to product.template
in model fields and methods. model的字段和方法中有很多引用了
product.template
。 Even if you fix that error, the product_tmpl_id
field still referece the product template model and this will prevent Odoo from creating any course.即使您修复了该错误,
product_tmpl_id
字段仍然引用产品模板 model,这将阻止 Odoo 创建任何课程。
When you change for example the product code it will check if the code is already used in product template model which is wrong.例如,当您更改产品代码时,它会检查代码是否已在产品模板 model 中使用,这是错误的。
Using only the _inherit
attribute, you can`t inherit the product template model.仅使用
_inherit
属性,您无法继承产品模板 model。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.