Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] hr_expense_invoice: Incorrect data and check when creating vendor bill from expense #249

Merged

Conversation

pedrobaeza
Copy link
Member

@pedrobaeza pedrobaeza commented Jun 22, 2024

Two fixes:

  1. The "amount_total" field now reflects the total of the invoice including taxes, so we have to use "untaxed_amount".
  2. If changing any data in the linked vendor bill, the computed fields used for the comparison are not yet recomputed, so let's do the check on a later stage (after the write).

Fixes #245

@Tecnativa

@edlopen
Copy link
Member

edlopen commented Jun 26, 2024

Hello @pedrobaeza , can you reset de runboat so we can test it? Thank you!

@pedrobaeza pedrobaeza force-pushed the 16.0-fix-hr_expense_invoice-create_bill branch from c072e51 to 3794eac Compare June 26, 2024 11:03
@pedrobaeza
Copy link
Member Author

Re-pushed

@rafaelbn
Copy link
Member

FIX : #248

@moduon MT-5202 Please @edlopen @Gelojr could you review 😄 ❤️

Copy link
Member

@edlopen edlopen left a comment

Choose a reason for hiding this comment

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

LGTM. Code and functional review. Thank you @pedrobaeza.

Copy link
Member

@edlopen edlopen left a comment

Choose a reason for hiding this comment

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

Hello @pedrobaeza , I've came across a new issue with the flow you suggested.
If in the bill I add a Vendor or a reference the validation error show up again.

https://www.loom.com/share/989658911ea94a788dc820adee39b5dd?sid=1b33c2b6-16d8-4ded-8613-e7d680d25761

Copy link

@loida-vm loida-vm left a comment

Choose a reason for hiding this comment

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

Hello, upon reviewing the PR, I don't see that it follows the correct flow. If the expense is X, the total amount of the invoice should also be X. Therefore, if we add a tax to the invoice, the price must change so that the total remains X.

When I perform these steps, a warning appears and does not allow us to confirm the invoice because it is based on the taxable base and not on the total. This is incorrect.

You can see the flow in the following video: https://www.loom.com/share/9c620effe6174653b380aa7a09d403ae?sid=631e7f66-ca85-42e8-8d54-d4cbb7450a37

@Shide
Copy link

Shide commented Sep 11, 2024

@pedrobaeza can I continue this PR in a separate PR using your code (and mentioning you)?

@pedrobaeza
Copy link
Member Author

We can merge this one and you add an extra PR on top of it. These fixes are welcome although not completed.

Copy link

@Shide Shide left a comment

Choose a reason for hiding this comment

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

I've spotted an strange behaviour.
If you perform a write when you are changing the supplier and the lines (always with a match on the total amounts) at the same time (modify all the fields you need to change and click save), the move.amount_total value is the old one.

The key to know when to allow Odoo perform it's changes or checks is to add the context checking.

With this small modifications works perfect.

# Check if the amount of the invoice linked to an invoice is different
# Done here in the write instead of a Python constraint as the computed field
# amount_total is not yet updated on that moment
res = super().write(vals)
Copy link

Choose a reason for hiding this comment

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

Suggested change
res = super().write(vals)
res = super().write(vals)
if self.env.context.get("skip_account_move_synchronization"):
return res

Copy link

Choose a reason for hiding this comment

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

@pedrobaeza can you address it?

@loida-vm @edlopen please approve this PR in order to allow me to continue doing things

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed, @Shide

…or bill from expense

Two fixes:

1. The "amount_total" field now reflects the total of the invoice
   including taxes, so we have to use "untaxed_amount".
2. If changing any data in the linked vendor bill, the computed fields
   used for the comparison are not yet recomputed, so let's do the
   check on a later stage (after the write).
@pedrobaeza pedrobaeza force-pushed the 16.0-fix-hr_expense_invoice-create_bill branch from 3794eac to 8b8aeb3 Compare September 12, 2024 07:49
Copy link
Member

@edlopen edlopen left a comment

Choose a reason for hiding this comment

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

LGTM indeed!

@pedrobaeza
Copy link
Member Author

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-249-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit c6d3bd5 into OCA:16.0 Sep 12, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at f787c47. Thanks a lot for contributing to OCA. ❤️

@pedrobaeza pedrobaeza deleted the 16.0-fix-hr_expense_invoice-create_bill branch September 12, 2024 08:26
Copy link

@loida-vm loida-vm left a comment

Choose a reason for hiding this comment

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

I’m presenting a video here doing the functional check.
As you can see, and as my colleague @Shide mentioned, the value move.amount_total it "remembers" is the old one. Therefore, if the case is like the one I’m presenting (the second) in the video, it still doesn't allow me to confirm the invoice.
https://www.loom.com/share/23ba25ca6c664f42af38a3ae70b09b20?sid=145650c5-cc3c-4e07-bd78-73a03646ca3b

@pedrobaeza
Copy link
Member Author

@loida-vm was that test done before or after I performed the change that @Shide suggested?

@loida-vm
Copy link

It was this morning, after the change

@pedrobaeza
Copy link
Member Author

Well, then the patch suggested by @Shide seems to be not working in that case.

@Shide
Copy link

Shide commented Sep 12, 2024

@loida-vm I'll fix your second case soon.

@loida-vm
Copy link

Ok, thank you very much. Aside from that case, the PR works correctly.

@ProcessControl-JHF
Copy link

Will we have this resolved in version 17? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] hr_expense_invoice: errors when a tax is set in the expense.
7 participants