Loan (LSE)
ea0ca18b81
[FIX] account: fix inconsistencies in _sync_dynamic_line
...
To reproduce (V16):
0. Install Accounting (can also be reproduced with just Invoicing, but
there is no "journal item" menu that will ease the process to show the
issue)
1. (In debug), change the dollar currency rounding to 0.0001
(instead of 0.01)
2. Go to Accounting > Customers > Invoices
3. Create a first invoice with:
- a partner P1
- set an invoice date
- make sure that there is a payment term set (for example "30 days")
- at least one invoiced line (the product does not matter) with the
tax 15 % and the price to 12.36
DO NOT confirm the invoice
4. Create another invoice with
- ANOTHER partner P2
- set an invoice date
- make sure that there is a payment term set (for example "30 days")
- at least one invoiced line (the product and the price does not
matter)
5. Go back to the Invoices list view and select the 2 new (unposted)
invoices then Action > Post entries.
6. Check Force and "Post Journal Entries"
7. Go to Accounting > Reporting > Journal Items
8. Group by "Journal Entry" and unfold the 2 last invoices (that should
be the one validated in 6.)
=> The "Partner" set on the Debit Line is the one of the other invoice
(and vice versa)
Analyse:
This issue is a mix of different sub-issues. Solving any of this
sub-issue would solve the issue but as other sub-issues may exists we
will fix each of them individually.
Sub-issue 1:
The account.move.line (=AML) partner is set correctly before the post
(6.), this is during the "mass posting" process that the issue happens.
The partner is changed because of this line:
https://github.com/odoo/odoo/blob/8006e7ce618f98bd26a82cf9b64eaa9b6e9c9d2a/addons/account/models/account_move.py#L2094-L2096
The value written to AML of id `line_id` include `move_id` which
overwrite the account.move that was originally set on the AML.
As the `partner` is computed only in certain circumstances, if the
`move_id` written differ from the one of the AML, most of the values
will be updated with the write values, but the `partner_id` will keep
its value (this is why the swap of partner happen).
In other words, this issue happen as `line_id.move_id` order is
different from `key["move_id"]`. So we write on the "wrong" AML.
Sub-issue 2:
In theory, this issue should not have happened in the first place.
The line:
https://github.com/odoo/odoo/blob/8006e7ce618f98bd26a82cf9b64eaa9b6e9c9d2a/addons/account/models/account_move.py#L2061
should have prevent the re-edition of the AML (as actually no relevant
datas are written). But the equality between the dictionaries fail due to some rounding errors.
Here:
- needed_after[<key Invoice 1>]["balance"] --> 14.214000000000002
- needed_before[<key Invoice 1>]["balance"] -> 14.213999999999999
N.B: if we don't set an "invoice date" on the invoice, a rewrite is
done before which would prevent our issue to reproduce.
Sub-issue 3:
If we try to reproduce the issue without setting a "payment term", the
issue would not reproduce.
By setting a "payment term" the `to_delete` computation change at:
https://github.com/odoo/odoo/blob/8006e7ce618f98bd26a82cf9b64eaa9b6e9c9d2a/addons/account/models/account_move.py#L2067
This happens as the `existing_before` keys and `needed_after` keys are
different:
- existing_before[<key Invoice 1>]["discount_date"] -> False
- needed_after[<key Invoice 1>]["discount_date"] ----> None
As the values are different, Odoo all the AML to the `to_delete` which
then trigger their overwrite.
In other words, if no "payment terms" were set on the invoices, the
issue would not happen either
opw-3270471,3292931,3333799
closes odoo/odoo#126272
X-original-commit: 074964b6c91d223da0b416855a92e9ed8a17ee55
Signed-off-by: William André (wan) <wan@odoo.com >
2023-06-23 22:39:00 +02:00
..
2023-06-23 22:39:00 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-06-21 20:10:01 +02:00
2023-06-01 11:43:51 +02:00
2023-06-19 03:24:39 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-05-22 17:52:07 +02:00
2023-06-16 23:01:20 +02:00
2023-06-15 17:36:14 +02:00
2023-06-01 11:43:51 +02:00
2023-06-06 14:48:27 +02:00
2023-05-22 17:52:07 +02:00
2023-06-23 17:59:57 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-05-22 17:52:07 +02:00
2023-06-09 18:30:31 +02:00
2023-05-22 11:43:04 +02:00
2023-06-09 18:30:31 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-20 19:08:56 +02:00
2023-06-22 08:35:01 +02:00
2023-06-12 22:39:26 +02:00
2023-06-01 11:43:51 +02:00
2023-06-21 15:53:15 +02:00
2023-06-01 11:43:51 +02:00
2023-06-09 17:01:06 +02:00
2023-06-12 19:46:23 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-06 18:10:56 +02:00
2023-06-12 22:39:26 +02:00
2023-06-13 10:14:06 +02:00
2023-06-14 20:20:43 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-06-19 13:35:28 +02:00
2023-06-01 11:43:51 +02:00
2023-06-19 13:35:28 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 13:54:08 +02:00
2023-06-22 15:40:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-12 22:39:26 +02:00
2023-06-21 06:57:53 +02:00
2023-06-01 11:43:51 +02:00
2023-06-20 15:58:03 +02:00
2023-06-01 11:43:51 +02:00
2023-06-22 15:40:51 +02:00
2023-06-21 06:57:53 +02:00
2023-06-15 10:45:06 +02:00
2023-06-09 13:50:14 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-02 07:56:56 +02:00
2023-06-05 14:50:20 +02:00
2023-06-01 11:43:51 +02:00
2023-06-23 16:35:07 +02:00
2023-06-01 11:43:51 +02:00
2023-06-20 15:58:17 +02:00
2023-06-19 13:35:28 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-21 19:04:14 +02:00
2023-06-15 02:37:56 +02:00
2023-06-01 11:43:51 +02:00
2023-06-22 18:29:50 +02:00
2023-05-22 17:52:07 +02:00
2023-06-01 17:55:25 +02:00
2023-06-12 22:39:26 +02:00
2023-06-19 21:25:52 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-06-23 13:26:55 +02:00
2023-05-22 17:52:07 +02:00
2023-06-01 11:43:51 +02:00
2023-06-07 15:58:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-21 01:24:20 +02:00
2023-06-09 10:54:43 +02:00
2023-05-22 17:52:07 +02:00
2023-06-22 15:41:00 +02:00
2023-05-17 10:34:00 +02:00
2023-06-22 18:29:50 +02:00
2023-06-01 11:43:51 +02:00
2023-06-09 17:01:17 +02:00
2023-06-15 17:35:42 +02:00
2023-06-23 16:35:35 +02:00
2023-06-12 22:39:26 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-06-22 19:37:10 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-05-10 04:14:50 +02:00
2023-05-22 17:52:07 +02:00
2023-06-23 16:35:35 +02:00
2023-05-22 17:52:07 +02:00
2023-05-10 04:14:50 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-06-14 10:54:24 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:35:42 +02:00
2023-06-16 12:18:48 +02:00
2023-06-19 16:40:09 +02:00
2023-06-21 11:50:22 +02:00
2023-05-31 09:23:10 +02:00
2023-06-05 17:51:02 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-06-19 10:40:54 +02:00
2023-05-10 04:14:50 +02:00
2023-05-10 04:14:50 +02:00
2023-06-23 16:35:35 +02:00
2023-06-22 15:41:03 +02:00
2023-06-19 10:40:43 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:36:14 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 07:57:03 +02:00
2023-06-09 10:54:59 +02:00
2023-06-15 17:35:42 +02:00
2023-06-14 10:54:24 +02:00
2023-05-12 22:59:22 +02:00
2023-06-05 14:50:11 +02:00
2023-06-19 10:40:43 +02:00
2023-05-10 04:14:50 +02:00
2023-06-16 13:41:00 +02:00
2023-05-10 04:14:50 +02:00
2023-06-16 13:41:00 +02:00
2023-05-10 04:14:50 +02:00
2023-06-15 17:35:42 +02:00
2023-06-20 15:58:26 +02:00
2023-05-23 20:57:15 +02:00
2023-06-14 09:39:05 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-05-10 04:14:50 +02:00
2023-06-15 17:35:42 +02:00
2023-06-12 22:39:26 +02:00
2023-05-22 17:52:07 +02:00
2023-06-12 22:39:26 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:35:42 +02:00
2023-06-07 08:59:00 +02:00
2023-06-14 10:54:24 +02:00
2023-05-10 04:14:50 +02:00
2023-05-10 04:14:50 +02:00
2023-05-10 04:14:50 +02:00
2023-06-22 18:29:58 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-06-12 22:39:26 +02:00
2023-05-11 10:40:53 +02:00
2023-05-11 10:40:55 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-06-05 17:51:06 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:36:15 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-06-14 10:54:24 +02:00
2023-06-15 17:35:42 +02:00
2023-05-10 04:14:50 +02:00
2023-06-15 17:35:42 +02:00
2023-05-22 17:52:07 +02:00
2023-06-15 17:35:42 +02:00
2023-06-15 17:35:42 +02:00
2023-06-01 11:43:51 +02:00
2023-06-14 17:14:43 +02:00
2023-06-01 11:43:51 +02:00
2023-06-19 13:35:28 +02:00
2023-06-22 19:37:18 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-22 09:50:38 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-05 16:17:12 +02:00
2023-06-09 17:01:43 +02:00
2023-05-22 17:52:07 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-22 19:37:10 +02:00
2023-06-23 16:35:40 +02:00
2023-06-23 17:59:57 +02:00
2023-05-17 10:34:00 +02:00
2023-06-23 18:00:05 +02:00
2023-05-17 14:47:15 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-05-22 13:54:08 +02:00
2023-06-01 11:43:51 +02:00
2023-06-12 22:39:26 +02:00
2023-06-16 01:40:18 +02:00
2023-06-12 14:03:48 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 13:54:08 +02:00
2023-05-22 13:54:08 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 13:54:08 +02:00
2023-05-22 13:54:08 +02:00
2023-05-22 13:54:08 +02:00
2023-06-19 10:41:00 +02:00
2023-05-22 17:52:07 +02:00
2023-06-01 11:44:13 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 17:52:07 +02:00
2023-05-22 13:54:08 +02:00
2023-05-22 17:52:07 +02:00
2023-05-24 14:27:44 +02:00
2023-06-01 11:43:51 +02:00
2023-06-23 16:35:27 +02:00
2023-06-22 19:37:10 +02:00
2023-06-05 13:31:35 +02:00
2023-06-19 10:40:43 +02:00
2023-06-01 11:43:51 +02:00
2023-06-19 10:40:43 +02:00
2023-06-19 10:40:43 +02:00
2023-06-19 10:40:43 +02:00
2023-06-05 17:51:06 +02:00
2023-06-23 18:00:13 +02:00
2023-06-19 10:40:43 +02:00
2023-06-22 08:35:04 +02:00
2023-05-05 17:06:38 +02:00
2023-05-05 17:06:38 +02:00
2023-06-23 18:00:24 +02:00
2023-06-05 17:51:06 +02:00
2023-06-19 10:40:43 +02:00
2023-06-22 18:29:44 +02:00
2023-06-19 10:40:43 +02:00
2023-06-19 10:40:43 +02:00
2023-05-17 10:34:00 +02:00
2023-06-20 19:08:56 +02:00
2023-05-22 17:52:07 +02:00
2023-06-09 13:49:39 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-23 13:26:55 +02:00
2023-05-17 10:34:00 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-23 17:59:57 +02:00
2023-06-01 11:43:51 +02:00
2023-06-22 15:40:51 +02:00
2023-06-14 13:10:49 +02:00
2023-06-21 00:13:49 +02:00
2023-06-20 19:08:57 +02:00
2023-06-22 09:50:41 +02:00
2023-06-01 11:43:51 +02:00
2023-06-12 11:22:07 +02:00
2023-05-22 17:52:07 +02:00
2023-06-23 18:00:05 +02:00
2023-06-08 21:52:44 +02:00
2023-06-23 18:00:05 +02:00
2023-06-06 16:22:45 +02:00
2023-06-22 15:40:51 +02:00
2023-06-22 15:40:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-22 15:40:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-12 22:39:26 +02:00
2023-06-22 08:34:58 +02:00
2023-06-22 15:40:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-22 15:40:51 +02:00
2023-06-23 09:20:57 +02:00
2023-05-12 19:55:08 +02:00
2023-05-24 09:49:05 +02:00
2023-06-23 18:00:05 +02:00
2023-05-17 13:37:47 +02:00
2023-06-22 19:37:07 +02:00
2023-05-22 17:52:07 +02:00
2023-06-13 19:28:59 +02:00
2023-06-13 19:28:59 +02:00
2023-06-09 17:01:17 +02:00
2023-05-22 17:52:07 +02:00
2023-06-22 15:40:43 +02:00
2023-06-13 12:49:33 +02:00
2023-06-15 10:44:58 +02:00
2023-06-15 10:44:58 +02:00
2023-06-01 11:43:51 +02:00
2023-06-13 14:07:27 +02:00
2023-06-13 14:07:27 +02:00
2023-06-23 18:00:05 +02:00
2023-06-23 18:00:05 +02:00
2023-06-22 15:40:51 +02:00
2023-06-21 11:50:16 +02:00
2023-06-23 10:27:38 +02:00
2023-05-22 17:52:07 +02:00
2023-06-12 10:02:23 +02:00
2023-06-23 16:34:46 +02:00
2023-06-12 22:39:26 +02:00
2023-06-13 10:14:06 +02:00
2023-06-21 06:57:53 +02:00
2023-06-15 00:12:45 +02:00
2023-06-12 22:39:26 +02:00
2023-06-12 10:02:22 +02:00
2023-06-12 12:41:23 +02:00
2023-06-12 22:39:26 +02:00
2023-06-21 01:24:20 +02:00
2023-05-11 10:41:06 +02:00
2023-06-12 22:39:26 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-12 22:39:26 +02:00
2023-06-23 18:00:15 +02:00
2023-06-23 18:00:22 +02:00
2023-06-22 15:40:43 +02:00
2023-06-08 23:01:21 +02:00
2023-06-23 18:00:27 +02:00
2023-06-19 13:35:28 +02:00
2023-06-01 11:43:51 +02:00
2023-06-12 22:39:26 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-19 13:35:28 +02:00
2023-06-02 14:29:49 +02:00
2023-05-30 13:03:00 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-02 14:29:49 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-05-22 17:52:07 +02:00
2023-06-02 14:29:49 +02:00
2023-06-01 11:43:51 +02:00
2023-06-19 23:17:01 +02:00
2023-05-22 17:52:07 +02:00
2023-06-22 17:10:42 +02:00
2023-05-22 13:54:08 +02:00
2023-06-19 21:25:52 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-14 07:18:43 +02:00
2023-05-22 17:52:07 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-05-30 10:31:43 +02:00
2023-06-05 14:49:48 +02:00
2023-06-19 23:17:01 +02:00
2023-06-23 18:00:27 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-12 14:04:10 +02:00
2023-06-01 11:43:51 +02:00
2023-06-01 11:43:51 +02:00
2023-06-22 18:29:55 +02:00
2023-06-22 15:40:51 +02:00
2023-06-16 13:41:04 +02:00
2023-06-01 11:43:51 +02:00
2023-05-22 17:52:07 +02:00
2023-06-23 19:06:39 +02:00
2023-06-01 11:43:51 +02:00
2023-06-09 09:34:56 +02:00
2023-06-01 11:43:51 +02:00
2023-05-22 17:52:07 +02:00