Browse Source

Added tests for ir_actions

pull/197/head
Richard deMeester 9 years ago
parent
commit
f5feecb164
  1. 16
      partner_contact_in_several_companies/demo/ir_actions.xml
  2. 34
      partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py

16
partner_contact_in_several_companies/demo/ir_actions.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="action_partner_form" model="ir.actions.act_window">
<field name="name">All Customers in All Positions</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="context">{"search_default_customer":1, 'search_show_all_positions': {'is_set': True, 'set_value': True}}</field>
<field name="search_view_id" ref="view_res_partner_filter"/>
</record>
</data>
</odoo>

34
partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py

@ -12,6 +12,7 @@ class PartnerContactInSeveralCompaniesCase(common.TransactionCase):
cr, uid = self.cr, self.uid
ModelData = self.registry('ir.model.data')
self.partner = self.registry('res.partner')
self.action = self.registry('ir.actions.act_window')
# Get test records reference
for attr, module, name in [
@ -25,7 +26,12 @@ class PartnerContactInSeveralCompaniesCase(common.TransactionCase):
('roger_contact_id', 'base', 'res_partner_main2'),
('roger_job2_id',
'partner_contact_in_several_companies',
'res_partner_main2_position_consultant')]:
'res_partner_main2_position_consultant'),
('base_partner_action_id', 'base', 'action_partner_form'),
('custom_partner_action_id',
'partner_contact_in_several_companies',
'action_partner_form'),
]:
r = ModelData.get_object_reference(cr, uid, module, name)
setattr(self, attr, r[1] if r else False)
@ -215,3 +221,29 @@ class PartnerContactInSeveralCompaniesCase(common.TransactionCase):
self.partner.browse(cr, uid, self.bob_contact_id).name,
'Bob Egnops',
)
def test_06_ir_action(self):
"""Check ir_action context is auto updated.
"""
cr, uid = self.cr, self.uid
new_context_val = "'search_show_all_positions': " \
"{'is_set': True, 'set_value': False},"
details = self.action.read(
cr, uid, [self.base_partner_action_id]
)
self.assertIn(
new_context_val,
details[0]['context'],
msg='Default actions not updated with new context'
)
details = self.action.read(
cr, uid, [self.custom_partner_action_id]
)
self.assertNotIn(
new_context_val,
details[0]['context'],
msg='Custom actions incorrectly updated with new context'
)
Loading…
Cancel
Save