从 Odoo 中的现有选择中删除项目

Removing items from an Existing Selection in Odoo

我在联系表的选择中有预先存在的密钥。我使用 "selection_add" 参数添加了新键,我想找出与 selection_add 参数相反的东西,以便从选择中删除任何旧键。

不幸的是,没有任何 selection_remove 选项。您可以完全重新定义该字段的 selection 值,删除不需要的选项。

如果字段定义为:

class ResPartner(models.Model):
    _name = 'res.partner'

    some_field = fields.Selection(string='Some Field',
                                  selection=[('a', 'A'),  ('b', 'B'), ('c', 'C')])

那么您可以继承class并覆盖字段的选择值

class ResPartner(models.Model):
    _inherit = 'res.partner'

    some_field = fields.Selection(selection=[('a', 'A'),  ('b', 'B')])

Odoo Fields Documentation