+ def _bikecoop_activity_dates_check(self, cr, uid, ids, context=None):
+ # TODO: check condition and return boolean accordingly
+ currentDateTime = datetime.datetime.now()
+ date = currentDateTime.date()
+ year = date.strftime("%Y")
+
+ min_date = 1950
+ max_date = int(year)
+
+ for partner in self.browse(cr, uid, ids, context=context):
+ if partner.bikecoop_activity_start == 0 and partner.bikecoop_activity_stop == 0:
+ return True
+ if partner.bikecoop_activity_start < 0 or partner.bikecoop_activity_stop < 0:
+ return False
+ if partner.bikecoop_activity_start == 0 and partner.bikecoop_activity_stop > 0:
+ return False
+ if partner.bikecoop_activity_stop > max_date or partner.bikecoop_activity_stop < min_date:
+ if partner.bikecoop_activity_stop != 0:
+ return False
+ if partner.bikecoop_activity_start > max_date or partner.bikecoop_activity_start < min_date:
+ if partner.bikecoop_activity_start != 0:
+ return False
+ if partner.bikecoop_activity_stop < partner.bikecoop_activity_start:
+ if partner.bikecoop_activity_stop != 0:
+ return False
+ return True
+
+ def _rna_check(self, cr, uid, ids, context=None):
+ """Check if RNA code is well formatted"""
+ for partner in self.browse(cr, uid, ids, context=context):
+ if partner.rna:
+ if len(partner.rna) != 10:
+ return False
+ if partner.rna[0] != 'W':
+ return False
+ try:
+ int(partner.rna[1:10])
+ except ValueError:
+ return False
+ return True
+ else:
+ return True
+
+
+ def _siret_check(self, cr, uid, ids, context=None):
+ """Check if SIRET code is well formatted"""
+ for partner in self.browse(cr, uid, ids, context=context):
+ if partner.siret:
+ if len(partner.siret) != 14:
+ return False
+ try:
+ int(partner.siret)
+ except ValueError:
+ return False
+ return True
+ else:
+ return True
+
+