在one2many中第二次限制选择同一记录(many2many)?

时间:2017-09-26 12:27:20

标签: openerp odoo-8

enter image description here当我在树视图one2many字段中选择第1天的选择字段值时,不应该重复第1天,它应该从第2天'日'开始:fields.selection([(1,'第1天'),(2,'第2天'),(3,'第3天'),(4,'第4天'),(5,'第5天'),'日' ),在odoo

enter image description here

1 个答案:

答案 0 :(得分:0)

@ api.onchange(' week1_meals_id'' week2_meals_id'' week3_meals_id'' week4_meals_id')     def _onchange_amount(self):         天= []

    if len(self.week1_meals_id) >5 or len(self.week2_meals_id) >5 or len(self.week3_meals_id) >5 or len(self.week4_meals_id) >5:
        raise osv.except_osv(_('Error!'),_('Only 5 days per week!!'))

    for lp in [self.week1_meals_id, self.week2_meals_id, self.week3_meals_id, self.week4_meals_id]:
        for i in lp:
            if i.day in days:
                raise osv.except_osv(_('Error!'),_('Meals for this day already exists!!'))
            else:
                days +=[ i.day]