Skip to content

[15.0][OU-FIX] hr_expense: mark credit account move lines excluded from invoice tab - #4253

Closed
dalonsod wants to merge 1 commit into
OCA:15.0from
solvosci:15.0-fix-scripts-hr_expense-efit
Closed

[15.0][OU-FIX] hr_expense: mark credit account move lines excluded from invoice tab#4253
dalonsod wants to merge 1 commit into
OCA:15.0from
solvosci:15.0-fix-scripts-hr_expense-efit

Conversation

@dalonsod

@dalonsod dalonsod commented Dec 13, 2023

Copy link
Copy Markdown

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

…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
Comment on lines +20 to +27
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For touching less rows:

Suggested change
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

@dalonsod dalonsod Dec 13, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_invoice installed to know what happen to these items?

Not installed in origin. Should I install it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pedrobaeza

Copy link
Copy Markdown
Member

Any news on this?

@dalonsod

Copy link
Copy Markdown
Author

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 hr_expense_invoice addon in this context, and try to update. Unfortunately, I have no new migrations scheduled at this time.

@pedrobaeza

Copy link
Copy Markdown
Member

Fixed in #4386

@pedrobaeza pedrobaeza closed this Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants