2
0

[FIX] account_asset_management: Avoid error

Steps to reproduce the problem:

* Go to assets view
* Group by profile
* Unfold a group and click on an asset
* Click on "Journal Entries" smart-button
* Go back to the asset list
* Click again on the same asset (or another).
* Click on "Journal Entries" smart-button

Current behavior:

Error saying "KeyError: 'profile_id'"

Expected behavior:

No error

The cause for this is that Odoo stores in the context the key `group_by` with the
value `profile_id` in the specified chain of steps. That context entry is used for
grouping records in the list, and system tries to group the journal entries also
by that field, which doesn't exists in the other model, and thus the error.

We avoided it copying the context to be passes and leaving out that entry.
This commit is contained in:
Pedro M. Baeza 2020-03-18 19:25:11 +01:00 committed by Rodrigo
parent 7e9d38ef5e
commit a16a456511
2 changed files with 5 additions and 2 deletions

View File

@ -4,7 +4,7 @@
{
"name": "Assets Management",
"version": "13.0.1.0.0",
"version": "13.0.1.0.1",
"license": "AGPL-3",
"depends": ["account"],
"excludes": ["account_asset"],

View File

@ -494,13 +494,16 @@ class AccountAsset(models.Model):
[("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)
return {
"name": _("Journal Entries"),
"view_mode": "tree,form",
"res_model": "account.move",
"view_id": False,
"type": "ir.actions.act_window",
"context": self.env.context,
"context": context,
"domain": [("id", "in", am_ids)],
}