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