ValueError: : "unsupported operand type(s) for -: 'bool' and 'datetime.date'" while evaluating "for record in self:\n record['x_studio_number_of_days'] = record.x_studio_end_date - record.x_studio_start_date\n"How can I fix this
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Proyectos
- MRP
Se marcó esta pregunta
I got it
for record in self:
if record.x_studio_end_date and record.x_studio_start_date:
record['x_studio_number_of_days'] = (record.x_studio_end_date - record.x_studio_start_date).days
Hi,
Seems one of the fields is coming as empty, thus you get this error. In order to overcome the error add if condition and make sure that both the field contains value before subtracting them.
for record in self:
if record.x_studio_end_date and record.x_studio_start_date:
record['x_studio_number_of_days'] = record.x_studio_end_date - record.x_studio_start_date
Thanks
I got error
ValueError: <class 'TypeError'>: "float() argument must be a string or a number, not 'datetime.timedelta'" while evaluating
"for record in self:\n if record.x_studio_end_date and record.x_studio_start_date:\n record['x_studio_number_of_days'] = record.x_studio_end_date - record.x_studio_start_date\n"
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
Registrarse