Migrate to 4.0

This commit refs #1277
This commit is contained in:
Sergio Morillo 2016-08-19 14:11:05 +02:00
parent 31f5763638
commit ac5e2fc1cf
5 changed files with 36 additions and 33 deletions

View File

@ -1 +1,2 @@
Version 4.0.3 - 2016-08-19
* Initial release

View File

@ -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)

View File

@ -5,7 +5,6 @@
<data>
<record model="ir.ui.view" id="location_view_form">
<field name="model">stock.location</field>
<field name="type">form</field>
<field name="inherit" ref="stock.location_view_form"/>
<field name="name">location_form</field>
</record>

View File

@ -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():

View File

@ -1,5 +1,5 @@
[tryton]
version=3.8.1
version=4.0.3
depends:
ir
res