Skip to content

Commit

Permalink
[MIG] crm_security_group: Backport from 14.0 to 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinDupont committed Sep 25, 2024
1 parent 477ca59 commit 94e9bd5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion crm_security_group/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "CRM Only Security Groups",
"summary": "Add new group in Sales to show only CRM",
"version": "14.0.1.1.0",
"version": "12.0.1.0.0",
"category": "Customer Relationship Management",
"website": "https://github.com/OCA/crm",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
4 changes: 0 additions & 4 deletions crm_security_group/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ access_crm_lead_user,crm.lead.user,crm.model_crm_lead,crm_security_group.group_c
access_crm_team_user,crm.team.user,sales_team.model_crm_team,crm_security_group.group_crm_own_leads,1,0,0,0
access_crm_team_manager,crm.team.manager,sales_team.model_crm_team,crm_security_group.group_crm_own_leads,1,1,1,1
access_crm_stage_manager,crm.stage.manager,crm.model_crm_stage,crm_security_group.group_crm_manager,1,1,1,1
access_crm_tag_own_leads,sale_team.crm.tag.own.leads,sales_team.model_crm_tag,crm_security_group.group_crm_own_leads,1,1,1,0
access_crm_tag_manager,sale_team.crm.tag.manager,sales_team.model_crm_tag,crm_security_group.group_crm_manager,1,1,1,1
access_crm_lead_scoring_frequency_user,crm.lead.scoring.frequency.user,crm.model_crm_lead_scoring_frequency,crm_security_group.group_crm_own_leads,1,0,0,0
access_crm_lead_scoring_frequency_field_user,crm.lead.scoring.frequency.field.user,crm.model_crm_lead_scoring_frequency_field,crm_security_group.group_crm_own_leads,1,0,0,0
26 changes: 13 additions & 13 deletions crm_security_group/tests/test_crm_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,64 +61,64 @@ def setUpClass(cls):
)

def test_user_crm_only(self):
model = self.model_ir_ui_menu.with_user(self.crm_user)
model = self.model_ir_ui_menu.sudo(self.crm_user)
items = model._visible_menu_ids()
self.assertTrue(self.crm_menu.id in items)
self.assertFalse(self.sale_menu.id in items)
# Crm lead checks
crm_lead_model = self.env["crm.lead"].with_user(self.crm_user)
crm_lead_model = self.env["crm.lead"].sudo(self.crm_user)
crm_lead = crm_lead_model.browse(self.crm_lead.id)
self.assertEqual(crm_lead, self.crm_lead)
with self.assertRaises(AccessError):
self.crm_lead.with_user(self.crm_user).unlink()
self.crm_lead.sudo(self.crm_user).unlink()
crm_lead_form = Form(crm_lead_model)
crm_lead_form.name = "Lead"
crm_lead_form.save()

def test_user_sale(self):
model = self.model_ir_ui_menu.with_user(self.sale_user)
model = self.model_ir_ui_menu.sudo(self.sale_user)
items = model._visible_menu_ids()
self.assertFalse(self.crm_menu.id in items)
self.assertTrue(self.sale_menu.id in items)
# Crm lead checks
crm_lead_model = self.env["crm.lead"].with_user(self.sale_user)
crm_lead_model = self.env["crm.lead"].sudo(self.sale_user)
crm_lead = crm_lead_model.browse(self.crm_lead.id)
self.assertEqual(crm_lead, self.crm_lead)
with self.assertRaises(AccessError):
self.crm_lead.with_user(self.sale_user).unlink()
self.crm_lead.sudo(self.sale_user).unlink()
crm_lead_form = Form(crm_lead_model)
crm_lead_form.name = "Lead"
crm_lead_form.save()
# Sale order checks
sale_order_model = self.env["sale.order"].with_user(self.sale_user)
sale_order_model = self.env["sale.order"].sudo(self.sale_user)
sale_order = sale_order_model.browse(self.sale_order.id)
self.assertEqual(sale_order, self.sale_order)
with self.assertRaises(AccessError):
self.sale_order.with_user(self.sale_user).unlink()
self.sale_order.sudo(self.sale_user).unlink()
sale_order_form = Form(sale_order_model)
sale_order_form.partner_id = self.partner
sale_order_form.save()

def test_user_crm_sale(self):
model = self.model_ir_ui_menu.with_user(self.crm_sale_user)
model = self.model_ir_ui_menu.sudo(self.crm_sale_user)
items = model._visible_menu_ids()
self.assertTrue(self.crm_menu.id in items)
self.assertTrue(self.sale_menu.id in items)
# Crm lead checks
crm_lead_model = self.env["crm.lead"].with_user(self.crm_sale_user)
crm_lead_model = self.env["crm.lead"].sudo(self.crm_sale_user)
crm_lead = crm_lead_model.browse(self.crm_lead.id)
self.assertEqual(crm_lead, self.crm_lead)
with self.assertRaises(AccessError):
self.crm_lead.with_user(self.crm_sale_user).unlink()
self.crm_lead.sudo(self.crm_sale_user).unlink()
crm_lead_form = Form(crm_lead_model)
crm_lead_form.name = "Lead"
crm_lead_form.save()
# Sale order checks
sale_order_model = self.env["sale.order"].with_user(self.crm_sale_user)
sale_order_model = self.env["sale.order"].sudo(self.crm_sale_user)
sale_order = sale_order_model.browse(self.sale_order.id)
self.assertEqual(sale_order, self.sale_order)
with self.assertRaises(AccessError):
self.sale_order.with_user(self.crm_sale_user).unlink()
self.sale_order.sudo(self.crm_sale_user).unlink()
sale_order_form = Form(sale_order_model)
sale_order_form.partner_id = self.partner
sale_order_form.save()

0 comments on commit 94e9bd5

Please sign in to comment.