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 def _get_default_country(self): print "yes: "、95 リターン95 –