Commit cfd7189
committed
[FIX] account: prevent wrong floating representation of currency
Steps to reproduce:
- In Journals/Bills/Advanced activate "Lock post entries with hash"
- Create a purchase tax of 17%
- Create a bill with a product of a cost of 30 and apply the "17%" tax
- Post it
- Export the data inalterability check report
Issue:
"Corrupted data"
Cause:
In python we have a reprentation issue
```
>>> 30*0.17
5.1000000000000005
```
We define the hash string during the `_compute_string_to_hash` at the
move creation. The issue is, at that time, the move_line tax debit
is not rounded.
Therefore, when we print the report, we take the `move.line_id.
debit` from the db which is rounded and equal to '5.10' and compare
it to '5.1000000000000005' which gives a different hash
Solution:
Implementing a V3 version that uses `repr` for monetary fields.
opw-3072693
closes odoo#112016
Signed-off-by: William André (wan) <wan@odoo.com>1 parent 5ef7bb2 commit cfd7189
File tree
3 files changed
+62
-3
lines changed- addons/account
- models
- tests
3 files changed
+62
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
2646 | 2647 | | |
2647 | 2648 | | |
2648 | 2649 | | |
2649 | | - | |
| 2650 | + | |
2650 | 2651 | | |
2651 | 2652 | | |
2652 | 2653 | | |
| |||
2680 | 2681 | | |
2681 | 2682 | | |
2682 | 2683 | | |
| 2684 | + | |
2683 | 2685 | | |
2684 | 2686 | | |
2685 | 2687 | | |
| 2688 | + | |
| 2689 | + | |
2686 | 2690 | | |
2687 | 2691 | | |
2688 | 2692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2534 | 2534 | | |
2535 | 2535 | | |
2536 | 2536 | | |
2537 | | - | |
| 2537 | + | |
2538 | 2538 | | |
2539 | 2539 | | |
2540 | 2540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
0 commit comments