我必须创建一个名为Category的manyOne或Selection字段和一个名为echelon的字段。对于一个类别,我们联想到许多梯队。这就像选择国家的例子,对于这个国家,我们通过关联的细分填充另一个字段。我的代码:
categoryy=fields.Many2One("grh.category","Category")
ech = fields.Many2One("grh.echelon",'echelon', depends=[ 'categoryy'])
@fields.depends('ech', 'categoryy')
def on_change_categoryy(self):
if (self.ech
and self.ech.echeloncategory != self.categoryy):
return {'ech': None}
return {}
from trytond.model import ModelView,ModelSQL,fields
from trytond.pool import Pool
__all__ = ['category']
class category(ModelView,ModelSQL):
'''category'''
__name__ = "grh.category"
category=fields.Char("category")
echelons=fields.One2Many("grh.echelon","echeloncategory","Category echelons")
我不知道为什么“梯队”场上显示了所有的梯队
请帮帮我
您应该使用domain子句来限制
ech
字段上的可用选项。您可以在以下位置找到域的完整引用:http://doc.tryton.org/3.2/trytond/doc/topics/domain.html?highlight=domain
此外,您必须使用PYSON来获取类别的当前值,因此您将得到如下结果:
您可以在以下网站找到关于PYSON的介绍:
http://doc.tryton.org/3.2/trytond/doc/topics/pyson.html
相关问题 更多 >
编程相关推荐