mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Continue to improve usability of account_lock_date_update and account_permanent_lock_move_update
This commit is contained in:
@@ -35,7 +35,6 @@ class AccountUpdateLockDate(models.TransientModel):
|
||||
})
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def _check_execute_allowed(self):
|
||||
self.ensure_one()
|
||||
has_adviser_group = self.env.user.has_group(
|
||||
@@ -43,7 +42,6 @@ class AccountUpdateLockDate(models.TransientModel):
|
||||
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()
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<field name="model">account.update.lock_date</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group>
|
||||
<group name="main">
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="period_lock_date"/>
|
||||
<field name="fiscalyear_lock_date"/>
|
||||
|
||||
@@ -8,9 +8,12 @@ from odoo.exceptions import UserError
|
||||
class PermanentLockDateWizard(models.TransientModel):
|
||||
_name = 'permanent.lock.date.wizard'
|
||||
|
||||
lock_date = fields.Date(string="Lock Date")
|
||||
lock_date = fields.Date(string="New Lock Date")
|
||||
company_id = fields.Many2one(comodel_name='res.company',
|
||||
string='Company')
|
||||
current_lock_date = fields.Date(
|
||||
related='company_id.permanent_lock_date', readonly=True,
|
||||
string='Current Lock Date')
|
||||
|
||||
@api.multi
|
||||
def confirm_date(self):
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Lock permanently entries">
|
||||
<label string="All journal entries prior to and included at this date will be permanently locked."/>
|
||||
<label string="All journal entries prior to and included at the new lock date will be permanently locked."/>
|
||||
<group>
|
||||
<field name="current_lock_date"/>
|
||||
<field name="lock_date" required="1"/>
|
||||
</group>
|
||||
<footer>
|
||||
|
||||
@@ -9,29 +9,27 @@ class AccountUpdateLockDate(models.TransientModel):
|
||||
|
||||
_inherit = 'account.update.lock_date'
|
||||
|
||||
permanent_lock_date = fields.Date(
|
||||
string="Permanent Lock Date", readonly=True)
|
||||
tmp_permanent_lock_date = fields.Date(string="Permanent Lock Date")
|
||||
|
||||
@api.model
|
||||
def default_get(self, field_list):
|
||||
res = super(AccountUpdateLockDate, self).default_get(field_list)
|
||||
company = self.env.user.company_id
|
||||
res['permanent_lock_date'] = company.permanent_lock_date
|
||||
res['tmp_permanent_lock_date'] = company.permanent_lock_date
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def change_permanent_lock_date(self):
|
||||
self.ensure_one()
|
||||
company = self.company_id
|
||||
wizard = self.env['permanent.lock.date.wizard'].create({
|
||||
'company_id': company.id,
|
||||
'lock_date': company.permanent_lock_date,
|
||||
})
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'permanent.lock.date.wizard',
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'res_id': wizard.id,
|
||||
'target': 'new',
|
||||
}
|
||||
def execute(self):
|
||||
res = super(AccountUpdateLockDate, self).execute()
|
||||
if self.tmp_permanent_lock_date != self.company_id.permanent_lock_date:
|
||||
wizard = self.env['permanent.lock.date.wizard'].create({
|
||||
'company_id': self.company_id.id,
|
||||
'lock_date': self.tmp_permanent_lock_date,
|
||||
})
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'permanent.lock.date.wizard',
|
||||
'view_mode': 'form',
|
||||
'res_id': wizard.id,
|
||||
'target': 'new',
|
||||
}
|
||||
return res
|
||||
|
||||
@@ -9,19 +9,9 @@
|
||||
<field name="model">account.update.lock_date</field>
|
||||
<field name="inherit_id" ref="account_lock_date_update.account_update_lock_date_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<sheet position="inside">
|
||||
<group>
|
||||
<group>
|
||||
<field name="permanent_lock_date"/>
|
||||
</group>
|
||||
<group>
|
||||
<button string="Permanently Lock Entries" name="change_permanent_lock_date"
|
||||
type="object" class="btn-primary"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
|
||||
<field name="fiscalyear_lock_date" position="after">
|
||||
<field name="tmp_permanent_lock_date"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user