mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[10.0][ADD] Modules which allow an account adviser to update lock dates
This commit is contained in:
71
account_lock_date_update/README.rst
Normal file
71
account_lock_date_update/README.rst
Normal file
@@ -0,0 +1,71 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
|
||||
========================
|
||||
Account Lock Date Update
|
||||
========================
|
||||
|
||||
Allow an Account adviser to update locking date without having
|
||||
access to all technical settings.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Just install it.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
No configuration needed.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To use this module, you need to be an account adviser and go to:
|
||||
|
||||
* Accounting -> Configuration -> Accounting -> Update accounting lock dates
|
||||
* Change values and click on update button
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/92/10.0
|
||||
|
||||
.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
|
||||
.. branch is "8.0" for example
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/account-financial-tools/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.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Benjamin Willig <benjamin.willig@acsone.eu>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
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.
|
||||
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
||||
1
account_lock_date_update/__init__.py
Normal file
1
account_lock_date_update/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import wizards
|
||||
20
account_lock_date_update/__manifest__.py
Normal file
20
account_lock_date_update/__manifest__.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Account Lock Date Update',
|
||||
'summary': """
|
||||
Allow an Account adviser to update locking date without having
|
||||
access to all technical settings""",
|
||||
'version': '10.0.1.0.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': 'ACSONE SA/NV, Odoo Community Association (OCA)',
|
||||
'website': 'https://github.com/OCA/account-financial-tools',
|
||||
'depends': [
|
||||
'account',
|
||||
],
|
||||
'data': [
|
||||
'wizards/account_update_lock_date.xml',
|
||||
],
|
||||
}
|
||||
BIN
account_lock_date_update/static/description/icon.png
Normal file
BIN
account_lock_date_update/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
1
account_lock_date_update/tests/__init__.py
Normal file
1
account_lock_date_update/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_account_lock_date_update
|
||||
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class TestAccountLockDateUpdate(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAccountLockDateUpdate, self).setUp()
|
||||
self.UpdateLockDateUpdateObj = self.env['account.update.lock_date']
|
||||
|
||||
self.company = self.env.ref('base.main_company')
|
||||
self.demo_user = self.env.ref('base.user_demo')
|
||||
self.adviser_group = self.env.ref('account.group_account_manager')
|
||||
|
||||
def create_account_lock_date_update(self):
|
||||
return self.UpdateLockDateUpdateObj.create({
|
||||
'company_id': self.company.id,
|
||||
})
|
||||
|
||||
def test_01_update_without_access(self):
|
||||
wizard = self.create_account_lock_date_update()
|
||||
wizard.write({
|
||||
'period_lock_date': '2000-01-01',
|
||||
'fiscalyear_lock_date': '2000-01-01',
|
||||
})
|
||||
|
||||
self.demo_user.write({
|
||||
'groups_id': [(3, self.adviser_group.id)],
|
||||
})
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
wizard.sudo(self.demo_user.id).execute()
|
||||
|
||||
def test_02_update_with_access(self):
|
||||
wizard = self.create_account_lock_date_update()
|
||||
wizard.write({
|
||||
'period_lock_date': '2000-01-01',
|
||||
'fiscalyear_lock_date': '2000-01-01',
|
||||
})
|
||||
|
||||
self.demo_user.write({
|
||||
'groups_id': [(4, self.adviser_group.id)],
|
||||
})
|
||||
|
||||
wizard.sudo(self.demo_user.id).execute()
|
||||
1
account_lock_date_update/wizards/__init__.py
Normal file
1
account_lock_date_update/wizards/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import account_update_lock_date
|
||||
53
account_lock_date_update/wizards/account_update_lock_date.py
Normal file
53
account_lock_date_update/wizards/account_update_lock_date.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class AccountUpdateLockDate(models.TransientModel):
|
||||
|
||||
_name = 'account.update.lock_date'
|
||||
_description = 'Account Update Lock_date'
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company', string="Company", required=True)
|
||||
period_lock_date = fields.Date(
|
||||
string="Lock Date for Non-Advisers",
|
||||
help="Only users with the 'Adviser' role can edit accounts prior to "
|
||||
"and inclusive of this date. Use it for period locking inside an "
|
||||
"open fiscal year, for example.")
|
||||
fiscalyear_lock_date = fields.Date(
|
||||
string="Lock Date",
|
||||
help="No users, including Advisers, can edit accounts prior to and "
|
||||
"inclusive of this date. Use it for fiscal year locking for "
|
||||
"example.")
|
||||
|
||||
@api.model
|
||||
def default_get(self, field_list):
|
||||
res = super(AccountUpdateLockDate, self).default_get(field_list)
|
||||
company = self.env.user.company_id
|
||||
res.update({
|
||||
'company_id': company.id,
|
||||
'period_lock_date': company.period_lock_date,
|
||||
'fiscalyear_lock_date': company.fiscalyear_lock_date,
|
||||
})
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def _check_execute_allowed(self):
|
||||
self.ensure_one()
|
||||
has_adviser_group = self.env.user.has_group(
|
||||
'account.group_account_manager')
|
||||
if not (has_adviser_group or self.env.uid == SUPERUSER_ID):
|
||||
raise UserError(_("You are not allowed to execute this action."))
|
||||
|
||||
@api.multi
|
||||
def execute(self):
|
||||
self.ensure_one()
|
||||
self._check_execute_allowed()
|
||||
self.company_id.sudo().write({
|
||||
'period_lock_date': self.period_lock_date,
|
||||
'fiscalyear_lock_date': self.fiscalyear_lock_date,
|
||||
})
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2017 ACSONE SA/NV
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="account_update_lock_date_form_view">
|
||||
<field name="name">account.update.lock_date.form (in account_lock_date_update)</field>
|
||||
<field name="model">account.update.lock_date</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<header/>
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="period_lock_date"/>
|
||||
<field name="fiscalyear_lock_date"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button string="Update" name="execute" type="object" class="btn-primary"/>
|
||||
<button string="Cancel" class="btn-default" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="account_update_lock_date_act_window">
|
||||
<field name="name">Update accounting lock dates</field>
|
||||
<field name="res_model">account.update.lock_date</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.menu" id="account_update_lock_date_menu">
|
||||
<field name="name">Update accounting lock dates</field>
|
||||
<field name="parent_id" ref="account.account_account_menu"/>
|
||||
<field name="action" ref="account_update_lock_date_act_window"/>
|
||||
<field name="groups_id" eval="[(6, 0, [ref('account.group_account_manager')])]"/>
|
||||
<field name="sequence" eval="70"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user