From 631e8f146889e8b49355195c7bd7a18c245fe3f1 Mon Sep 17 00:00:00 2001 From: David Jaen Date: Tue, 6 Jun 2023 13:03:41 +0200 Subject: [PATCH] [IMP] account_move_budget: pre-commit stuff --- account_move_budget/README.rst | 3 +- account_move_budget/__manifest__.py | 2 +- account_move_budget/readme/CONTRIBUTORS.rst | 1 + account_move_budget/tests/__init__.py | 2 + .../tests/test_account_move_budget.py | 139 ++++++++++++++++++ .../odoo/addons/account_move_budget | 1 + setup/account_move_budget/setup.py | 6 + 7 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 account_move_budget/tests/__init__.py create mode 100644 account_move_budget/tests/test_account_move_budget.py create mode 120000 setup/account_move_budget/odoo/addons/account_move_budget create mode 100644 setup/account_move_budget/setup.py diff --git a/account_move_budget/README.rst b/account_move_budget/README.rst index 05e52be6..79e869a4 100644 --- a/account_move_budget/README.rst +++ b/account_move_budget/README.rst @@ -23,7 +23,7 @@ Account Move Budget :target: https://runbot.odoo-community.org/runbot/92/15.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module allows to define accounting budgets. @@ -65,6 +65,7 @@ Authors ~~~~~~~ * ForgeFlow +* David Jaen Contributors ~~~~~~~~~~~~ diff --git a/account_move_budget/__manifest__.py b/account_move_budget/__manifest__.py index c371c161..4a53be3b 100644 --- a/account_move_budget/__manifest__.py +++ b/account_move_budget/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Account Move Budget", "summary": "Create Accounting Budgets", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "category": "Accounting & Finance", "website": "https://github.com/OCA/account-financial-tools", "author": "ForgeFlow, " "Odoo Community Association (OCA)", diff --git a/account_move_budget/readme/CONTRIBUTORS.rst b/account_move_budget/readme/CONTRIBUTORS.rst index aded1793..970d49af 100644 --- a/account_move_budget/readme/CONTRIBUTORS.rst +++ b/account_move_budget/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * ForgeFlow, S.L. (https://www.forgeflow.com) * Hector Villarreal * Jordi Ballester Alomar +* David Jaen diff --git a/account_move_budget/tests/__init__.py b/account_move_budget/tests/__init__.py new file mode 100644 index 00000000..dcc433fa --- /dev/null +++ b/account_move_budget/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import test_account_move_budget diff --git a/account_move_budget/tests/test_account_move_budget.py b/account_move_budget/tests/test_account_move_budget.py new file mode 100644 index 00000000..74b86615 --- /dev/null +++ b/account_move_budget/tests/test_account_move_budget.py @@ -0,0 +1,139 @@ +# Copyright 2023 David Jaen . +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.exceptions import ValidationError +from odoo.tests.common import Form, TransactionCase + + +class TestAccountMoveBudget(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.type = cls.env["date.range.type"].create( + {"name": "Fiscal year", "company_id": False, "allow_overlap": False} + ) + + cls.date_range = cls.env["date.range"].create( + { + "name": "FS2023", + "date_start": "2023-01-01", + "date_end": "2023-12-31", + "type_id": cls.type.id, + } + ) + + cls.date_range2 = cls.env["date.range"].create( + { + "name": "FS2024", + "date_start": "2024-01-01", + "date_end": "2024-12-31", + "type_id": cls.type.id, + } + ) + + user = ( + cls.env["res.users"] + .with_context(no_reset_password=True) + .create( + { + "name": "Because I am budgetman!", + "login": "budgetman", + "groups_id": [ + (6, 0, cls.env.user.groups_id.ids), + (4, cls.env.ref("account.group_account_user").id), + ], + } + ) + ) + user.partner_id.email = "budgetman@test.com" + cls.env = cls.env(user=user) + + cls.account = cls.env["account.account"].create( + { + "code": "TT", + "name": "Test Account", + "account_type": "asset_fixed", + } + ) + + def test_01_create_account_move_budget(self): + move_form = Form(self.env["account.move.budget"]) + move_form.name = "Budget Test 01" + move_form.description = "Description" + move_form.date_range_id = self.date_range + move_budget = move_form.save() + + move_line_form = Form(self.env["account.move.budget.line"]) + move_line_form.name = "Dummy line" + move_line_form.budget_id = move_budget + move_line_form.date = "2023-01-02" + move_line_form.partner_id = self.env.user.partner_id + move_line_form.credit = 3000 + move_line_form.debit = 5000 + move_line_form.account_id = self.account + move_line_form.save() + + def test_02_change_date_range_account_move_budget(self): + move_form = Form(self.env["account.move.budget"]) + move_form.name = "Budget Test 02" + move_form.description = "Description" + move_form.date_range_id = self.date_range + move_form.state = "draft" + move_form.date_range_id = self.date_range2 + self.assertTrue(move_form.save()) + + def test_03_copy_account_move_budget(self): + + move_form = Form(self.env["account.move.budget"]) + move_form.name = "Budget Test 03" + move_form.description = "Description" + move_form.date_range_id = self.date_range + move_form.state = "draft" + self.assertTrue(move_form.save().copy()) + + def test_04_actions_account_move_budget(self): + + values = { + "name": "Budget Test 04", + "description": "Description", + "date_range_id": self.date_range.id, + "date_from": self.date_range.date_start, + "date_to": self.date_range.date_end, + } + budget = self.env["account.move.budget"].create(values) + + budget.action_draft() + self.assertTrue(budget.state == "draft") + budget.action_cancel() + self.assertTrue(budget.state == "cancelled") + budget.action_confirm() + self.assertTrue(budget.state == "confirmed") + + def test_05_raise_account_move_budget(self): + move_form = Form(self.env["account.move.budget"]) + move_form.name = "Budget Test 05" + move_form.description = "Description" + move_form.date_range_id = self.date_range + move_form.date_from = "2021-01-01" + move_form.save() + + def test_06_raise_account_move_budget(self): + values = { + "name": "Budget Test 06", + "description": "Description", + "date_range_id": self.date_range.id, + "date_from": "2023-02-01", + "date_to": "2023-12-30", + } + move_budget = self.env["account.move.budget"].create(values) + + move_line_form = Form(self.env["account.move.budget.line"]) + move_line_form.name = "Dummy line" + move_line_form.budget_id = move_budget + move_line_form.date = "2021-01-02" + move_line_form.partner_id = self.env.user.partner_id + move_line_form.credit = 3000 + move_line_form.debit = 5000 + move_line_form.account_id = self.account + with self.assertRaises(ValidationError): + move_line_form.save() diff --git a/setup/account_move_budget/odoo/addons/account_move_budget b/setup/account_move_budget/odoo/addons/account_move_budget new file mode 120000 index 00000000..1ce52767 --- /dev/null +++ b/setup/account_move_budget/odoo/addons/account_move_budget @@ -0,0 +1 @@ +../../../../account_move_budget \ No newline at end of file diff --git a/setup/account_move_budget/setup.py b/setup/account_move_budget/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_move_budget/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)