Skip to Content
Menu
This question has been flagged
3094 Rodiniai

Hi,

I am trying to compare year from date picker with a year in dropdown (hardcoded year), so if it doesnt match "show error".

This is my code:

 def _check_year_match(self, cr, uid, ids, context=None):
  holiday_year = self.pool.get('holiday')
  holiday_date_year = self.pool.get('holiday.line')
  hol_year1 = holiday_year.browse(cr, uid,[],context=context)
  hol_year2 = holiday_date_year.search(cr, uid,[],context=context)
  cal_year = hol_year2.date_start('%Y',hol_year2.date_start(datetime, "%Y"))
  for x in cal_year.browse(cr, uid, sr_ids, context=context):
   if x.id != ids[0]:
    for self_obj in self.browse(cr, uid, ids, context=context):
     if x.holiday_id == self_obj.holiday_id and x.year != cal_year:
      return False
  return True

 

I know this is some junk I have written.  Please help.

Or is there a way where I can have a option to select only date and month.

 

Portretas
Atmesti