From b1fdfcde7fab1dd73ff7b81bfef015205545fc0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Mon, 31 Jan 2022 10:43:42 +0100 Subject: [PATCH] [FIX] Fix access right issues when using actions --- animal_owner/models/res_partner.py | 3 ++- .../tests/test_partner_contact_in_several_companies.py | 8 ++++---- partner_pricelist_search/models/product_pricelist.py | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/animal_owner/models/res_partner.py b/animal_owner/models/res_partner.py index 662c32e78..9444176ca 100644 --- a/animal_owner/models/res_partner.py +++ b/animal_owner/models/res_partner.py @@ -17,7 +17,8 @@ class ResPartner(models.Model): ) def action_view_animals(self): - action = self.env.ref("animal.action_animal").read()[0] + xmlid = "animal.action_animal" + action = self.env["ir.actions.act_window"]._for_xml_id(xmlid) if self.animal_count > 1: action["domain"] = [("id", "in", self.animal_ids.ids)] else: 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 7b83338c6..ad23be512 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 @@ -156,7 +156,8 @@ class PartnerContactInSeveralCompaniesCase(common.TransactionCase): "'search_show_all_positions': " "{'is_set': True, 'set_value': False}" ) - details = self.env.ref("base.action_partner_form").read()[0] + xmlid = "base.action_partner_form" + details = self.env["ir.actions.act_window"]._for_xml_id(xmlid) self.assertIn( new_context_val, @@ -164,9 +165,8 @@ class PartnerContactInSeveralCompaniesCase(common.TransactionCase): msg="Default actions not updated with new context", ) - details = self.env.ref( - "partner_contact_in_several_companies.action_partner_form" - ).read()[0] + xmlid = "partner_contact_in_several_companies.action_partner_form" + details = self.env["ir.actions.act_window"]._for_xml_id(xmlid) self.assertNotIn( new_context_val, diff --git a/partner_pricelist_search/models/product_pricelist.py b/partner_pricelist_search/models/product_pricelist.py index ed2ea12c6..dbb2f267d 100644 --- a/partner_pricelist_search/models/product_pricelist.py +++ b/partner_pricelist_search/models/product_pricelist.py @@ -13,9 +13,9 @@ class Pricelist(models.Model): else: domain = [("property_product_pricelist", "in", self.ids)] partners = self.env["res.partner"].search(domain) - action = self.env.ref("base.action_partner_form") - res = action.read()[0] - res["domain"] = [ + xmlid = "base.action_partner_form" + action = self.env["ir.actions.act_window"]._for_xml_id(xmlid) + action["domain"] = [ ("id", "in", partners.ids), ] - return res + return action