如何解决ODOO 选择 - 在某些条件下隐藏一些选项
我在 xml 文件中有一个 customer_type 选择字段,但我需要根据条件隐藏 4 个选择中的 2 个。
到目前为止,这是我在 python 中的代码
res_partner.py
customer_type = fields.Selection([
('cash_customer','Cash Customer'),('credit_customer','Credit Customer'),('cash_customer_vendor','Cash Customer and Vendor'),('credit_customer_vendor','Credit Customer and Vendor')],string="Customer Type" )
res_partner.xml
<field name="customer_type"
attrs="{'required':
[('customer_tick','=',True)],'invisible': [('customer_tick','!=',True)]}"/>
我的情况是
vendor_state = 'vendor'
解决方法
安德里温·马昆托
不要在字段中添加 key,value
,而是尝试使用方法添加。
customer_type = fields.Selection(selection="_get_customer_type",string="Customer Type")
def _get_customer_type(self):
if self: # your codnition to check
return [('cash_customer','Cash Customer'),('credit_customer','Credit Customer'),('cash_customer_vendor','Cash Customer and Vendor'),('credit_customer_vendor','Credit Customer and Vendor')]
else:
return [('cash_customer','Credit Customer')]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。