diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index 3c2290ece72..d7ceeeb0c1e 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -418,12 +418,20 @@ class AccountAssetDepreciationLine(models.Model): depreciated_value = fields.Float(string='Cumulative Depreciation', required=True) depreciation_date = fields.Date('Depreciation Date', index=True) move_id = fields.Many2one('account.move', string='Depreciation Entry') - move_check = fields.Boolean(compute='_get_move_check', string='Posted', track_visibility='always', store=True) + move_check = fields.Boolean(compute='_get_move_check', string='Linked', track_visibility='always', store=True) + move_posted_check = fields.Boolean(compute='_get_move_posted_check', string='Posted', track_visibility='always', store=True) - @api.one + @api.multi @api.depends('move_id') def _get_move_check(self): - self.move_check = bool(self.move_id) + for line in self: + line.move_check = bool(line.move_id) + + @api.multi + @api.depends('move_id.state') + def _get_move_posted_check(self): + for line in self: + line.move_posted_check = True if line.move_id and line.move_id.state == 'posted' else False @api.multi def create_move(self, post_move=True): @@ -567,6 +575,13 @@ class AccountMove(models.Model): asset_depreciation_ids = fields.One2many('account.asset.depreciation.line', 'move_id', string='Assets Depreciation Lines', ondelete="restrict") + @api.multi + def button_cancel(self): + for move in self: + for line in move.asset_depreciation_ids: + line.move_posted_check = False + return super(AccountMove, self).button_cancel() + @api.multi def post(self): for move in self: diff --git a/addons/account_asset/static/src/js/account_asset.js b/addons/account_asset/static/src/js/account_asset.js index 69c4fc1f523..5fe995a98a8 100644 --- a/addons/account_asset/static/src/js/account_asset.js +++ b/addons/account_asset/static/src/js/account_asset.js @@ -16,14 +16,18 @@ var _t = core._t; var WidgetOnButton = core.list_widget_registry.get('field').extend({ format: function(row_data, options) { this._super.apply(this, arguments); - this.has_value = !!row_data.move_check.value; + this.is_posted = !!row_data.move_posted_check.value; this.parent_state = row_data.parent_state.value; - + var class_color = ''; + if (this.is_posted){class_color = 'o_is_posted';} + else{ + if (row_data.move_check.value){class_color = 'o_unposted';} + } return $('
').append((this.parent_state === 'open')? $('', { type: 'button', title: (this.has_value)? _t('Posted') : _t('Unposted'), disabled: !!this.has_value, - 'class': 'btn btn-sm btn-link fa fa-circle o_widgetonbutton' + ((this.has_value)? ' o_has_value' : ''), + 'class': 'btn btn-sm btn-link fa fa-circle o_widgetonbutton ' + class_color, }) : '').html(); }, }); diff --git a/addons/account_asset/static/src/less/account_asset.less b/addons/account_asset/static/src/less/account_asset.less index f1b9b3e7cd4..c540f2d65cd 100644 --- a/addons/account_asset/static/src/less/account_asset.less +++ b/addons/account_asset/static/src/less/account_asset.less @@ -1,6 +1,9 @@ .o_web_client .o_widgetonbutton { color: @brand-danger; - &.o_has_value { + &.o_is_posted { color: @brand-success; } + &.o_unposted{ + color: @brand-warning; + } } diff --git a/addons/account_asset/views/account_asset_view.xml b/addons/account_asset/views/account_asset_view.xml index cf52ee59e9c..b4d5f7ec837 100644 --- a/addons/account_asset/views/account_asset_view.xml +++ b/addons/account_asset/views/account_asset_view.xml @@ -148,6 +148,7 @@