fix bug in asset
This commit is contained in:
parent
9bd1ace149
commit
aee1fb3cb6
|
|
@ -390,7 +390,7 @@ class AccountAsset(models.Model):
|
||||||
# no need of amount field, as it is computed and we don't want to trigger its inverse function
|
# no need of amount field, as it is computed and we don't want to trigger its inverse function
|
||||||
del (newline_vals['amount_total'])
|
del (newline_vals['amount_total'])
|
||||||
newline_vals_list.append(newline_vals)
|
newline_vals_list.append(newline_vals)
|
||||||
new_moves = self.env['account.move'].create(newline_vals_list)
|
new_moves = self.env['account.move'].sudo().create(newline_vals_list)
|
||||||
for move in new_moves:
|
for move in new_moves:
|
||||||
commands.append((4, move.id))
|
commands.append((4, move.id))
|
||||||
return self.write({'depreciation_move_ids': commands})
|
return self.write({'depreciation_move_ids': commands})
|
||||||
|
|
@ -692,7 +692,7 @@ class AccountAsset(models.Model):
|
||||||
if changes:
|
if changes:
|
||||||
asset.message_post(body=_('Asset sold or disposed. Accounting entry awaiting for validation.'),
|
asset.message_post(body=_('Asset sold or disposed. Accounting entry awaiting for validation.'),
|
||||||
tracking_value_ids=tracking_value_ids)
|
tracking_value_ids=tracking_value_ids)
|
||||||
move_ids += self.env['account.move'].search([('asset_id', '=', asset.id), ('state', '=', 'draft')]).ids
|
move_ids += self.env['account.move'].sudo().search([('asset_id', '=', asset.id), ('state', '=', 'draft')]).ids
|
||||||
|
|
||||||
return move_ids
|
return move_ids
|
||||||
|
|
||||||
|
|
@ -791,7 +791,7 @@ class AccountAsset(models.Model):
|
||||||
@api.depends('depreciation_move_ids.state', 'parent_id')
|
@api.depends('depreciation_move_ids.state', 'parent_id')
|
||||||
def _entry_count(self):
|
def _entry_count(self):
|
||||||
for asset in self:
|
for asset in self:
|
||||||
res = self.env['account.move'].search_count(
|
res = self.env['account.move'].sudo().search_count(
|
||||||
[('asset_id', '=', asset.id), ('state', '=', 'posted'), ('reversal_move_id', '=', False)])
|
[('asset_id', '=', asset.id), ('state', '=', 'posted'), ('reversal_move_id', '=', False)])
|
||||||
asset.depreciation_entries_count = res or 0
|
asset.depreciation_entries_count = res or 0
|
||||||
asset.total_depreciation_entries_count = len(asset.depreciation_move_ids)
|
asset.total_depreciation_entries_count = len(asset.depreciation_move_ids)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue