Continue to improve usability of account_lock_date_update and account_permanent_lock_move_update

This commit is contained in:
Alexis de Lattre
2018-03-18 22:17:49 +01:00
parent 472275bb34
commit 65b68b7d65
6 changed files with 27 additions and 37 deletions

View File

@@ -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()

View File

@@ -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"/>

View File

@@ -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):

View File

@@ -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>

View File

@@ -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

View File

@@ -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>