我想选择字段many2one选择阶段,如果我在选择阶段视图错误中点击搜索更多。
这是我的选择阶段代码:
class SelectionStage(models.Model):
_name = 'estate.nursery.selectionstage'
#_inherit = 'estate.nursery.selection'
name = fields.Char(string="Selection Stage")
age_limit_max= fields.Integer(string="Age Max",required=True)
age_limit_min= fields.Integer(string="Age Min",required=True)
age_selection= fields.Integer(string="Age Selection",required=True)
info = fields.Selection([('draft','Draft'),('0','Age selection not less than age limit min'),
('1','Age selection not more than age limit max'),
('2','passed'),("3","Age Limit min not less than 1"),
("4","Age Limit min not more than 12")],
compute='calculateinfo', default='draft', string="Information" ,
readonly=True,required=False)
comment = fields.Text(string="Description or Comment")
stage_id = fields.Many2one('estate.nursery.stage',"Nursery Stage",)
#Limit age
@api.one
@api.depends("age_limit_max","age_limit_min","age_selection","info",)
def calculateinfo(self):
maxa =self.age_limit_max
mina=self.age_limit_min
limitmax = self.age_limit_max
limitmin = 1
limit=[1,2,3,4,5,6,7,8,9,10,11,12]
for a in limit:
limitmax = a
if maxa and mina :
if maxa == limitmax:
self.info = "2"
if self.age_selection >= maxa:
self.info = "1"
elif self.age_selection <= mina:
self.info = "0"
else:
inf = "2"
elif maxa >= limitmax:
self.info="4"
elif mina < limitmin:
self.info="3"
这是我的estate.nursery.stage代码:
class Stage(models.Model):
"""
Seed nursery has two kind of method. First, single stage. Second, double stage (common).
"""
_name = 'estate.nursery.stage'
#_sequence = 'sequence,name'
#_defaults = { 'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'code'), }
name = fields.Char("Nursery Stage", required=True)
code = fields.Char("Short Name", help="Use for reporting label purposes.", size=3)
sequence = fields.Integer("Sequence No")
age_minimum = fields.Integer("Minimum Age", help="Minimum age required to be at this stage. 0 is unlimited.")
age_maximum = fields.Integer("Maximum Age", help="Maximum age required to be at this stage. 0 is unlimited.")