采取这种情况:
class Model1(models.Model):
_name = "model1"
_description = "Model 1"
custom_field = fields.One2many(
'model2',
'registration',
)
class Model2(models.Model):
_name = "model2"
_description = "Model 2"
field_name = fields.Char(
'Field Name',
required=True,
)
field_value = fields.Char(
'Field Value',
required=True,
)
registration = fields.Many2one(
'model1',
required=True,
)
所需输出:
根据where过滤model1
odoo 树视图中的记录。应该由用户输入。是存储为 str 的浮点数。field_value
field_name="amount"
field_value
amount
当前过滤器(静态):
domain="['&',('custom_field.field_name','=','amount'),('custom_field.field_value','>','100.0')]"
实际输出:
model1
在上述情况下被过滤的记录amount='20'
。(字符串比较'20'>'100.0'
)。这100.0
是由用户在界面中输入的。
我从odoo.com 上的论坛帖子“如何在域过滤器中使用动态值?”尝试了这个解决方案。
输出:
Uncaught TypeError: Cannot read property 'fields' of null
请帮忙!感谢您的时间!