Skip to Content
Menu
This question has been flagged
1 Reply
703 Views

I placed this code in computed field 

for record in self: if record[('record.x_studio_start_date')] !=False and record[('record.x_studio_end_date')] !=False:
 d1 = record.x_studio_start_date
 d2 = record.x_studio_end_date record['x_studio_number_of_days'] = (d2-d1).days else:
  record['x_studio_days_to_close'] = 0

and this the error I got 


ValueError: : "record.x_studio_start_date" while evaluating
"for record in self:\n  if record[('record.x_studio_start_date')] !=False and record[('record.x_studio_end_date')] !=False:\n    d1 = record.x_studio_start_date\n    d2 = record.x_studio_end_date\n    record['x_studio_number_of_days'] = (d2-d1).days\n  else:\n    record['x_studio_days_to_close'] = 0\n\n"
Can anyone help me to fix this I need to calculate days different between two dates using computed field 
Avatar
Discard
Best Answer

Hi,

Try the following code

for record in self:
if record['x_studio_start_date'] != False and record['x_studio_end_date'] != False:
d1 = record['x_studio_start_date']
d2 = record['x_studio_end_date']
record['x_studio_number_of_days'] = (d2 - d1).days
else:
record['x_studio_days_to_close'] = 0

Regards

Avatar
Discard