Skip to content

Commit

Permalink
TA#67540 [ADD] account_sale_invoice_date_required (#213)
Browse files Browse the repository at this point in the history
* TA#67540 [ADD] account_sale_invoice_date_required
---------

Co-authored-by: majouda <[email protected]>
  • Loading branch information
rivo2302 and majouda authored Sep 3, 2024
1 parent 25c5c5c commit 38c1b30
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 0 deletions.
1 change: 1 addition & 0 deletions .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"old_accounts",
"payment_list_not_sent",
"payment_stripe_not_silenced",
"account_sale_invoice_date_required"
],
"installable": True,
}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ COPY account_payment_term_usage_sale /mnt/extra-addons/account_payment_term_usag
COPY account_payment_widget_link /mnt/extra-addons/account_payment_widget_link
COPY account_report_line_menu /mnt/extra-addons/account_report_line_menu
COPY account_report_trial_balance /mnt/extra-addons/account_report_trial_balance
COPY account_sale_invoice_date_required /mnt/extra-addons/account_sale_invoice_date_required
COPY account_search_by_amount /mnt/extra-addons/account_search_by_amount
COPY account_show_full_features /mnt/extra-addons/account_show_full_features
COPY account_type_archive /mnt/extra-addons/account_type_archive
Expand Down
20 changes: 20 additions & 0 deletions account_sale_invoice_date_required/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Account sale invoice date required
============================

.. contents:: Table of Contents

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


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

More information
----------------
* Meet us at https://bit.ly/numigi-com
4 changes: 4 additions & 0 deletions account_sale_invoice_date_required/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
14 changes: 14 additions & 0 deletions account_sale_invoice_date_required/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"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",
"maintainer": "Numigi",
"license": "AGPL-3",
"depends": ["account"],
"installable": True
}
42 changes: 42 additions & 0 deletions account_sale_invoice_date_required/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_sale_invoice_date_required
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-29 12:04+0000\n"
"PO-Revision-Date: 2024-08-29 12:04+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_sale_invoice_date_required
#: model:ir.model.fields,field_description:account_sale_invoice_date_required.field_account_move__display_name
msgid "Display Name"
msgstr "Nom d'affichage"

#. module: account_sale_invoice_date_required
#: model:ir.model.fields,field_description:account_sale_invoice_date_required.field_account_move__id
msgid "ID"
msgstr ""

#. module: account_sale_invoice_date_required
#: model:ir.model,name:account_sale_invoice_date_required.model_account_move
msgid "Journal Entry"
msgstr "Pièce comptable"

#. module: account_sale_invoice_date_required
#: model:ir.model.fields,field_description:account_sale_invoice_date_required.field_account_move____last_update
msgid "Last Modified on"
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/refund date is required to validate this document."
msgstr "La date de facturation/remboursement est requise pour valider ce document."
4 changes: 4 additions & 0 deletions account_sale_invoice_date_required/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_move
19 changes: 19 additions & 0 deletions account_sale_invoice_date_required/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo import models, _
from odoo.exceptions import UserError


class AccountMove(models.Model):

_inherit = 'account.move'

def action_post(self):
for move in self:
if move.is_sale_document(include_receipts=True) and not move.invoice_date:
raise UserError(
_("The invoice/refund date is required to validate this document.")
)
return super(AccountMove, self).action_post()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions account_sale_invoice_date_required/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_account_move
35 changes: 35 additions & 0 deletions account_sale_invoice_date_required/tests/test_account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase
from odoo.exceptions import UserError


class TestAccountMove(TransactionCase):

def setUp(self):
super(TestAccountMove, self).setUp()
self.partner = self.env['res.partner'].create({
'name': 'Test Customer',
})
self.invoice = self.env['account.move'].create([
{
'move_type': 'out_invoice',
'date': '2017-01-01',
'invoice_date': '2017-01-01',
'partner_id': self.partner.id,
'invoice_line_ids': [
(0, 0, {'name': 'aaaa', 'price_unit': 100.0})
],
}
])

def test_invoice_without_date(self):
self.invoice.invoice_date = False
with self.assertRaises(UserError):
self.invoice.action_post()

def test_invoice_with_date(self):
self.invoice.invoice_date = '2023-08-01'
self.invoice.action_post()
self.assertEqual(self.invoice.state, 'posted')

0 comments on commit 38c1b30

Please sign in to comment.