我想检索函数中的活动记录。
这是我的代码:
def no_duplicate_school_dates(self):
if self.school_registration or self.school_end_date:
print "Je commence ma fonction"
# Récupérer les enregistrement actifs
records = self.env['ecole.partner.school'].search([])
for rec in records:
if rec.school_registration and rec.school_end_date:
if (self.school_registration >= rec.school_registration and self.school_registration <= rec.school_end_date)\
or (self.school_end_date >= rec.school_registration and self.school_end_date <= rec.school_end_date) :
print "doublon trouvé"
# raise ValidationError("Erreur : La plage de date en chevauche une autre")
else:
print "Pas de doublon trouvé"
我应该在这行上写些什么?
records = self.env['ecole.partner.school'].search([])
谢谢
编辑:在我的模型“ ecole.partner.school”中,我有一个关系字段。
class ResPartner(models.Model):
_inherit = 'res.partner'
scholarship_ids = fields.One2many(string='School card', comodel_name='ecole.partner.school',
inverse_name='partner_id')
我希望将记录链接到同一伙伴。一个伙伴可以在学校的不同日期多次注册。而且我正在尝试仅恢复同一伙伴的记录。我将在问题中提供更多信息