[13.0][MIG] account_lock_date_update
This commit is contained in:
parent
fc1575ea6a
commit
7886472828
@ -6,7 +6,7 @@
|
||||
'summary': """
|
||||
Allow an Account adviser to update locking date without having
|
||||
access to all technical settings""",
|
||||
'version': '12.0.1.0.0',
|
||||
'version': '13.0.1.0.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': 'ACSONE SA/NV, Odoo Community Association (OCA)',
|
||||
'website': 'https://github.com/OCA/account-financial-tools',
|
||||
|
@ -1,3 +1,4 @@
|
||||
* Benjamin Willig <benjamin.willig@acsone.eu>
|
||||
* Fekete Mihai <feketemihai@gmail.com>
|
||||
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th>
|
||||
* Andrea Stirpe <a.stirpe@onestein.nl>
|
||||
|
@ -9,13 +9,13 @@ from odoo.exceptions import UserError
|
||||
class TestAccountLockDateUpdate(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAccountLockDateUpdate, self).setUp()
|
||||
super().setUp()
|
||||
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')
|
||||
self.UpdateLockDateUpdateObj = self.env[
|
||||
'account.update.lock_date'
|
||||
].sudo(self.demo_user)
|
||||
].with_user(self.demo_user)
|
||||
|
||||
def create_account_lock_date_update(self):
|
||||
return self.UpdateLockDateUpdateObj.create({
|
||||
@ -32,7 +32,7 @@ class TestAccountLockDateUpdate(TransactionCase):
|
||||
'groups_id': [(3, self.adviser_group.id)],
|
||||
})
|
||||
with self.assertRaises(UserError):
|
||||
wizard.sudo(self.demo_user.id).execute()
|
||||
wizard.with_user(self.demo_user.id).execute()
|
||||
|
||||
def test_02_update_with_access(self):
|
||||
wizard = self.create_account_lock_date_update()
|
||||
@ -43,7 +43,7 @@ class TestAccountLockDateUpdate(TransactionCase):
|
||||
self.demo_user.write({
|
||||
'groups_id': [(4, self.adviser_group.id)],
|
||||
})
|
||||
wizard.sudo(self.demo_user.id).execute()
|
||||
wizard.with_user(self.demo_user.id).execute()
|
||||
self.assertEqual(
|
||||
fields.Date.to_string(self.company.period_lock_date),
|
||||
'2000-02-01')
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 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 import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ class AccountUpdateLockDate(models.TransientModel):
|
||||
_description = 'Account Update Lock_date'
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company', string="Company", required=True)
|
||||
comodel_name='res.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 "
|
||||
@ -24,8 +24,8 @@ class AccountUpdateLockDate(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def default_get(self, field_list):
|
||||
res = super(AccountUpdateLockDate, self).default_get(field_list)
|
||||
company = self.env.user.company_id
|
||||
res = super().default_get(field_list)
|
||||
company = self.env.company
|
||||
res.update({
|
||||
'company_id': company.id,
|
||||
'period_lock_date': company.period_lock_date,
|
||||
@ -33,15 +33,12 @@ class AccountUpdateLockDate(models.TransientModel):
|
||||
})
|
||||
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):
|
||||
has_adviser_group = self.env.user.has_group('account.group_account_manager')
|
||||
if not (has_adviser_group or self.env.user._is_admin()):
|
||||
raise UserError(_("You are not allowed to execute this action."))
|
||||
|
||||
@api.multi
|
||||
def execute(self):
|
||||
self.ensure_one()
|
||||
self._check_execute_allowed()
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="account_update_lock_date_form_view">
|
||||
<record id="account_update_lock_date_form_view" model="ir.ui.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">
|
||||
@ -12,9 +12,13 @@
|
||||
<header/>
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="period_lock_date"/>
|
||||
<field name="fiscalyear_lock_date"/>
|
||||
<group>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="period_lock_date"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="fiscalyear_lock_date"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
@ -25,15 +29,14 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="account_update_lock_date_act_window">
|
||||
<record id="account_update_lock_date_act_window" model="ir.actions.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">
|
||||
<record id="account_update_lock_date_menu" model="ir.ui.menu">
|
||||
<field name="name">Update accounting lock dates</field>
|
||||
<field name="parent_id" ref="account.menu_finance_entries_actions"/>
|
||||
<field name="action" ref="account_update_lock_date_act_window"/>
|
||||
|
Loading…
Reference in New Issue
Block a user