You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Odoo继承product.product模型时触发500错误,服务器崩溃

Fixing "TypeError: Model 'product.product' does not exist in registry" When Inheriting product.product in Odoo

Hey, let's break down what's going wrong here and fix it quickly.

The core issue in your code is that you're mixing up Odoo's model inheritance syntax. When you want to extend an existing model (like product.product from the product/website_sale modules), you don't need to set the _name attribute—only _inherit is required.

Here's why your code caused the 500 error:

  • By setting _name = 'product.product' alongside _inherit = 'product.product', you're telling Odoo to redefine the product.product model from scratch, instead of inheriting and extending the existing one.
  • Odoo loads modules in a specific order, and your custom module is trying to redefine the model before the original product module has registered it in the system registry. That's why you get the "Model does not exist" error.

The Corrected Code

Replace your models.py with this:

# -*- coding: utf-8 -*- 
from odoo import models, fields, api 

class ImgToGifProductExtension(models.Model): 
    _inherit = 'product.product' 

    # Add your custom fields, methods, or overrides here
    # Example:
    # custom_description = fields.Text(string="Custom GIF Description")

Additional Checks to Ensure Everything Works

  • Module Dependencies: Make sure your custom module depends on the product module (since product.product originates there) and website_sale if you need its features. Update your __manifest__.py file:
    'depends': ['product', 'website_sale'],
    
  • Class Naming: The class name can be anything descriptive (I used ImgToGifProductExtension here)—it doesn't have to match the original model name.
  • Restart & Upgrade: After fixing the code, restart your Odoo server and upgrade your custom module through the Odoo interface.

That should resolve the server crash and let you extend the product.product model as intended.

内容的提问来源于stack exchange,提问作者Mike2233

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 16:17:31