Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从Odoo中的现有选择中删除项目_Python_Xml_Python 3.x_Python 2.7_Odoo - Fatal编程技术网

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

Python 从Odoo中的现有选择中删除项目,python,xml,python-3.x,python-2.7,odoo,Python,Xml,Python 3.x,Python 2.7,Odoo,我在联系人表单的选择中有预先存在的密钥。我使用“selection\u add”参数添加了新的键,我想找出selection\u add参数的相反之处,以便从选择中删除任何旧键。不幸的是,没有任何selection\u remove选项。您可以完全重新定义字段的选择值,删除不需要的选项 如果字段定义为: class ResPartner(models.Model): _name = 'res.partner' some_field = fields.Selection(stri

我在联系人表单的选择中有预先存在的密钥。我使用“selection\u add”参数添加了新的键,我想找出selection\u add参数的相反之处,以便从选择中删除任何旧键。

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

如果字段定义为:

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

    some_field = fields.Selection(string='Some Field',
                                  selection=[('a', 'A'),  ('b', 'B'), ('c', 'C')])
然后可以继承该类并重写字段的选择值

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

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