Skip to content

Commit

Permalink
[FIX] account_asset_management: Avoid error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pedrobaeza committed Mar 18, 2020
1 parent 0bb6165 commit 36f38ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion account_asset_management/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
'name': 'Assets Management',
'version': '12.0.2.2.2',
'version': '12.0.2.2.3',
'license': 'AGPL-3',
'depends': [
'account',
Expand Down
5 changes: 4 additions & 1 deletion account_asset_management/models/account_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,17 @@ def open_entries(self):
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)
return {
'name': _("Journal Entries"),
'view_type': 'form',
'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)],
}

Expand Down

0 comments on commit 36f38ad

Please sign in to comment.