From f695ee7ffc77c7b46a4dd9d443918be1c6f55156 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 18 Mar 2020 19:25:11 +0100 Subject: [PATCH] [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. --- account_asset_management/__manifest__.py | 2 +- account_asset_management/models/account_asset.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/account_asset_management/__manifest__.py b/account_asset_management/__manifest__.py index 32da6ad2c..a44082861 100644 --- a/account_asset_management/__manifest__.py +++ b/account_asset_management/__manifest__.py @@ -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"], diff --git a/account_asset_management/models/account_asset.py b/account_asset_management/models/account_asset.py index d61bac18a..084ab20a9 100644 --- a/account_asset_management/models/account_asset.py +++ b/account_asset_management/models/account_asset.py @@ -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)], }