From f5feecb1647486799ed4a9cf6fea597afaf43780 Mon Sep 17 00:00:00 2001 From: Richard deMeester Date: Tue, 1 Dec 2015 13:46:28 +1100 Subject: [PATCH] Added tests for ir_actions --- .../demo/ir_actions.xml | 16 +++++++++ ...st_partner_contact_in_several_companies.py | 34 ++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 partner_contact_in_several_companies/demo/ir_actions.xml diff --git a/partner_contact_in_several_companies/demo/ir_actions.xml b/partner_contact_in_several_companies/demo/ir_actions.xml new file mode 100644 index 000000000..8d457b141 --- /dev/null +++ b/partner_contact_in_several_companies/demo/ir_actions.xml @@ -0,0 +1,16 @@ + + + + + + All Customers in All Positions + ir.actions.act_window + res.partner + form + kanban,tree,form + {"search_default_customer":1, 'search_show_all_positions': {'is_set': True, 'set_value': True}} + + + + + \ No newline at end of file diff --git a/partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py b/partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py index 04cec9602..ecd7270b1 100644 --- a/partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py +++ b/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' + )