Files
odoo_source/addons/hr_holidays/tests
Yannick Tivisse 4afdebbb7e [FIX] hr_holidays: Fix undeterministic crashing tests
The tests in hr_holidays/tests/test_company_leave.py seem like they randomly fail if the default value for
date_to is computed on a different second than the date_from (it's a dict of fields so not ordered).

Cfr https://runbot.odoo.com/runbot/build/3727451 2020-07-30 08:28:32 vs 2020-07-30 08:28:31
for which date_from > date_to.

I imagine the call to leave._onchange_request_parameters() is meant to fix it, but it occurs after
the create() which is flushed immediately, so it's too late and the date_from/date_to SQL constraint
still triggers.

It could happen for real production usage too, so we might want to do something about that outside of tests.
Options include:

1/ making the date_from/date_to fields writeable computed fields, with the compute method setting
   better defaults on both fields at once
2/ alternatively, remove the default=fields.Datetime.now and override default_get instead for
   deterministic defaults on both fields at once

The second solution seemed to be the better one.

closes odoo/odoo#55880

Taskid: 2312029
X-original-commit: 6908ea471dd18182f83c81046f0000a00898fb66
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-08-14 09:29:30 +00:00
..