From ac5e2fc1cf000e8b75af3e1466eddd1a68c48c8d Mon Sep 17 00:00:00 2001 From: Sergio Morillo Date: Fri, 19 Aug 2016 14:11:05 +0200 Subject: [PATCH] Migrate to 4.0 This commit refs #1277 --- CHANGELOG | 1 + location.py | 2 +- location.xml | 1 - tests/test_stock_product_category_location.py | 63 ++++++++++--------- tryton.cfg | 2 +- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 909b4eb..7b0f6f4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1 +1,2 @@ +Version 4.0.3 - 2016-08-19 * Initial release diff --git a/location.py b/location.py index 9618c55..5c481a4 100644 --- a/location.py +++ b/location.py @@ -45,7 +45,7 @@ class ProductCategoryLocation(ModelSQL, ModelView): @staticmethod def _compute_sequence(table, record): - cursor = Transaction().cursor + cursor = Transaction().connection.cursor() seq_sel = table.select( Max(table.sequence).as_('max_sequence')) seq_sel.where = ProductCategoryLocation._compute_sequence_where(table, record) diff --git a/location.xml b/location.xml index a4bf162..1b474e2 100644 --- a/location.xml +++ b/location.xml @@ -5,7 +5,6 @@ stock.location - form location_form diff --git a/tests/test_stock_product_category_location.py b/tests/test_stock_product_category_location.py index c5c1983..4b8c02e 100644 --- a/tests/test_stock_product_category_location.py +++ b/tests/test_stock_product_category_location.py @@ -2,9 +2,9 @@ # copyright notices and license terms. import unittest import trytond.tests.test_tryton -from trytond.tests.test_tryton import ModuleTestCase -from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT +from trytond.tests.test_tryton import ModuleTestCase, with_transaction from trytond.transaction import Transaction +from trytond.pool import Pool from trytond.exceptions import UserError import doctest from trytond.tests.test_tryton import doctest_setup, doctest_teardown @@ -14,41 +14,44 @@ class StockProductCategoryLocationTestCase(ModuleTestCase): """Test Stock Product Category Location module""" module = 'stock_product_category_location' - def setUp(self): - super(StockProductCategoryLocationTestCase, self).setUp() - self.location = POOL.get('stock.location') - self.category = POOL.get('product.category') - self.cat_loc = POOL.get('stock.product.category.location') - + @with_transaction() def test0010_add_category_default_location(self): """Add the category default location for a warehouse""" + pool = Pool() + Location = pool.get('stock.location') + Category = pool.get('product.category') + CatLoc = pool.get('stock.product.category.location') + transaction = Transaction() - with Transaction().start(DB_NAME, USER, context=CONTEXT) as transaction: - storage, = self.location.search([('code', '=', 'STO')]) - new_cat, = self.category.create([{'name': 'CAT1'}]) - cat_loc_rec = { - 'category': new_cat.id, - 'warehouse': storage.parent.id, - 'location': storage.id - } - self.cat_loc.create([cat_loc_rec]) - transaction.cursor.commit() + storage, = Location.search([('code', '=', 'STO')]) + new_cat, = Category.create([{'name': 'CAT1'}]) + cat_loc_rec = { + 'category': new_cat.id, + 'warehouse': storage.parent.id, + 'location': storage.id + } + CatLoc.create([cat_loc_rec]) + transaction.commit() + @with_transaction() def test0020category_location_unique(self): """Check unique error""" + pool = Pool() + Location = pool.get('stock.location') + Category = pool.get('product.category') + CatLoc = pool.get('stock.product.category.location') - with Transaction().start(DB_NAME, USER, context=CONTEXT): - storage, = self.location.search([('code', '=', 'STO')]) - new_cat, = self.category.search([('name', '=', 'CAT1')]) - cat_loc_rec = { - 'category': new_cat.id, - 'warehouse': storage.parent.id, - 'location': storage.id - } - with self.assertRaises(UserError) as cm: - self.cat_loc.create([cat_loc_rec]) - self.assertEqual( - cm.exception.message, 'Category and location must be unique.') + storage, = Location.search([('code', '=', 'STO')]) + new_cat, = Category.search([('name', '=', 'CAT1')]) + cat_loc_rec = { + 'category': new_cat.id, + 'warehouse': storage.parent.id, + 'location': storage.id + } + with self.assertRaises(UserError) as cm: + CatLoc.create([cat_loc_rec]) + self.assertEqual( + cm.exception.message, 'Category and location must be unique.') def suite(): diff --git a/tryton.cfg b/tryton.cfg index a90e566..001b961 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=3.8.1 +version=4.0.3 depends: ir res