py代码:
@api.depends('country_id')
def _get_default_country(self, context=None):
if self.country_id:
return {'domain': [('country_id', '=', self.country_id.id)]}
print "yes:", 235
return True
_defaults = {
'country_id': _get_default_country
}
country_info = fields.Char(compute='_get_default_country',
string='Default Country')
返回值始终与字段数据类型匹配。在您的例子中,存储“char”值并返回“Boolean”(true/false)。这没道理。在
如果您想要下拉列表,那么将“country_info”数据类型从“Char”更改为“manyOne”,并且您的默认函数应该根据您的逻辑返回“integer”值。在
Python Lambda函数主要与filter()、map()和reduce()函数结合使用。在
奥多10
Python代码:
XML代码:
^{pr2}$相关问题 更多 >
编程相关推荐