就用上篇博客中继承的官方模模块的产品界面做演示。【产品类型的字段为 detailed_type】
我们在product里的product_template.py直接ctrl+f 【detailed_type】就找到了。是一个fields.Selection字段。但是只有【能消耗】与【服务】两个字段。
实现的效果是把这个Test移动到服务的上边:
代码:selection_add=[(你添加的选项), (官方的选项名)] 就添加到这个service上边了
from odoo import api, fields, models
class Testondelete(models.Model):
_inherit = 'product.template'
detailed_type = fields.Selection(selection_add=[('test', 'Test'), ('service',)],
tracking=True, ondelete={'test': 'set default'})
同理可测试一下添加到 能消耗【Consumable】的上边:
完全没什么问题,至于为什么把这个小括号添加到后面而不是前边:
可在fields里找到官方给的规则: