Skip to content

Commit

Permalink
[MIG] sales_team_security_crm: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lef-adhoc committed Jan 10, 2025
1 parent 3451ee1 commit 5825dd1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sales_team_security_crm/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "CRM documents permissions by teams",
"summary": "Integrates sales_team_security with crm",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Customer Relationship Management",
"website": "https://github.com/OCA/sale-workflow",
"author": "Tecnativa, Iván Todorovich, Odoo Community Association (OCA)",
Expand Down
8 changes: 3 additions & 5 deletions sales_team_security_crm/security/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<field name="model_id" ref="crm.model_crm_lead" />
<field
name="domain_force"
>['|', '|', ('user_id', '=', user.id), ('user_id', '=', False), '|', ('team_id', '=', user.sale_team_id.id),
('team_id', '=', False)]
>['|', ('user_id', 'in', [user.id, False]), ('team_id', 'in', user.crm_team_ids.ids + [False])]
</field>
<field
name="groups"
Expand All @@ -18,8 +17,7 @@
<field name="model_id" ref="crm.model_crm_activity_report" />
<field
name="domain_force"
>['|', '|', ('user_id', '=', user.id), ('user_id', '=', False), '|', ('team_id', '=', user.sale_team_id.id),
('team_id', '=', False)]
>['|', ('user_id', 'in', [user.id, False]), ('team_id', 'in', user.crm_team_ids.ids + [False])]
</field>
<field
name="groups"
Expand All @@ -29,7 +27,7 @@
<record id="sales_team_team_rule" model="ir.rule">
<field name="name">Own Sale Teams</field>
<field name="model_id" ref="sales_team.model_crm_team" />
<field name="domain_force">[('id', '=', user.sale_team_id.id)]</field>
<field name="domain_force">[('id', 'in', user.crm_team_ids.ids)]</field>
<field
name="groups"
eval="[(4, ref('sales_team_security.group_sale_team_manager'))]"
Expand Down
8 changes: 8 additions & 0 deletions sales_team_security_crm/tests/test_sales_team_security_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class TestSalesTeamSecurityCrm(TestCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env["ir.config_parameter"].set_param("sales_team.membership_multi", True)
cls.team3 = cls.env["crm.team"].create({"name": "Test channel 3"})
cls.env["crm.team.member"].create(
{"user_id": cls.user.id, "crm_team_id": cls.team3.id}
)
cls.record = cls.env["crm.lead"].create(
{
"name": "Test lead",
Expand All @@ -19,3 +24,6 @@ def setUpClass(cls):

def test_crm_lead_permissions(self):
self._check_whole_permission_set(extra_checks=False)

def test_crm_lead_permissions_multi_team(self):
self._check_permission(False, self.team3, True)

0 comments on commit 5825dd1

Please sign in to comment.