Browse Source

[9.0][partner_contact_in_several_companies] Several companies 90 (#330)

* [9.0] Read method to not use new api.

* Flake8 errors.

* Extra Test Added
pull/450/head
Richard deMeester 8 years ago
committed by Rafael Blasco
parent
commit
303445b0b6
  1. 22
      partner_contact_in_several_companies/models/ir_actions.py
  2. 8
      partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py

22
partner_contact_in_several_companies/models/ir_actions.py

@ -1,15 +1,26 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, api
from openerp import models
class IRActionsWindow(models.Model):
_inherit = 'ir.actions.act_window'
@api.multi
def read(self, fields=None, context=None, load='_classic_read'):
actions = super(IRActionsWindow, self).read(fields=fields, load=load)
# do not use new api, as read can return a single id or multi...
# def read(self, fields=None, load='_classic_read'):
def read(self, cr, uid, ids,
fields=None, context=None, load='_classic_read'):
""" call the method get_empty_list_help of the model and set the
window action help message
"""
ids_int = isinstance(ids, (int, long))
if ids_int:
ids = [ids]
actions = super(IRActionsWindow, self).read(
cr, uid, ids, fields=fields, context=context, load=load)
for action in actions:
if action.get('res_model', '') == 'res.partner':
# By default, only show standalone contact
@ -20,4 +31,7 @@ class IRActionsWindow(models.Model):
("{'search_show_all_positions': "
"{'is_set': True, 'set_value': False},"),
1)
if ids_int:
return actions[0]
return actions

8
partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py

@ -260,3 +260,11 @@ class PartnerContactInSeveralCompaniesCase(common.TransactionCase):
details[0]['context'],
msg='Custom actions incorrectly updated with new context'
)
details = self.action.read(
cr, uid, self.custom_partner_action_id
)
self.assertIs(
type(details), type({}),
msg='Action should return one dictionary if called with integer'
)
Loading…
Cancel
Save