-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][MIG]: invoice_refund_not_earlier (#184)
Co-authored-by: Majda EL MARIOULI <[email protected]>
- Loading branch information
1 parent
913c579
commit f077760
Showing
14 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Invoice Refund Not Earlier | ||
========================== | ||
This module prevents to select a date prior to the invoice date when registering a refund. | ||
|
||
This constraint is added on all journal entries, not only invoices. | ||
|
||
Usage | ||
----- | ||
As member of the group `Accounting / Billing`, I go to the form view of an invoice: | ||
|
||
I click to create a refund. | ||
|
||
.. image:: static/description/invoice_form.png | ||
|
||
I select a refund date prior to the invoice date, then I click on ``Reverse``. | ||
|
||
.. image:: static/description/refund_wizard.png | ||
|
||
A blocking message appears: | ||
|
||
.. image:: static/description/error_message.png | ||
|
||
Contributors | ||
------------ | ||
* Numigi (tm) and all its contributors (https://bit.ly/numigiens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Invoice Refund Not Ealier", | ||
"version": "1.0.0", | ||
"author": "Numigi", | ||
"maintainer": "Numigi", | ||
"website": "https://www.numigi.com", | ||
"license": "LGPL-3", | ||
"category": "Accounting", | ||
"summary": "Prevent refunds prior to the invoice date", | ||
"depends": ["account"], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * invoice_refund_not_earlier | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-04-08 20:53+0000\n" | ||
"PO-Revision-Date: 2019-04-08 16:54-0400\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"Language: fr\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: \n" | ||
"X-Generator: Poedit 2.0.6\n" | ||
|
||
#. module: invoice_refund_not_earlier | ||
#: model:ir.model,name:invoice_refund_not_earlier.model_account_invoice | ||
msgid "Invoice" | ||
msgstr "" | ||
|
||
#. module: invoice_refund_not_earlier | ||
#: code:addons/invoice_refund_not_earlier/models.py:51 | ||
#, python-format | ||
msgid "" | ||
"The date of the reversal entry ({reversal_date}) can not be prior to the " | ||
"original move date ({move_date})." | ||
msgstr "" | ||
"La date de renversement ({reversal_date}) ne peut pas être inférieure à la " | ||
"date de la pièce comptable d'origine ({move_date})." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import account_move |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import models, _ | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class AccountMove(models.Model): | ||
|
||
_inherit = "account.move" | ||
|
||
def _reverse_moves(self, default_values_list=None, cancel=False): | ||
for i, move in enumerate(self): | ||
date = default_values_list[i].get("date") | ||
if date and date < move.date: | ||
raise ValidationError(_( | ||
"The date of the reversal entry ({reversal_date}) " | ||
"can not be prior to the original move date ({move_date})." | ||
).format(reversal_date=date, move_date=move.date)) | ||
return super()._reverse_moves(default_values_list, cancel) |
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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# © 2019 Numigi | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# © 2019 Numigi | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
import pytest | ||
from datetime import datetime, timedelta | ||
from odoo.tests.common import SavepointCase | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class TestAccountMove(SavepointCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.journal = cls.env['account.journal'].create({ | ||
'name': 'Test', | ||
'code': 'TEST', | ||
'type': 'general', | ||
}) | ||
cls.default_plan = cls.env['account.analytic.plan'].create( | ||
{'name': 'Default', 'company_id': False}) | ||
cls.analytic = cls.env['account.analytic.account'].create({ | ||
'name': 'test', | ||
'plan_id': cls.default_plan.id | ||
}) | ||
cls.account_1 = cls.env['account.account'].create({ | ||
'name': 'Account 1', | ||
'code': '501001', | ||
'account_type': 'asset_fixed', | ||
}) | ||
cls.account_2 = cls.env['account.account'].create({ | ||
'name': 'Account 2', | ||
'code': '101001', | ||
'account_type': 'expense', | ||
}) | ||
|
||
cls.today = datetime.now().date() | ||
cls.yesterday = cls.today - timedelta(1) | ||
|
||
cls.move = cls.env['account.move'].create({ | ||
'journal_id': cls.journal.id, | ||
'date': cls.today, | ||
'line_ids': [ | ||
(0, 0, { | ||
'account_id': cls.account_1.id, | ||
'name': '/', | ||
'debit': 100, | ||
}), | ||
(0, 0, { | ||
'account_id': cls.account_2.id, | ||
'name': '/', | ||
'credit': 100, | ||
}) | ||
] | ||
}) | ||
|
||
def test_if_reversed_prior_to_original_move__validation_raised(self): | ||
with pytest.raises(ValidationError): | ||
self._reverse_moves(date=self.yesterday) | ||
|
||
def test_if_reversed_with_same_date__reversal_move_created(self): | ||
assert self._reverse_moves(date=self.today) | ||
|
||
def _reverse_moves(self, date): | ||
return self.move._reverse_moves([{"date": date}]) |