diff --git a/account_maturity_date_default/README.rst b/account_maturity_date_default/README.rst new file mode 100644 index 000000000..9bbda488e --- /dev/null +++ b/account_maturity_date_default/README.rst @@ -0,0 +1,86 @@ +============================= +Account Maturity Date Default +============================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github + :target: https://github.com/OCA/account-financial-tools/tree/13.0/account_maturity_date_default + :alt: OCA/account-financial-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-financial-tools-13-0/account-financial-tools-13-0-account_maturity_date_default + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/92/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon defines as due date of the journal item the date of the journal +entry (only if you have not defined one) only affecting receivable and +payable accounts. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_ + + * Pedro M. Baeza + * Víctor Martínez + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px + :target: https://github.com/victoralmau + :alt: victoralmau + +Current `maintainer `__: + +|maintainer-victoralmau| + +This module is part of the `OCA/account-financial-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_maturity_date_default/__init__.py b/account_maturity_date_default/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/account_maturity_date_default/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_maturity_date_default/__manifest__.py b/account_maturity_date_default/__manifest__.py new file mode 100644 index 000000000..f68bbcc8b --- /dev/null +++ b/account_maturity_date_default/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Account Maturity Date Default", + "version": "13.0.1.0.0", + "category": "Accounting", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-financial-tools", + "license": "AGPL-3", + "depends": ["account"], + "data": [], + "installable": True, + "maintainers": ["victoralmau"], +} diff --git a/account_maturity_date_default/i18n/account_maturity_date_default.pot b/account_maturity_date_default/i18n/account_maturity_date_default.pot new file mode 100644 index 000000000..c34d4a5bb --- /dev/null +++ b/account_maturity_date_default/i18n/account_maturity_date_default.pot @@ -0,0 +1,21 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_maturity_date_default +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-09-06 13:03+0000\n" +"PO-Revision-Date: 2021-09-06 13:03+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_maturity_date_default +#: model:ir.model,name:account_maturity_date_default.model_account_move_line +msgid "Journal Item" +msgstr "" diff --git a/account_maturity_date_default/models/__init__.py b/account_maturity_date_default/models/__init__.py new file mode 100644 index 000000000..8795b3bea --- /dev/null +++ b/account_maturity_date_default/models/__init__.py @@ -0,0 +1 @@ +from . import account_move_line diff --git a/account_maturity_date_default/models/account_move_line.py b/account_maturity_date_default/models/account_move_line.py new file mode 100644 index 000000000..215cf2085 --- /dev/null +++ b/account_maturity_date_default/models/account_move_line.py @@ -0,0 +1,17 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if not vals.get("date_maturity"): + account = self.env["account.account"].browse(vals.get("account_id")) + if account.internal_type in {"receivable", "payable"}: + move = self.env["account.move"].browse(vals.get("move_id")) + vals["date_maturity"] = move.date + return super().create(vals_list) diff --git a/account_maturity_date_default/readme/CONTRIBUTORS.rst b/account_maturity_date_default/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..4c9d0f2a9 --- /dev/null +++ b/account_maturity_date_default/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_ + + * Pedro M. Baeza + * Víctor Martínez diff --git a/account_maturity_date_default/readme/DESCRIPTION.rst b/account_maturity_date_default/readme/DESCRIPTION.rst new file mode 100644 index 000000000..71bdabbb3 --- /dev/null +++ b/account_maturity_date_default/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This addon defines as due date of the journal item the date of the journal +entry (only if you have not defined one) only affecting receivable and +payable accounts. diff --git a/account_maturity_date_default/static/description/icon.png b/account_maturity_date_default/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_maturity_date_default/static/description/icon.png differ diff --git a/account_maturity_date_default/static/description/index.html b/account_maturity_date_default/static/description/index.html new file mode 100644 index 000000000..1c91e572c --- /dev/null +++ b/account_maturity_date_default/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Account Maturity Date Default + + + +
+

Account Maturity Date Default

+ + +

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

+

This addon defines as due date of the journal item the date of the journal +entry (only if you have not defined one) only affecting receivable and +payable accounts.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa
      +
    • Pedro M. Baeza
    • +
    • Víctor Martínez
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

victoralmau

+

This module is part of the OCA/account-financial-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_maturity_date_default/tests/__init__.py b/account_maturity_date_default/tests/__init__.py new file mode 100644 index 000000000..d41173dbe --- /dev/null +++ b/account_maturity_date_default/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) + +from . import test_account_move diff --git a/account_maturity_date_default/tests/test_account_move.py b/account_maturity_date_default/tests/test_account_move.py new file mode 100644 index 000000000..52e424df0 --- /dev/null +++ b/account_maturity_date_default/tests/test_account_move.py @@ -0,0 +1,100 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) + +from odoo import fields +from odoo.tests import Form, common + + +class TestAccountMove(common.SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.account_tax = cls.env["account.tax"].create( + {"name": "0%", "amount_type": "fixed", "type_tax_use": "sale", "amount": 0} + ) + cls.partner = cls.env["res.partner"].create({"name": "Partner test"}) + cls.product = cls.env["product.product"].create( + { + "name": "Product Test", + "list_price": 10, + "taxes_id": [(6, 0, [cls.account_tax.id])], + } + ) + cls.account = cls.env["account.account"].create( + { + "name": "Test Account", + "code": "TEST", + "user_type_id": cls.env.ref("account.data_account_type_receivable").id, + "reconcile": True, + } + ) + cls.other_account = cls.env["account.account"].create( + { + "name": "Test Account", + "code": "ACC", + "user_type_id": cls.env.ref( + "account.data_account_type_other_income" + ).id, + "reconcile": True, + } + ) + cls.env["account.journal"].create( + {"name": "Test sale journal", "type": "sale", "code": "TEST-SALE"} + ) + cls.journal_bank = cls.env["account.journal"].create( + {"name": "Test bank journal", "type": "bank", "code": "TEST-BANK"} + ) + + def _create_invoice(self): + move_form = Form( + self.env["account.move"].with_context(default_type="out_invoice") + ) + move_form.partner_id = self.partner + move_form.invoice_date = fields.Date.from_string("2000-01-01") + with move_form.invoice_line_ids.new() as line_form: + line_form.product_id = self.product + invoice = move_form.save() + return invoice + + def test_invoice_reconciliation(self): + invoice = self._create_invoice() + invoice.action_post() + invoice_line = invoice.line_ids.filtered( + lambda x: x.account_id.internal_type == "receivable" + ) + statement = self.env["account.bank.statement"].create( + { + "journal_id": self.journal_bank.id, + "name": "Test", + "date": "2000-01-01", + "balance_end_real": 10.0, + "line_ids": [ + ( + 0, + 0, + { + "date": "2000-01-01", + "partner_id": self.partner.id, + "name": invoice.name, + "amount": 10.0, + }, + ) + ], + } + ) + statement_line = statement.line_ids.filtered(lambda x: x.name == invoice.name) + statement_line.process_reconciliation( + counterpart_aml_dicts=[ + { + "move_line": invoice_line, + "credit": 10.0, + "debit": 0.0, + "name": invoice.name, + } + ] + ) + self.assertEqual(invoice.invoice_payment_state, "paid") + line_receivable = statement_line.journal_entry_ids.filtered( + lambda x: x.account_id.internal_type == "receivable" + ) + self.assertEqual(line_receivable.date_maturity, line_receivable.move_id.date) diff --git a/setup/account_maturity_date_default/odoo/addons/account_maturity_date_default b/setup/account_maturity_date_default/odoo/addons/account_maturity_date_default new file mode 120000 index 000000000..0942618e9 --- /dev/null +++ b/setup/account_maturity_date_default/odoo/addons/account_maturity_date_default @@ -0,0 +1 @@ +../../../../account_maturity_date_default \ No newline at end of file diff --git a/setup/account_maturity_date_default/setup.py b/setup/account_maturity_date_default/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_maturity_date_default/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)