Initial commit
This commit is contained in:
1
garazd_product_label_pro/tests/__init__.py
Normal file
1
garazd_product_label_pro/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_access_rights
|
||||
45
garazd_product_label_pro/tests/common.py
Normal file
45
garazd_product_label_pro/tests/common.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# Copyright © 2023 Garazd Creation (https://garazd.biz)
|
||||
# @author: Yurii Razumovskyi (support@garazd.biz)
|
||||
# @author: Iryna Razumovska (support@garazd.biz)
|
||||
# License OPL-1 (https://www.odoo.com/documentation/16.0/legal/licenses.html).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.tests import tagged
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestProductLabel(TransactionCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
|
||||
cls.label_template_50x25 = cls.env['print.product.label.template'].create({
|
||||
'name': 'Test Label',
|
||||
'paperformat_id': cls.env.ref('garazd_product_label_pro.paperformat_label_custom_50x25').id,
|
||||
'orientation': 'Portrait',
|
||||
'cols': 1,
|
||||
'rows': 1,
|
||||
'width': 50,
|
||||
'height': 25,
|
||||
})
|
||||
cls.product_a = cls.env['product.product'].create({
|
||||
'name': 'Test Product A',
|
||||
'type': 'consu',
|
||||
'list_price': 20.0,
|
||||
'barcode': '1234567890',
|
||||
})
|
||||
cls.product_b = cls.env['product.product'].create({
|
||||
'name': 'Test Product B',
|
||||
'type': 'consu',
|
||||
'list_price': 199.99,
|
||||
'barcode': '9999999999999',
|
||||
})
|
||||
|
||||
def setUp(self):
|
||||
super(TestProductLabel, self).setUp()
|
||||
|
||||
self.print_wizard = self.env['print.product.label'].with_context(**{
|
||||
'active_model': 'product.product',
|
||||
'default_product_product_ids': [self.product_a.id, self.product_b.id],
|
||||
}).create({})
|
||||
27
garazd_product_label_pro/tests/test_access_rights.py
Normal file
27
garazd_product_label_pro/tests/test_access_rights.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright © 2023 Garazd Creation (https://garazd.biz)
|
||||
# @author: Yurii Razumovskyi (support@garazd.biz)
|
||||
# @author: Iryna Razumovska (support@garazd.biz)
|
||||
# License OPL-1 (https://www.odoo.com/documentation/16.0/legal/licenses.html).
|
||||
|
||||
from odoo.tests import tagged
|
||||
|
||||
from odoo.addons.base.tests.common import BaseUsersCommon
|
||||
from .common import TestProductLabel
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestAccessRights(BaseUsersCommon, TestProductLabel):
|
||||
|
||||
def test_access_internal_user(self):
|
||||
""" Test internal user's access rights """
|
||||
PrintWizard = self.env['print.product.label'].with_user(self.user_internal)
|
||||
wizard_as_internal_user = PrintWizard.browse(self.print_wizard.id)
|
||||
|
||||
# Internal user can use label templates
|
||||
wizard_as_internal_user.read()
|
||||
|
||||
# Internal user can change label templates
|
||||
wizard_as_internal_user.write({'template_id': self.label_template_50x25.id})
|
||||
|
||||
# Internal user can preview label templates
|
||||
wizard_as_internal_user.action_print()
|
||||
Reference in New Issue
Block a user