2
0

[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 committed by Rodrigo
parent a16a456511
commit 20078b4472

View File

@ -490,10 +490,6 @@ class AccountAsset(models.Model):
def open_entries(self): def open_entries(self):
self.ensure_one() 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 # needed for avoiding errors after grouping in assets
context = dict(self.env.context) context = dict(self.env.context)
context.pop("group_by", None) context.pop("group_by", None)
@ -504,7 +500,7 @@ class AccountAsset(models.Model):
"view_id": False, "view_id": False,
"type": "ir.actions.act_window", "type": "ir.actions.act_window",
"context": context, "context": context,
"domain": [("id", "in", am_ids)], "domain": [("id", "in", self.account_move_line_ids.mapped("move_id").ids)],
} }
def _group_lines(self, table): def _group_lines(self, table):