1
我想为country_id字段设置默认国家“香港”。那么我为odoo10写的是什么函数。现在我的Python代码如下:设置默认国家
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')
是的,你是对的Odedra。我已经通过添加以下代码来完成此操作:country_id = fields.Many2one('res.country',“Country”,change_default = True,default = _get_default_country)@ api.model 012_bdef _get_default_country(self): print“yes: “,95 返回95 –