Skip to content
Snippets Groups Projects
Commit 4a5b68f0 authored by Xavier-Do's avatar Xavier-Do
Browse files

[FIX] crm: avoid indeterminism linked to create_date filter


The test `test_assign_count` may fail randomly leading to the error:

```
self.assertEqual(self.sales_team_1_m3.lead_month_count, 14)
AssertionError: 12 != 14
```

Since BUNDLE_HOURS_DELAY is 0 (during tests), the domain becomes
`[('create_date', '<', fields.Datetime.now()]`

Depending of the time when the transaction starts, and the tests is
executed, the domain could match more or less records when executed one
second earlier or later. This is especially True for single module build
where there is less logic and the execution is faster. The domain may be
tested earlier and match less records.

This error can be reproduced deterministically by setting
`BUNDLE_HOURS_DELAY = 1/3600`

A fix could be to ignore ignore the create_date domain if the
BUNDLE_HOURS_DELAY is 0, we want to match all records in theory
(except if some of them are created in the future...)

The chosen solution is to use cr.now and use a <= instead.

Some assertions where also added to the test in order to identify why
the count was different and give a more precise message when it fails.

```
AssertionError: Lists differ: [] != ['TestLeadInitial_0000', 'TestLeadInitial_[97 chars]006']

Second list contains 6 additional elements.
First extra element 0:
'TestLeadInitial_0000'

- []
+ ['TestLeadInitial_0000',
+  'TestLeadInitial_0001',
+  'TestLeadInitial_0002',
+  'TestLeadInitial_0004',
+  'TestLeadInitial_0005',
+  'TestLeadInitial_0006']
```

task-2796579

closes odoo/odoo#83922

Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
parent e36dbb83
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment