|
|
@ -57,8 +57,7 @@ class AccountAssetCategory(models.Model): |
|
|
|
journal_id = fields.Many2one('account.journal', string='Journal', |
|
|
|
required=True) |
|
|
|
company_id = fields.Many2one('res.company', string='Company', |
|
|
|
required=True, |
|
|
|
default=lambda self: self.env.company) |
|
|
|
required=True, default=lambda self: self.env.company) |
|
|
|
method = fields.Selection( |
|
|
|
[('linear', 'Linear'), ('degressive', 'Degressive')], |
|
|
|
string='Computation Method', required=True, default='linear', |
|
|
@ -437,8 +436,6 @@ class AccountAssetAsset(models.Model): |
|
|
|
fields)) |
|
|
|
asset.message_post(subject=_('Asset created'), |
|
|
|
tracking_value_ids=tracking_value_ids) |
|
|
|
if self.value_residual == 0.0: |
|
|
|
self.write({'state': 'close'}) |
|
|
|
|
|
|
|
def _get_disposal_moves(self): |
|
|
|
move_ids = [] |
|
|
@ -479,8 +476,7 @@ class AccountAssetAsset(models.Model): |
|
|
|
tracked_fields, old_values) |
|
|
|
if changes: |
|
|
|
asset.message_post(subject=_( |
|
|
|
'Asset sold or disposed. Accounting entry awaiting ' |
|
|
|
'for validation.'), |
|
|
|
'Asset sold or disposed. Accounting entry awaiting for validation.'), |
|
|
|
tracking_value_ids=tracking_value_ids) |
|
|
|
move_ids += asset.depreciation_line_ids[-1].create_move( |
|
|
|
post_move=False) |
|
|
@ -489,7 +485,6 @@ class AccountAssetAsset(models.Model): |
|
|
|
|
|
|
|
def set_to_close(self): |
|
|
|
move_ids = self._get_disposal_moves() |
|
|
|
self.write({'state': 'close'}) |
|
|
|
if move_ids: |
|
|
|
name = _('Disposal Move') |
|
|
|
view_mode = 'form' |
|
|
@ -504,6 +499,8 @@ class AccountAssetAsset(models.Model): |
|
|
|
'target': 'current', |
|
|
|
'res_id': move_ids[0], |
|
|
|
} |
|
|
|
# Fallback, as if we just clicked on the smartbutton |
|
|
|
return self.open_entries() |
|
|
|
|
|
|
|
def set_to_draft(self): |
|
|
|
self.write({'state': 'draft'}) |
|
|
@ -533,15 +530,7 @@ class AccountAssetAsset(models.Model): |
|
|
|
def _check_prorata(self): |
|
|
|
if self.prorata and self.method_time != 'number': |
|
|
|
raise ValidationError(_( |
|
|
|
'Prorata temporis can be applied only for time method "number ' |
|
|
|
'of depreciations".')) |
|
|
|
|
|
|
|
@api.constrains('active', 'state') |
|
|
|
def _check_active(self): |
|
|
|
for record in self: |
|
|
|
if not record.active and record.state not in ['draft', 'close']: |
|
|
|
raise UserError( |
|
|
|
"You cannot archive a record in a running state.") |
|
|
|
'Prorata temporis can be applied only for time method "number of depreciations".')) |
|
|
|
|
|
|
|
@api.onchange('category_id') |
|
|
|
def onchange_category_id(self): |
|
|
@ -633,8 +622,7 @@ class AccountAssetDepreciationLine(models.Model): |
|
|
|
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='Linked', |
|
|
|
store=True) |
|
|
|
move_check = fields.Boolean(compute='_get_move_check', string='Linked', store=True) |
|
|
|
move_posted_check = fields.Boolean(compute='_get_move_posted_check', |
|
|
|
string='Posted', store=True) |
|
|
|
|
|
|
|