[FIX] account: dashboard traceback

In the dashboard view, it's possible to use the "Group By" feature.
However, when clicking on a link on any dashboard, a traceback might
show up.

This is because the context key `group_by` is kept when clicking on an
action. If the destination view is a list/kanban, and the destination
model doesn't have the field, the system will try to make a grouping by
a field which doesn't exist.

The solution is to remove the `group_by` key from the context, since it
doesn't make sense to send it the the destination model.

opw-684568
This commit is contained in:
Nicolas Martinelli
2016-08-08 08:24:57 +02:00
parent 8a3a620404
commit 4f037210c2
@@ -303,6 +303,7 @@ class account_journal(models.Model):
invoice_type = _journal_invoice_type_map[(self.type, self._context.get('invoice_type'))]
ctx = self._context.copy()
ctx.pop('group_by', None)
ctx.update({
'journal_type': self.type,
'default_journal_id': self.id,
@@ -336,6 +337,7 @@ class account_journal(models.Model):
'default_payment_type': payment_type,
'default_journal_id': self.id
})
ctx.pop('group_by', None)
action_rec = self.env['ir.model.data'].xmlid_to_object('account.action_account_payments')
if action_rec:
action = action_rec.read([])[0]
@@ -351,6 +353,7 @@ class account_journal(models.Model):
ctx = dict(self.env.context, default_journal_id=self.id)
if ctx.get('search_default_journal', False):
ctx.update(search_default_journal_id=self.id)
ctx.pop('group_by', None)
ir_model_obj = self.pool['ir.model.data']
model, action_id = ir_model_obj.get_object_reference(self._cr, self._uid, 'account', action_name)
action = self.pool[model].read(self._cr, self._uid, action_id, context=self._context)