diff --git a/account_move_locking/__openerp__.py b/account_move_locking/__openerp__.py
index cfa0974b0..ef79ab44f 100644
--- a/account_move_locking/__openerp__.py
+++ b/account_move_locking/__openerp__.py
@@ -19,13 +19,13 @@
##############################################################################
{
"name": "Move locked to prevent modification",
- "version": "8.0.1.0.0",
+ "version": "9.0.1.0.0",
"depends": ["base", "account"],
"author": "Camptocamp,Odoo Community Association (OCA)",
'license': 'AGPL-3',
'website': 'http://www.camptocamp.com',
'data': ['account_view.xml',
'wizard/account_lock_move_view.xml'],
- 'installable': False,
+ 'installable': True,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/account_move_locking/account.py b/account_move_locking/account.py
index 3e1956eac..006b0191d 100644
--- a/account_move_locking/account.py
+++ b/account_move_locking/account.py
@@ -30,16 +30,14 @@ class AccountMove(models.Model):
def write(self, vals):
for move in self:
if move.locked:
- raise exceptions.Warning(_('Move Locked!'),
- move.name)
+ raise exceptions.UserError(_('Move Locked! %s') % (move.name))
return super(AccountMove, self).write(vals)
@api.multi
def unlink(self):
for move in self:
if move.locked:
- raise exceptions.Warning(_('Move Locked!'),
- move.name)
+ raise exceptions.UserError(_('Move Locked! %s') % (move.name))
return super(AccountMove, self).unlink()
@api.multi
@@ -48,6 +46,5 @@ class AccountMove(models.Model):
# so we need to test manualy if the move is locked
for move in self:
if move.locked:
- raise exceptions.Warning(_('Move Locked!'),
- move.name)
+ raise exceptions.UserError(_('Move Locked! %s') % (move.name))
return super(AccountMove, self).button_cancel()
diff --git a/account_move_locking/account_view.xml b/account_move_locking/account_view.xml
index cbcebb132..4d4828c21 100644
--- a/account_move_locking/account_view.xml
+++ b/account_move_locking/account_view.xml
@@ -6,7 +6,7 @@
account.move
-
+
diff --git a/account_move_locking/wizard/account_lock_account_move.py b/account_move_locking/wizard/account_lock_account_move.py
index 6a2e554fd..ee18afee6 100644
--- a/account_move_locking/wizard/account_lock_account_move.py
+++ b/account_move_locking/wizard/account_lock_account_move.py
@@ -29,11 +29,17 @@ class lock_account_move(models.TransientModel):
rel='wizard_lock_account_move_journal',
string='Journal',
required=True)
- period_ids = fields.Many2many('account.period',
- rel='wizard_lock_account_move_period',
- string='Period',
- required=True,
- domain=[('state', '<>', 'done')])
+ date_start = fields.Datetime(string='Date start',
+ required=True)
+ date_end = fields.Datetime(string='Date end',
+ required=True)
+
+ @api.one
+ @api.constrains('date_start', 'date_end')
+ def _check_date_stop_start(self):
+ if self.date_start > self.date_end:
+ raise exceptions.UserError(_('Date start need to be \
+ before Date end'))
@api.multi
def lock_move(self, data):
@@ -42,21 +48,22 @@ class lock_account_move(models.TransientModel):
('journal_id',
'in',
self.journal_ids.ids),
- ('period_id', 'in',
- self.period_ids.ids)],
+ ('date', '>=',
+ self.date_start),
+ ('date', '<=',
+ self.date_end)],
order='date')
if draft_move:
- raise exceptions.Warning(_('Warning!'),
- _('Unposted move in period/jounal \
- selected, please post it before \
- locking them'))
+ raise exceptions.UserError(_('Unposted move in period/jounal \
+ selected, please post it before \
+ locking them'))
move = obj_move.search([('state', '=', 'posted'),
('locked', '=', False),
('journal_id', 'in', self.journal_ids.ids),
- ('period_id', 'in', self.period_ids.ids)],
+ ('date', '>=', self.date_start),
+ ('date', '<=', self.date_end)],
order='date')
if not move:
- raise exceptions.Warning(_('Warning!'),
- _('No move to locked found'))
+ raise exceptions.UserError(_('No move to locked found'))
move.write({'locked': True})
return {'type': 'ir.actions.act_window_close'}
diff --git a/account_move_locking/wizard/account_lock_move_view.xml b/account_move_locking/wizard/account_lock_move_view.xml
index 823072932..ebcf94a82 100644
--- a/account_move_locking/wizard/account_lock_move_view.xml
+++ b/account_move_locking/wizard/account_lock_move_view.xml
@@ -10,7 +10,8 @@