1、模块命名[驼峰命名方法]
res开头的是:resources 常见模型:res.users, res.company, res.partner, res.config.settings 等。。。
@api.model
def _selection_grade(self):
res_grade = []
grade_list = self.env[‘ir.config_parameter‘].search([(‘key‘,‘like‘,‘‘)])
for item in grade_list:
res_grade.append((item.key[12:],_(item.value)))
return res_grade
2、三级联动案例:
country_id = fields.Many2one(‘res.country‘,string=u‘国家‘)
state_id=fields.Many2one(‘res.country.state‘,domain=[(‘country_id‘,‘=‘,country_id.id)],string=u‘省份‘)
state_id=fields.Many2one(‘res.country.state‘,domain=lambda self:[(‘country_id‘,‘=‘,self.env.user.country_id.id)],string=u‘省份‘)
或
<field name="country_id" />
<field name="state_id" domain="[(‘country_id‘,‘=‘,country_id)]"/>
待完善
原文:https://www.cnblogs.com/1314520xh/p/14065745.html