mirror of
https://github.com/bringout/ventor.git
synced 2026-04-18 22:32:03 +02:00
Initial commit: Ventor Odoo packages (4 packages)
This commit is contained in:
commit
1f20ad87e6
190 changed files with 10375 additions and 0 deletions
|
|
@ -0,0 +1,6 @@
|
|||
# Copyright 2020 VentorTech OU
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0).
|
||||
|
||||
from . import test_check_default_location
|
||||
from . import test_checking_logotype
|
||||
from . import test_set_active_view
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# Copyright 2020 VentorTech OU
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestCheckDefaultLocation(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestCheckDefaultLocation, self).setUp()
|
||||
self.location = self.env['stock.location'].create({
|
||||
'name': 'test_location'
|
||||
})
|
||||
self.user = self.env['res.users'].create({
|
||||
'name': 'test_user',
|
||||
'login': 'test_user',
|
||||
'email': 'test.user@email.com'
|
||||
})
|
||||
self.ventor_worker = self.env.ref('ventor_base.ventor_role_wh_worker')
|
||||
self.ventor_worker.write({'users': [(4, self.user.id)]})
|
||||
self.inventory_manager = self.env.ref('stock.group_stock_manager')
|
||||
self.inventory_manager.write({'users': [(4, self.user.id)]})
|
||||
self.administration_settings = self.env.ref('base.group_system')
|
||||
self.administration_settings.write({'users': [(4, self.user.id)]})
|
||||
self.company = self.env['res.company'].create({
|
||||
'name': 'test_company',
|
||||
})
|
||||
self.product = self.env['product.template'].create({
|
||||
'name': 'new_product'
|
||||
})
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
# Copyright 2020 VentorTech OU
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.modules.module import get_resource_path
|
||||
import base64
|
||||
|
||||
|
||||
class TestCheckingLogotype(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestCheckingLogotype, self).setUp()
|
||||
self.user = self.env['res.users'].create({
|
||||
'name': 'admin',
|
||||
'login': 'login@email.com'
|
||||
})
|
||||
self.ventor_admin = self.env.ref('ventor_base.ventor_role_admin')
|
||||
self.ventor_admin.write({'users': [(4, self.user.id, 0)]})
|
||||
self.inventory_manager = self.env.ref('stock.group_stock_manager')
|
||||
self.inventory_manager.write({'users': [(4, self.user.id, 0)]})
|
||||
self.administration_settings = self.env.ref('base.group_system')
|
||||
self.administration_settings.write({'users': [(4, self.user.id, 0)]})
|
||||
self.company = self.env['res.company'].search([], limit=1)
|
||||
|
||||
def test_upload_invalid_logo(self):
|
||||
img_path = get_resource_path('ventor_base', 'static', 'test_logo', '400_400.png')
|
||||
img_content = base64.b64encode(open(img_path, "rb").read())
|
||||
with self.assertRaises(UserError):
|
||||
self.company._validate_logotype({'logotype_file': img_content})
|
||||
|
||||
def test_upload_valid_logo(self):
|
||||
img_path = get_resource_path('ventor_base', 'static', 'test_logo', '600_600.png')
|
||||
img_content = base64.b64encode(open(img_path, "rb").read())
|
||||
self.assertEqual(self.company._validate_logotype({'logotype_file': img_content}), True)
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
# Copyright 2020 VentorTech OU
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import Warning
|
||||
import base64
|
||||
|
||||
|
||||
class TestSetActiveView(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestSetActiveView, self).setUp()
|
||||
self.view_with_barcode = self.env.ref('ventor_base.view_location_form_inherit_additional_barcode')
|
||||
self.ConfigObj = self.env['res.config.settings']
|
||||
|
||||
def test_get_values(self):
|
||||
# A default value, adjusted in a view.xml
|
||||
config = self.ConfigObj.get_values()
|
||||
self.assertEqual(
|
||||
config['add_barcode_on_view'],
|
||||
False
|
||||
)
|
||||
# We set True directly to the ir.ui.view
|
||||
self.view_with_barcode.active = True
|
||||
config = self.ConfigObj.get_values()
|
||||
self.assertEqual(
|
||||
config['add_barcode_on_view'],
|
||||
True
|
||||
)
|
||||
|
||||
def test_set_values(self):
|
||||
for value in (True, False):
|
||||
config = self.ConfigObj.create(
|
||||
{'add_barcode_on_view': value}
|
||||
)
|
||||
config.execute()
|
||||
self.assertEqual(
|
||||
self.view_with_barcode.active,
|
||||
value
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue