[IMP] account_asset_management: Simplify code for opening related entries

We don't need the search having the one2many field and no need also for list
comprehension having mapped operator.
This commit is contained in:
Pedro M. Baeza
2020-03-18 19:35:44 +01:00
parent 36f38adf06
commit 17a298b9d8

View File

@@ -443,9 +443,6 @@ class AccountAsset(models.Model):
@api.multi
def open_entries(self):
self.ensure_one()
amls = self.env['account.move.line'].search(
[('asset_id', '=', self.id)], order='date ASC')
am_ids = [l.move_id.id for l in amls]
# needed for avoiding errors after grouping in assets
context = dict(self.env.context)
context.pop('group_by', None)
@@ -457,7 +454,8 @@ class AccountAsset(models.Model):
'view_id': False,
'type': 'ir.actions.act_window',
'context': context,
'domain': [('id', 'in', am_ids)],
'domain': [
('id', 'in', self.account_move_line_ids.mapped('move_id').ids)]
}
@api.multi