-
-
Notifications
You must be signed in to change notification settings - Fork 782
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
base: 16.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -34,13 +34,18 @@ def _get_older_conflicting_invoices_domain(self): | |||||||||||||||
] | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
def _raise_older_conflicting_invoices(self): | ||||||||||||||||
def _raise_older_conflicting_invoices(self, older_move): | ||||||||||||||||
self.ensure_one() | ||||||||||||||||
raise UserError( | ||||||||||||||||
_( | ||||||||||||||||
"Chronology conflict: A conflicting draft invoice dated before " | ||||||||||||||||
"{date_invoice} exists, please validate it first." | ||||||||||||||||
).format(date_invoice=format_date(self.env, self.invoice_date)) | ||||||||||||||||
"Chronology conflict: A conflicting draft invoice {name} for " | ||||||||||||||||
"{partner} dated before {date_invoice} exists, please validate it " | ||||||||||||||||
"first or remove its invoice date." | ||||||||||||||||
).format( | ||||||||||||||||
Comment on lines
+41
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
@rvalyi would you this before merging? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will try to find the time, carnival here :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enjoy! |
||||||||||||||||
date_invoice=format_date(self.env, self.invoice_date), | ||||||||||||||||
name=older_move.name, | ||||||||||||||||
partner=older_move.partner_id.name, | ||||||||||||||||
) | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
def _get_newer_conflicting_invoices_domain(self): | ||||||||||||||||
|
@@ -174,8 +179,11 @@ def write(self, vals): | |||||||||||||||
move._get_sequence_order_conflicting_invoices_domain(), limit=1 | ||||||||||||||||
): | ||||||||||||||||
move._raise_sequence_ordering_conflict() | ||||||||||||||||
if self.search(move._get_older_conflicting_invoices_domain(), limit=1): | ||||||||||||||||
move._raise_older_conflicting_invoices() | ||||||||||||||||
older_move = self.search( | ||||||||||||||||
move._get_older_conflicting_invoices_domain(), limit=1 | ||||||||||||||||
rvalyi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
) | ||||||||||||||||
if older_move: | ||||||||||||||||
move._raise_older_conflicting_invoices(older_move) | ||||||||||||||||
if move in previously_validated: | ||||||||||||||||
if self.search( | ||||||||||||||||
move._get_sequence_order_conflicting_previously_validated(), limit=1 | ||||||||||||||||
|
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.