Browse Source

[FIX] fix action test

pull/347/head
Nicolas JEUDY 8 years ago
parent
commit
b44adf3af1
  1. 1
      partner_contact_in_several_companies/__manifest__.py
  2. 4
      partner_contact_in_several_companies/data/ir_actions.xml
  3. 13
      partner_contact_in_several_companies/models/ir_actions.py
  4. 18
      partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py

1
partner_contact_in_several_companies/__manifest__.py

@ -29,7 +29,6 @@
],
"data": [
"views/res_partner.xml",
"data/ir_actions.xml",
],
"demo": [
"demo/res_partner.xml",

4
partner_contact_in_several_companies/data/ir_actions.xml

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<function model="ir.actions.act_window" name="_enable_context"/>
</odoo>

13
partner_contact_in_several_companies/models/ir_actions.py

@ -21,16 +21,3 @@ class IRActionsWindow(models.Model):
"{'is_set': True, 'set_value': False},"),
1)
return actions
@api.model
def _enable_context(self):
action = self.env.ref('base.action_partner_form')
if 'search_show_all_positions' not in action.context:
action_ctx = action.context.replace(
'{',
("{'search_show_all_positions': "
"{'is_set': True, 'set_value': False},"),
1)
action.write({'context': action_ctx})
return True

18
partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py

@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo.tests import common
_logger = logging.getLogger(__name__)
class PartnerContactInSeveralCompaniesCase(common.TransactionCase):
@ -199,18 +201,24 @@ class PartnerContactInSeveralCompaniesCase(common.TransactionCase):
new_context_val = "'search_show_all_positions': " \
"{'is_set': True, 'set_value': False}"
details = self.env.ref('base.action_partner_form')
details = self.env['ir.actions.act_window'].for_xml_id(
'base',
'action_partner_form')
_logger.debug(details['context'])
self.assertIn(
new_context_val,
details.context,
details['context'],
msg='Default actions not updated with new context'
)
details = self.env.ref(
'partner_contact_in_several_companies.action_partner_form')
details = self.env['ir.actions.act_window'].for_xml_id(
'partner_contact_in_several_companies',
'action_partner_form')
_logger.debug(details['context'])
self.assertNotIn(
new_context_val,
details.context,
details['context'],
msg='Custom actions incorrectly updated with new context'
)
Loading…
Cancel
Save