如何通过扩展修改Odoo字段属性:取消网站报价订单描述字段可翻译性
website_description Field in Odoo No need to modify the original website_quote module code—you can easily fix this by creating a small custom module that inherits and overrides the field. Here's a step-by-step guide:
Step 1: Create a Custom Module
First, set up a new module (let's name it website_quote_disable_translate). Your module structure should look like this:
website_quote_disable_translate/ ├── __init__.py ├── __manifest__.py └── models/ ├── __init__.py └── sale_order.py
Step 2: Override the Field in the Model
In models/sale_order.py, inherit the sale.order model and redefine the website_description field with translate=False (keeping all other original field attributes intact):
from odoo import models, fields class SaleOrder(models.Model): _inherit = 'sale.order' website_description = fields.Html( 'Description', sanitize_attributes=False, # Preserve original sanitization behavior translate=False # Disable translation to eliminate the prompt )
Step 3: Configure the Module Manifest
Update __manifest__.py to declare dependencies and basic module details:
{ 'name': 'Disable Website Quote Description Translation', 'version': '1.0', 'category': 'Website', 'depends': ['website_quote'], # Ensure our module loads after the original 'data': [], 'installable': True, 'auto_install': False, }
Step 4: Install the Module
- Place your module folder in Odoo's
addonsdirectory (or zip it for upload). - Go to Odoo's Apps menu, click "Update Apps List".
- Search for your module name and install it.
Once installed, the website_description field will no longer trigger the "Update translations" prompt when saving sale orders, as we've explicitly disabled translation for this field.
内容的提问来源于stack exchange,提问作者Developer Marius Žilėnas

