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][account_invoice_constraint_chronology] better error message #2035

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

rvalyi
Copy link
Member

@rvalyi rvalyi commented Feb 19, 2025

The error message in case of an older conflicting invoice was not really
helpful. Now it will show the conflicting invoice name if any and also
the customer name (because a draft invoice will likely be named '/' so
just the name might not be enough). This will help the user to find
the offending invoice. It also suggest to remove the invoice date
as a possible work around.

cc @DarioLodeiros @sbidoul @alexis-via @sebastienbeau @florian-dacosta @pedrobaeza @etobella @DarioLodeiros

@rvalyi rvalyi force-pushed the 16.0-fix-account_invoice_constraint_chronology-ak branch from b32c505 to e19db35 Compare February 19, 2025 16:13
@rvalyi
Copy link
Member Author

rvalyi commented Feb 19, 2025

hum it seems #2032 (review) is actually a nicer fix than my 1st commit. Putting it in draft and I'll probably remove my 1st commit, stay tuned.

@rvalyi rvalyi marked this pull request as draft February 19, 2025 16:21
Copy link
Member

@DarioLodeiros DarioLodeiros left a comment

Choose a reason for hiding this comment

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

Following the line I mentioned in #2032, I think it's also applicable here. I'm sharing the comments to see what you all think.

@@ -95,6 +100,8 @@ def _conflicting_inv_after_sequence_before_inv_date_domain(self):
return expression.AND(
[
(
("journal_id", "=", self.journal_id.id),
("move_type", ">", self.move_type),
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the ">" operator in the move_type comparisons... ¿?

Copy link
Member Author

Choose a reason for hiding this comment

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

wow that was a typo indeed.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, we must take into account that if the journal has the "different sequence" checkbox marked for refunds (refund_sequence), then it's true that the move_type should be checked. However, if not, the situation changes... there could be sequence conflicts among different types (https://github.com/OCA/account-financial-tools/blob/16.0/account_invoice_constraint_chronology/model/account_move.py#L14).
In my opinion, it would be best to unify the domain methods to avoid confusion and duplicate code.
What do you all think?

@rvalyi rvalyi force-pushed the 16.0-fix-account_invoice_constraint_chronology-ak branch from e19db35 to ca57806 Compare February 19, 2025 16:27
@rvalyi rvalyi changed the title [16.0][account_invoice_constraint_chronology] avoid multi-company false positive conflicts + better message [16.0][account_invoice_constraint_chronology] better error message Feb 19, 2025
@rvalyi
Copy link
Member Author

rvalyi commented Feb 19, 2025

@DarioLodeiros I just removed my 1st commit as it is covered by your PR #2032

The error message in case of an older conflicting invoice was not really
helpful. Now it will show the conflicting invoice name if any and also
the customer name (because a draft invoice will likely be named '/' so
just the name might not be enough). This will help the user to find
the offending invoice. It also suggest to removed the invoice date
as a possible work around.
@rvalyi rvalyi force-pushed the 16.0-fix-account_invoice_constraint_chronology-ak branch from ca57806 to 2969978 Compare February 24, 2025 18:26
@rvalyi rvalyi marked this pull request as ready for review February 24, 2025 18:35
Copy link
Member

@DarioLodeiros DarioLodeiros left a comment

Choose a reason for hiding this comment

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

Technical and functional review

Copy link
Member

@etobella etobella left a comment

Choose a reason for hiding this comment

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

Makes sense to me.

Technical review 👍

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

"Chronology conflict: A conflicting draft invoice {name} for "
"{partner} dated before {date_invoice} exists, please validate it "
"first or remove its invoice date."
).format(

Choose a reason for hiding this comment

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

You should use translation function arguments instead of format()

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the translation functions be automatically validated with precommit? I thought that if the precommit was passing, it was because it was a valid format (in my personal experience, I get an error if I don't use the translation function).

Choose a reason for hiding this comment

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

Yes, but this is new from >= v16. So, maybe you can propose a change in pylint-odoo.

Comment on lines +41 to +44
"Chronology conflict: A conflicting draft invoice {name} for "
"{partner} dated before {date_invoice} exists, please validate it "
"first or remove its invoice date."
).format(
Copy link
Member

@sbidoul sbidoul Mar 2, 2025

Choose a reason for hiding this comment

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

Suggested change
"Chronology conflict: A conflicting draft invoice {name} for "
"{partner} dated before {date_invoice} exists, please validate it "
"first or remove its invoice date."
).format(
"Chronology conflict: A conflicting draft invoice %(name)s for "
"%(partner)s dated before %(date_invoice)s exists, please validate it "
"first or remove its invoice date."

@rvalyi would you this before merging?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will try to find the time, carnival here :-)

Copy link
Member

Choose a reason for hiding this comment

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

Enjoy!

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.

6 participants