Add test for depends

This commit is contained in:
Cédric Krier committed 2011-08-04 16:57:33 +02:00
1 parent 4d8a826487
commit 1595175929
3 files changed
+34 -24

No files matched your search

+15 -13
View File
@@ -8,6 +8,7 @@ from trytond.pool import Pool
STATES = {
'readonly': Not(Bool(Eval('active'))),
}
DEPENDS = ['active']
class Template(ModelSQL, ModelView):
@@ -16,31 +17,32 @@ class Template(ModelSQL, ModelView):
_description = __doc__
name = fields.Char('Name', size=None, required=True, translate=True,
select=1, states=STATES)
select=1, states=STATES, depends=DEPENDS)
type = fields.Selection([
('stockable', 'Stockable'),
('consumable', 'Consumable'),
('service', 'Service')
], 'Type', required=True, states=STATES)
('stockable', 'Stockable'),
('consumable', 'Consumable'),
('service', 'Service')
], 'Type', required=True, states=STATES, depends=DEPENDS)
category = fields.Many2One('product.category', 'Category', required=True,
states=STATES)
states=STATES, depends=DEPENDS)
list_price = fields.Property(fields.Numeric('List Price', states=STATES,
digits=(16, 4)))
digits=(16, 4), depends=DEPENDS))
list_price_uom = fields.Function(fields.Numeric('List Price',
digits=(16, 4)), 'get_price_uom')
cost_price = fields.Property(fields.Numeric('Cost Price',
states=STATES, digits=(16, 4)))
states=STATES, digits=(16, 4), depends=DEPENDS))
cost_price_uom = fields.Function(fields.Numeric('Cost Price',
digits=(16, 4)), 'get_price_uom')
cost_price_method = fields.Property(fields.Selection([
("fixed", "Fixed"),
("average", "Average")
], 'Cost Method', required=True, states=STATES))
("fixed", "Fixed"),
("average", "Average")
], 'Cost Method', required=True, states=STATES,
depends=DEPENDS))
default_uom = fields.Many2One('product.uom', 'Default UOM', required=True,
states=STATES)
states=STATES, depends=DEPENDS)
active = fields.Boolean('Active', select=1)
products = fields.One2Many('product.product', 'template', 'Products',
states=STATES)
states=STATES, depends=DEPENDS)
def default_active(self):
return True
+8 -1
View File
@@ -11,7 +11,8 @@ if os.path.isdir(DIR):
import unittest
from decimal import Decimal
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, test_view
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, test_view,\
test_depends
from trytond.transaction import Transaction
class ProductTestCase(unittest.TestCase):
@@ -30,6 +31,12 @@ class ProductTestCase(unittest.TestCase):
'''
test_view('product')
def test0006depends(self):
'''
Test depends.
'''
test_depends()
def test0010uom_non_zero_rate_factor(self):
'''
Test uom non_zero_rate_factor constraint.
+11 -10
View File
@@ -10,6 +10,7 @@ from trytond.pool import Pool
STATES = {
'readonly': Not(Bool(Eval('active'))),
}
DEPENDS = ['active']
class UomCategory(ModelSQL, ModelView):
'Product uom category'
@@ -30,21 +31,21 @@ class Uom(ModelSQL, ModelView):
_name = 'product.uom'
_description = __doc__
name = fields.Char('Name', size=None, required=True, states=STATES,
translate=True)
translate=True, depends=DEPENDS)
symbol = fields.Char('Symbol', size=10, required=True, states=STATES,
translate=True)
translate=True, depends=DEPENDS)
category = fields.Many2One('product.uom.category', 'UOM Category',
required=True, ondelete='RESTRICT', states=STATES)
required=True, ondelete='RESTRICT', states=STATES, depends=DEPENDS)
rate = fields.Float('Rate', digits=(12, 12), required=True,
on_change=['rate'], states=STATES,
help='The coefficient for the formula:\n' \
'1 (base unit) = coef (this unit)')
on_change=['rate'], states=STATES, depends=DEPENDS,
help='The coefficient for the formula:\n' \
'1 (base unit) = coef (this unit)')
factor = fields.Float('Factor', digits=(12, 12), states=STATES,
on_change=['factor'], required=True,
help='The coefficient for the formula:\n' \
'coef (base unit) = 1 (this unit)')
on_change=['factor'], required=True, depends=DEPENDS,
help='The coefficient for the formula:\n' \
'coef (base unit) = 1 (this unit)')
rounding = fields.Float('Rounding Precision', digits=(12, 12),
required=True, states=STATES)
required=True, states=STATES, depends=DEPENDS)
digits = fields.Integer('Display Digits')
active = fields.Boolean('Active')