Skip to content

Commit

Permalink
[MIG] product_cost_security: Migration to 16.0
Browse files Browse the repository at this point in the history
[MIG] product_cost_security: Migration to 16.0

[MIG] product_cost_security: Migration to 16.0

[MIG] product_cost_security: Migration to 16.0

[MIG] product_cost_security: Migration to 16.0

Updated test scripts
  • Loading branch information
bvanjeelharia committed Apr 17, 2023
1 parent 6993201 commit e79b382
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 11 deletions.
14 changes: 7 additions & 7 deletions product_cost_security/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ Product Cost Security
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/15.0/product_cost_security
:target: https://github.com/OCA/product-attribute/tree/16.0/product_cost_security
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-15-0/product-attribute-15-0-product_cost_security
:target: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_cost_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/135/15.0
:target: https://runbot.odoo-community.org/runbot/135/16.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
|badge1| |badge2| |badge3| |badge4| |badge5|

It adds two security groups, one for viewing the product cost price, and the other for
editing it.
Expand Down Expand Up @@ -55,7 +55,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/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://github.com/OCA/product-attribute/issues/new?body=module:%20product_cost_security%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_cost_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 Down Expand Up @@ -97,8 +97,8 @@ promote its widespread use.

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sergio-teruel|
|maintainer-sergio-teruel|

This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/15.0/product_cost_security>`_ project on GitHub.
This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/16.0/product_cost_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 product_cost_security/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Product Cost Security",
"summary": "Product cost security restriction view",
"version": "15.0.2.0.0",
"version": "16.0.1.0.0",
"development_status": "Production/Stable",
"maintainers": ["sergio-teruel"],
"category": "Product",
Expand Down
3 changes: 3 additions & 0 deletions product_cost_security/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@

* Watthanun Khorchai <watthanun_t@hotmail.com>
* Carlos Lopez <celm1990@gmail.com>
* `Onestein <https://www.onestein.eu>`_:

* Anjeel Haria
6 changes: 3 additions & 3 deletions product_cost_security/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Product Cost Security</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://github.com/OCA/product-attribute/tree/15.0/product_cost_security"><img alt="OCA/product-attribute" src="https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/product-attribute-15-0/product-attribute-15-0-product_cost_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/135/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://github.com/OCA/product-attribute/tree/16.0/product_cost_security"><img alt="OCA/product-attribute" src="https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_cost_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/135/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>It adds two security groups, one for viewing the product cost price, and the other for
editing it.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -405,7 +405,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/product-attribute/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://github.com/OCA/product-attribute/issues/new?body=module:%20product_cost_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://github.com/OCA/product-attribute/issues/new?body=module:%20product_cost_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 Down Expand Up @@ -437,7 +437,7 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/sergio-teruel"><img alt="sergio-teruel" src="https://github.com/sergio-teruel.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-attribute/tree/15.0/product_cost_security">OCA/product-attribute</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-attribute/tree/16.0/product_cost_security">OCA/product-attribute</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 product_cost_security/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import test_product_cost_security
78 changes: 78 additions & 0 deletions product_cost_security/tests/test_product_cost_security.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright 2023 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests.common import Form, TransactionCase


class TestProductCostSecurity(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.product_edit_cost_group_id = cls.env.ref(
"product_cost_security.group_product_edit_cost"
).id
cls.product_cost_group_id = cls.env.ref(
"product_cost_security.group_product_cost"
).id
cls.product_template_model = cls.env["product.template"].with_context(
tracking_disable=True
)
cls.env.user.write(
{
"groups_id": [
(6, 0, cls.env.ref("base.group_system").ids),
],
}
)

def test_without_access_to_product_costs_group(self):
sheet_form = Form(self.product_template_model.with_user(self.env.user))
sheet_form.name = "Test Product"
sheet_form.save()
with self.assertRaises(AssertionError):
# It would raise an AssertionError as the field would not be found in the view
# as the user does not have the group- Access to product costs
standard_price = sheet_form.standard_price
self.assertEqual(standard_price, 0.0)

def test_with_access_to_product_costs_group(self):
self.env.user.groups_id = [
(
6,
0,
[self.product_cost_group_id],
)
]
sheet_form = Form(self.product_template_model.with_user(self.env.user))
sheet_form.name = "Test Product"
sheet_form.save()
standard_price = (
sheet_form.standard_price
) # It would not raise any error now as the user
# has the required group to view the costs
self.assertEqual(standard_price, 0.0)

def test_without_access_to_modify_product_costs_group(self):
sheet_form = Form(self.product_template_model.with_user(self.env.user))
sheet_form.name = "Test Product"
sheet_form.save()
with self.assertRaises(AssertionError):
# It would raise an AssertionError as the field is readonlyin the view
# as the user does not have the group- Modify product costs
sheet_form.standard_price = 5.0

def test_with_access_to_modify_product_costs_group(self):
self.env.user.groups_id = [
(
6,
0,
[self.product_edit_cost_group_id],
)
]
sheet_form = Form(self.product_template_model.with_user(self.env.user))
sheet_form.name = "Test Product"
sheet_form.save()
sheet_form.standard_price = 5.0 # It would not raise any error now as the user
# has the required group to modify the costs
self.assertEqual(sheet_form.standard_price, 5.0)

0 comments on commit e79b382

Please sign in to comment.