[15.0][OU-FIX] hr_expense: mark credit account move lines excluded from invoice tab - #4253
[15.0][OU-FIX] hr_expense: mark credit account move lines excluded from invoice tab#4253dalonsod wants to merge 1 commit into
Conversation
…oice tab Starting from v15, credit journal items linked to expenses will be marked as excluded from invoice tab. Existing journal entries will be recomputed due to payment status, and this information should be properly set, otherwise amounts will be unset
| UPDATE account_move_line | ||
| SET exclude_from_invoice_tab=( | ||
| CASE WHEN credit > 0.0 THEN true | ||
| WHEN debit > 0.0 THEN false | ||
| ELSE exclude_from_invoice_tab | ||
| END | ||
| ) | ||
| WHERE expense_id IS NOT NULL |
There was a problem hiding this comment.
For touching less rows:
| UPDATE account_move_line | |
| SET exclude_from_invoice_tab=( | |
| CASE WHEN credit > 0.0 THEN true | |
| WHEN debit > 0.0 THEN false | |
| ELSE exclude_from_invoice_tab | |
| END | |
| ) | |
| WHERE expense_id IS NOT NULL | |
| UPDATE account_move_line | |
| SET exclude_from_invoice_tab=true | |
| WHERE expense_id IS NOT NULL | |
| AND credit > 0 |
There was a problem hiding this comment.
Yes, that's correct, and I've verified that such account move lines have exclude_from_invoice_tab unset for a v14 database, indeed .
But I've found this problem: used OpenUpgrade with a database from v11 to v15, and every v14 account move line linked to expenses were migrated with exclude_from_invoice_tab=true, I still don't know why. That's why I've preferred this approach.
Anyway, if you think is more accurate your approach, no problem changing it.
There was a problem hiding this comment.
So is it a problem that both lines have exclude_from_invoice_tab=true?
And do you have hr_expense_invoice installed to know what happen to these items?
There was a problem hiding this comment.
So is it a problem that both lines have
exclude_from_invoice_tab=true?
Yes, according to
https://github.com/odoo/odoo/blob/15.0/addons/account/models/account_move.py#L1525-L1530
for this kind of moves, total_amount is set to 0.0 if exclude_from_invoice_tab is the same value (no matter true or false because with false both balances are added and sum is 0.0, and with true both are ignored), one of them must be true and the other false, as v15 new code indicates.
And do you have
hr_expense_invoiceinstalled to know what happen to these items?
Not installed in origin. Should I install it?
There was a problem hiding this comment.
The hr_expense_invoice is to check if the journal entries linked to both the invoice and the expense are correctly kept, as for example the tax line should be excluded from invoice tab. I'm having now the doubt if your expense contains taxes, that this is the correct approach. Please check how it's done in v15.
There was a problem hiding this comment.
OK, I'll take a look at v15 implementation and will update. And in my case, every expense comes without taxes.
Thanks for all Pedro.
|
Any news on this? |
|
Not yet, in this case migration tasks took my whole time and I couldn't test it before migration was completed (matter of priorities and deadlines, as you can guess), so I simply applied the proposed patch during final migration stuff. Sorry 😞 Anyway, I'll analyze |
|
Fixed in #4386 |
Starting from v15, credit journal items linked to expenses will be marked as excluded from invoice tab. Existing journal entries will be recomputed due to payment status, and this information should be properly set, otherwise amounts will be unset.
Fixes #4251