Skip to content
Snippets Groups Projects
Commit 7ecfe1f9d366 authored by Etienne Ferriere's avatar Etienne Ferriere
Browse files

Give the rights to create, edit and delete accounting fiscal years and periods

to a new and specific group.
parent 1d19434d0d3f
No related branches found
No related tags found
No related merge requests found
Pipeline #79084 failed
This commit is part of merge request !42. Comments created here will be created in the context of that merge request.
......@@ -2,6 +2,12 @@
Changelog
=========
13.0.1.6.0
----------
Give the rights to create, edit and delete accounting fiscal years and periods
to a new and specific group.
13.0.1.5.1
----------
......
......@@ -22,9 +22,9 @@
"name": "Accounting Periods",
"license": "AGPL-3",
"summary": "Add period accounting concept",
"version": "13.0.1.5.1",
"version": "13.0.1.6.0",
"category": "Accounting/Accounting",
"author": "XCG Consulting",
"website": "https://odoo.consulting/",
"depends": ["account"],
"data": [
......@@ -26,8 +26,9 @@
"category": "Accounting/Accounting",
"author": "XCG Consulting",
"website": "https://odoo.consulting/",
"depends": ["account"],
"data": [
"security/groups.xml",
"security/ir.model.access.csv",
"security/record_rules.xml",
"wizards/account_period_close_view.xml",
......
......@@ -7,8 +7,8 @@
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-09-09 08:42+0000\n"
"PO-Revision-Date: 2022-09-09 10:45+0200\n"
"POT-Creation-Date: 2024-03-04 19:30+0000\n"
"PO-Revision-Date: 2024-03-04 20:33+0100\n"
"Last-Translator: Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr>\n"
"Language-Team: XCG Consulting\n"
"Language: fr\n"
......@@ -16,7 +16,7 @@
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 2.4.2\n"
"X-Generator: Poedit 3.0.1\n"
#. module: account_period
#: model:ir.model,name:account_period.model_account_chart_template
......@@ -24,6 +24,11 @@
msgstr "Modèle de plan comptable"
#. module: account_period
#: model:res.groups,name:account_period.group_account_period
msgid "Accounting Fiscal Years & Periods"
msgstr "Exercices fiscaux & Périodes comptables"
#. module: account_period
#: model:ir.model.fields,field_description:account_period.field_account_move__accounting_date
msgid "Accounting date"
msgstr "Date de comptabilisation"
......@@ -102,6 +107,12 @@
msgstr "Créer des périodes mensuelles"
#. module: account_period
#: model:res.groups,comment:account_period.group_account_period
msgid "Create, edit and delete accounting fiscal years and periods."
msgstr ""
"Créer, éditer et supprimer des années fiscales et des périodes comptables."
#. module: account_period
#: model:ir.model.fields,field_description:account_period.field_account_fiscalyear__create_uid
#: model:ir.model.fields,field_description:account_period.field_account_period__create_uid
#: model:ir.model.fields,field_description:account_period.field_account_period_close__create_uid
......
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Security group to create, edit and delete accounting fiscal years and
periods. -->
<record id="group_account_period" model="res.groups">
<field name="name">Accounting Fiscal Years &amp; Periods</field>
<field name="comment">
Create, edit and delete accounting fiscal years and periods.
</field>
<field name="category_id" ref="base.module_category_hidden" />
<field
name="users"
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
/>
</record>
</odoo>
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
account_fiscalyear_accmanager_access,account_fiscalyear_accmanager_access,model_account_fiscalyear,account.group_account_manager,1,1,1,1
account_fiscalyear_accmanager_access,account_fiscalyear_accmanager_access,model_account_fiscalyear,account_period.group_account_period,1,1,1,1
account_fiscalyear_any_access,account_fiscalyear_any_access,model_account_fiscalyear,,1,0,0,0
......@@ -3,3 +3,3 @@
account_fiscalyear_any_access,account_fiscalyear_any_access,model_account_fiscalyear,,1,0,0,0
account_period_accmanager_access,account_period_accmanager_access,model_account_period,account.group_account_manager,1,1,1,1
account_period_accmanager_access,account_period_accmanager_access,model_account_period,account_period.group_account_period,1,1,1,1
account_period_any_access,account_period_any_access,model_account_period,,1,0,0,0
......@@ -20,6 +20,7 @@
from datetime import date
import odoo.exceptions
import odoo.fields
import odoo.tests
......@@ -31,6 +32,7 @@
def setUp(self):
super().setUp()
self.group_id = self.ref("account_period.group_account_period")
self.long_past = date(1977, 9, 20)
# this should not be in any demo data, so use assert, and not a unit
# assert.
......@@ -44,6 +46,14 @@
"date_stop": odoo.fields.Date.to_date("2018-12-31"),
}
)
# Check that without the correct security group, it is not possible to
# create a period and edit a fiscal year.
self.env.user.groups_id = [(3, self.group_id)]
with self.assertRaises(odoo.exceptions.AccessError):
fiscalyear.create_period()
self.env.user.groups_id = [(4, self.group_id)]
fiscalyear.create_period()
self.assertEqual(len(fiscalyear.period_ids), 12)
self.assertEqual(
......@@ -55,6 +65,21 @@
min(period.date_start for period in fiscalyear.period_ids),
)
# Check that without the correct security group, it is not possible to
# edit or delete a period.
period = fiscalyear.period_ids[2]
self.env.user.groups_id = [(3, self.group_id)]
with self.assertRaises(odoo.exceptions.AccessError):
period.write({"state": "done"})
with self.assertRaises(odoo.exceptions.AccessError):
period.unlink()
self.env.user.groups_id = [(4, self.group_id)]
period.write({"state": "done"})
self.assertEqual(period.state, "done")
period.unlink()
self.assertFalse(period)
def test_create_period_change_fiscalyear_end(self):
self.env.company.write(
{"fiscalyear_last_month": "9", "fiscalyear_last_day": 20}
......@@ -79,6 +104,14 @@
def test_create_fiscal_year(self):
"""Test the automatic creation."""
# Check that without the correct security group, it is not possible to
# create a fiscal year.
self.env.user.groups_id = [(3, self.group_id)]
with self.assertRaises(odoo.exceptions.AccessError):
self.env["account.fiscalyear"].find(self.long_past, create=True)
self.env.user.groups_id = [(4, self.group_id)]
# clean up all fiscal year for a first branch
fiscal_year = self.env["account.fiscalyear"].find(
self.long_past, create=True
......@@ -87,6 +120,16 @@
self.assertEqual(fiscal_year.date_stop, date(1977, 12, 31))
self.assertEqual(fiscal_year.company_id.id, 1)
# Check that without the correct security group, it is not possible to
# delete a fiscal year.
self.env.user.groups_id = [(3, self.group_id)]
with self.assertRaises(odoo.exceptions.AccessError):
fiscal_year.unlink()
self.env.user.groups_id = [(4, self.group_id)]
fiscal_year.unlink()
self.assertFalse(fiscal_year)
def test_create_fiscal_year_first_day_of_year(self):
"""Test the creation of the fiscal year, ensuring the lower limit
does not cause trouble."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment