Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
1
account_lock_date_update/tests/__init__.py
Executable file
1
account_lock_date_update/tests/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import test_account_lock_date_update
|
||||
66
account_lock_date_update/tests/test_account_lock_date_update.py
Executable file
66
account_lock_date_update/tests/test_account_lock_date_update.py
Executable file
@@ -0,0 +1,66 @@
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import Command, fields
|
||||
from odoo.exceptions import AccessError
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestAccountLockDateUpdate(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.env = cls.env(
|
||||
context=dict(
|
||||
cls.env.context,
|
||||
mail_create_nolog=True,
|
||||
mail_create_nosubscribe=True,
|
||||
mail_notrack=True,
|
||||
no_reset_password=True,
|
||||
tracking_disable=True,
|
||||
)
|
||||
)
|
||||
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
|
||||
cls.company = cls.env.ref("base.main_company")
|
||||
cls.demo_user = cls.env.ref("base.user_demo")
|
||||
cls.adviser_group = cls.env.ref("account.group_account_manager")
|
||||
|
||||
def test_01_update_without_access(self):
|
||||
self.demo_user.write({"groups_id": [Command.unlink(self.adviser_group.id)]})
|
||||
with self.assertRaises(AccessError):
|
||||
self.env["account.update.lock_date"].with_user(self.demo_user.id).create(
|
||||
{"company_id": self.company.id}
|
||||
)
|
||||
|
||||
def test_02_update_with_access(self):
|
||||
self.demo_user.write({"groups_id": [Command.link(self.adviser_group.id)]})
|
||||
wizard = (
|
||||
self.env["account.update.lock_date"]
|
||||
.with_user(self.demo_user.id)
|
||||
.create({"company_id": self.company.id})
|
||||
)
|
||||
wizard.write(
|
||||
{
|
||||
"sale_lock_date": "2000-05-01",
|
||||
"purchase_lock_date": "2000-04-01",
|
||||
"tax_lock_date": "2000-03-01",
|
||||
"fiscalyear_lock_date": "2000-02-01",
|
||||
"hard_lock_date": "2000-01-01",
|
||||
}
|
||||
)
|
||||
wizard.with_user(self.demo_user.id).execute()
|
||||
self.assertEqual(
|
||||
fields.Date.to_string(self.company.sale_lock_date), "2000-05-01"
|
||||
)
|
||||
self.assertEqual(
|
||||
fields.Date.to_string(self.company.purchase_lock_date), "2000-04-01"
|
||||
)
|
||||
self.assertEqual(
|
||||
fields.Date.to_string(self.company.tax_lock_date), "2000-03-01"
|
||||
)
|
||||
self.assertEqual(
|
||||
fields.Date.to_string(self.company.fiscalyear_lock_date), "2000-02-01"
|
||||
)
|
||||
self.assertEqual(
|
||||
fields.Date.to_string(self.company.hard_lock_date), "2000-01-01"
|
||||
)
|
||||
Reference in New Issue
Block a user