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
Jonathan Oscategui Taza authored and pedrobaeza committed Aug 8, 2023
1 parent 70a5b8e commit b17f10c
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 23 deletions.
14 changes: 9 additions & 5 deletions sales_team_security/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Sales documents permissions by channels (teams)
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https:/OCA/sale-workflow/tree/15.0/sales_team_security
:target: https:/OCA/sale-workflow/tree/16.0/sales_team_security
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-15-0/sale-workflow-15-0-sales_team_security
:target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sales_team_security
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/15.0
:target: https://runbot.odoo-community.org/runbot/167/16.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -88,7 +88,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https:/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https:/OCA/sale-workflow/issues/new?body=module:%20sales_team_security%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https:/OCA/sale-workflow/issues/new?body=module:%20sales_team_security%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -115,6 +115,10 @@ Contributors

* Iván Todorovich <[email protected]>

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

* Jonathan Oscategui Taza <[email protected]>

Maintainers
~~~~~~~~~~~

Expand All @@ -139,6 +143,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-pedrobaeza| |maintainer-ivantodorovich|

This module is part of the `OCA/sale-workflow <https:/OCA/sale-workflow/tree/15.0/sales_team_security>`_ project on GitHub.
This module is part of the `OCA/sale-workflow <https:/OCA/sale-workflow/tree/16.0/sales_team_security>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
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:/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
4 changes: 4 additions & 0 deletions sales_team_security/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
* Ramón Bajona

* Iván Todorovich <[email protected]>

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

* Jonathan Oscategui Taza <[email protected]>
12 changes: 8 additions & 4 deletions sales_team_security/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Sales documents permissions by channels (teams)</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Sales documents permissions by channels (teams)</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https:/OCA/sale-workflow/tree/15.0/sales_team_security"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/sale-workflow-15-0/sale-workflow-15-0-sales_team_security"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/167/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https:/OCA/sale-workflow/tree/16.0/sales_team_security"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sales_team_security"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/167/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds a new “Sale” group called “User: Team documents”, that
includes the proper permissions for showing only the information related to
that user sale team (having assigned that team/channel or no team at all,
Expand Down Expand Up @@ -438,7 +438,7 @@ <h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https:/OCA/sale-workflow/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https:/OCA/sale-workflow/issues/new?body=module:%20sales_team_security%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https:/OCA/sale-workflow/issues/new?body=module:%20sales_team_security%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -463,6 +463,10 @@ <h2><a class="toc-backref" href="#id7">Contributors</a></h2>
</ul>
</li>
<li>Iván Todorovich &lt;<a class="reference external" href="mailto:ivan.todorovich&#64;gmail.com">ivan.todorovich&#64;gmail.com</a>&gt;</li>
<li><a class="reference external" href="https://www.pesol.es">Pesol</a>:<ul>
<li>Jonathan Oscategui Taza &lt;<a class="reference external" href="mailto:info&#64;pesol.es">info&#64;pesol.es</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -474,7 +478,7 @@ <h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external" href="https:/pedrobaeza"><img alt="pedrobaeza" src="https:/pedrobaeza.png?size=40px" /></a> <a class="reference external" href="https:/ivantodorovich"><img alt="ivantodorovich" src="https:/ivantodorovich.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https:/OCA/sale-workflow/tree/15.0/sales_team_security">OCA/sale-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https:/OCA/sale-workflow/tree/16.0/sales_team_security">OCA/sale-workflow</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions sales_team_security/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def setUpClass(cls):
cls.partner_child_2 = cls.env["res.partner"].create(
{"name": "Child 2", "parent_id": cls.partner.id, "type": "invoice"}
)
cls.partner2 = cls.env["res.partner"].create(
{"name": "Test partner 2", "user_id": cls.user.id}
)
cls.user2 = cls.env["res.users"].create(
{
"login": "sales_team_security2",
Expand Down
10 changes: 8 additions & 2 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 @@ -65,7 +71,7 @@ def test_change_user_id_partner_child_1(self):
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(
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 b17f10c

Please sign in to comment.