Skip to content

Commit

Permalink
[MIG] sales_team_security: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Yadier-Tecnativa committed Jul 13, 2023
1 parent c79c59f commit 43a71c0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion sales_team_security/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Sales documents permissions by channels (teams)",
"summary": "New group for seeing only sales channel's documents",
"version": "15.0.1.0.2",
"version": "16.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/sale-workflow",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
4 changes: 2 additions & 2 deletions sales_team_security/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ msgstr "El usuario interno a cargo de este contacto."
msgid ""
"The user will have an access to the documents of the sales teams he/she "
"belongs to."
msgstr ""
msgstr "El usuario tendrá acceso a los documentos de los equipos comerciales a los que pertenece."

#. module: sales_team_security
#: model:res.groups,name:sales_team_security.group_sale_team_manager
msgid "User: Team Documents Only"
msgstr ""
msgstr "Usuario: Solo documentos del equipo"
11 changes: 2 additions & 9 deletions sales_team_security/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,12 @@ class ResPartner(models.Model):
team_id = fields.Many2one(index=True)

@api.model
def fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
def get_view(self, view_id=None, view_type="form", **options):
"""
Patch view to inject the default value for the team_id and user_id.
"""
# FIXME: Use base_view_inheritance_extension when available
res = super().fields_view_get(
view_id=view_id,
view_type=view_type,
toolbar=toolbar,
submenu=submenu,
)
res = super().get_view(view_id, view_type, **options)
if view_type == "form":
eview = etree.fromstring(res["arch"])
xml_fields = eview.xpath("//field[@name='child_ids']")
Expand Down
5 changes: 5 additions & 0 deletions sales_team_security/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
* Pedro M. Baeza
* Víctor Martínez
* César A. Sánchez
* Yadier Quesada

* `Guadaltech <https://www.guadaltech.es>`__:

* Ramón Bajona

* Iván Todorovich <[email protected]>

* `Pesol <https://www.pesol.es>`__:

* Jonathan Oscategui Taza <[email protected]>
2 changes: 1 addition & 1 deletion sales_team_security/security/sales_team_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name="name">User: Team Documents Only</field>
<field
name="comment"
>The user will have an access to the documents of the sales teams he/she belongs to.</field>
>The user will have access to the documents of the sales teams he/she belongs to.</field>
<field name="category_id" ref="base.module_category_sales_sales" />
<field name="implied_ids" eval="[(4, ref('sales_team.group_sale_salesman'))]" />
</record>
Expand Down
7 changes: 5 additions & 2 deletions sales_team_security/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo.tests import common
from odoo.tests import TransactionCase


class TestCommon(common.TransactionCase):
class TestCommon(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand All @@ -27,6 +27,9 @@ def setUpClass(cls):
cls.partner = cls.env["res.partner"].create(
{"name": "Test partner", "team_id": cls.team.id}
)
cls.partner2 = cls.env["res.partner"].create(
{"name": "Test partner 2", "user_id": cls.user.id}
)
cls.partner_child_1 = cls.env["res.partner"].create(
{"name": "Child 1", "parent_id": cls.partner.id}
)
Expand Down
12 changes: 9 additions & 3 deletions sales_team_security/tests/test_sales_team_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ def test_onchange_parent_id(self):
contact._onchange_parent_id_sales_team_security()
self.assertEqual(contact.team_id, self.team)

contact2 = self.env["res.partner"].create(
{"name": "Test contact", "parent_id": self.partner2.id}
)
contact2._onchange_parent_id_sales_team_security()
self.assertEqual(contact2.user_id, self.user)

def test_onchange_user_id(self):
contact = self.env["res.partner"].create(
{
Expand All @@ -38,7 +44,7 @@ def test_assign_contacts_team(self):
{"name": "Test contact", "parent_id": self.partner.id, "team_id": False}
)
post_init_hook(self.env.cr, self.env.registry)
contact.refresh()
contact.env.invalidate_all()
self.assertEqual(contact.team_id, self.partner.team_id)

def test_change_user_id_partner(self):
Expand All @@ -64,8 +70,8 @@ def test_change_user_id_partner_child_1(self):
self.assertNotIn(self.user_partner, self.partner_child_2.message_partner_ids)
self.assertIn(self.user2_partner, self.partner_child_2.message_partner_ids)

def test_partner_fields_view_get(self):
res = self.env["res.partner"].fields_view_get(
def test_partner_get_view(self):
res = self.env["res.partner"].get_view(
view_id=self.ref("base.view_partner_form")
)
eview = etree.fromstring(res["arch"])
Expand Down

0 comments on commit 43a71c0

Please sign in to comment.