Skip to content

Commit

Permalink
Code Review
Browse files Browse the repository at this point in the history
  • Loading branch information
majouda committed Sep 3, 2024
1 parent df27bb6 commit 79c0887
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
11 changes: 10 additions & 1 deletion account_sale_invoice_date_required/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@ Summary

This module triggers an error when posting a customer invoice that does not have an invoice date.

.. image:: static/description/invoice_date_required.png
.. image:: static/description/invoice_date_required.png


Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)

More information
----------------
* Meet us at https://bit.ly/numigi-com
4 changes: 2 additions & 2 deletions account_sale_invoice_date_required/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{

Check warning on line 4 in account_sale_invoice_date_required/__manifest__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

account_sale_invoice_date_required/__manifest__.py#L4

Statement seems to have no effect
"name": "Account sale invoice date required",
"summary": "Raise an error posting customer invoice without invoice date.",
"name": "Account Sale Invoice Date Required",
"summary": "Raise an error when posting customer invoice without invoice date.",
"version": "14.0.1.0.0",
"website": "https://bit.ly/numigi-com",
"author": "Numigi",
Expand Down
4 changes: 2 additions & 2 deletions account_sale_invoice_date_required/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ msgstr "Dernière modification le"
#. module: account_sale_invoice_date_required
#: code:addons/account_sale_invoice_date_required/models/account_move.py:0
#, python-format
msgid "The invoice date is required to validate this document."
msgstr "La datede facturation est requise pour valider ce document."
msgid "The invoice/refund date is required to validate this document."
msgstr "La date de facturation/remboursement est requise pour valider ce document."
13 changes: 5 additions & 8 deletions account_sale_invoice_date_required/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


from odoo import models, _

from odoo.exceptions import UserError


Expand All @@ -12,10 +11,8 @@ class AccountMove(models.Model):
_inherit = 'account.move'

def action_post(self):
if not self.invoice_date:
if self.is_sale_document(include_receipts=True):
raise UserError(
_("The invoice date is required to validate this document.")
)
res = super(AccountMove, self).action_post()
return res
if self.is_sale_document(include_receipts=True) and not self.invoice_date:
raise UserError(
_("The invoice/refund date is required to validate this document.")
)
return super(AccountMove, self).action_post()

0 comments on commit 79c0887

Please sign in to comment.