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 –