diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index b3f719f1449..6253235442d 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -238,6 +238,7 @@ class AccountMove(models.Model): @api.multi def _reverse_move(self, date=None, journal_id=None, auto=False): self.ensure_one() + date = date or fields.Date.today() with self.env.norecompute(): reversed_move = self.copy(default={ 'date': date, @@ -502,8 +503,8 @@ class AccountMoveLine(models.Model): is_unaffected_earnings_line = fields.Boolean(string="Is Unaffected Earnings Line", compute="_compute_is_unaffected_earnings_line", help="Tells whether or not this line belongs to an unaffected earnings account") _sql_constraints = [ - ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in accounting entry !'), - ('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in accounting entry !'), + ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in accounting entry! Credit or debit should be zero.'), + ('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in accounting entry! Credit and debit should be positive.'), ] @api.model diff --git a/addons/account_asset/models/account_asset.py b/addons/account_asset/models/account_asset.py index 2f45dd4fff2..6e2ee099ad6 100644 --- a/addons/account_asset/models/account_asset.py +++ b/addons/account_asset/models/account_asset.py @@ -500,17 +500,12 @@ class AccountAssetDepreciationLine(models.Model): @api.multi def create_move(self, post_move=True): created_moves = self.env['account.move'] - # `line.move_id` was invalidated from the cache at each iteration - # To prevent to refetch `move_id` of all lines at each iteration just to check a UserError, - # we use an intermediar dict which stores the information the UserError check requires. - line_moves = {line: line.move_id for line in self} + if self.mapped('move_id'): + raise UserError(_('This depreciation is already linked to a journal entry! Please post or delete it.')) for line in self: - if line_moves[line]: - raise UserError(_('This depreciation is already linked to a journal entry! Please post or delete it.')) move_vals = self._prepare_move(line) move = self.env['account.move'].create(move_vals) line.write({'move_id': move.id, 'move_check': True}) - line_moves[line] = move created_moves |= move if post_move and created_moves: diff --git a/addons/calendar/views/calendar_views.xml b/addons/calendar/views/calendar_views.xml index 80994d946fa..aafd119c49a 100644 --- a/addons/calendar/views/calendar_views.xml +++ b/addons/calendar/views/calendar_views.xml @@ -162,7 +162,7 @@