Add test for depends

This commit is contained in:
Cédric Krier committed 2011-08-04 16:57:31 +02:00
1 parent 17be90434c
commit 99b3466dfb
6 files changed
+51 -33

No files matched your search

+13 -11
View File
@@ -8,6 +8,7 @@ from trytond.pool import Pool
STATES = {
'readonly': Not(Bool(Eval('active'))),
}
DEPENDS = ['active']
class Address(ModelSQL, ModelView):
@@ -15,21 +16,22 @@ class Address(ModelSQL, ModelView):
_name = 'party.address'
_description = __doc__
party = fields.Many2One('party.party', 'Party', required=True,
ondelete='CASCADE', select=1, states={
'readonly': If(Not(Bool(Eval('active'))),
True, Greater(Eval('active_id', 0), 0)),
})
name = fields.Char('Name', states=STATES)
street = fields.Char('Street', states=STATES)
streetbis = fields.Char('Street (bis)', states=STATES)
ondelete='CASCADE', select=1, states={
'readonly': If(Not(Bool(Eval('active'))),
True, Greater(Eval('id', 0), 0)),
},
depends=['active', 'id'])
name = fields.Char('Name', states=STATES, depends=DEPENDS)
street = fields.Char('Street', states=STATES, depends=DEPENDS)
streetbis = fields.Char('Street (bis)', states=STATES, depends=DEPENDS)
zip = fields.Char('Zip', change_default=True,
states=STATES)
city = fields.Char('City', states=STATES)
states=STATES, depends=DEPENDS)
city = fields.Char('City', states=STATES, depends=DEPENDS)
country = fields.Many2One('country.country', 'Country',
on_change=['country', 'subdivision'], states=STATES)
on_change=['country', 'subdivision'], states=STATES, depends=DEPENDS)
subdivision = fields.Many2One("country.subdivision",
'Subdivision', domain=[('country', '=', Eval('country'))],
states=STATES)
states=STATES, depends=['active', 'country'])
active = fields.Boolean('Active')
sequence = fields.Integer("Sequence")
full_address = fields.Function(fields.Text('Full Address'),
+5 -3
View File
@@ -6,6 +6,7 @@ from trytond.pyson import Not, Bool, Eval
STATES = {
'readonly': Not(Bool(Eval('active'))),
}
DEPENDS = ['active']
SEPARATOR = ' / '
@@ -14,11 +15,12 @@ class Category(ModelSQL, ModelView):
"Category"
_name = "party.category"
_description = __doc__
name = fields.Char('Name', required=True, states=STATES, translate=True)
name = fields.Char('Name', required=True, states=STATES, translate=True,
depends=DEPENDS)
parent = fields.Many2One('party.category', 'Parent',
select=1, states=STATES)
select=1, states=STATES, depends=DEPENDS)
childs = fields.One2Many('party.category', 'parent',
'Children', states=STATES)
'Children', states=STATES, depends=DEPENDS)
active = fields.Boolean('Active')
def __init__(self):
+6 -5
View File
@@ -1,7 +1,7 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, ModelSingleton, fields
from trytond.pyson import Eval
from trytond.pyson import Eval, Get
class Configuration(ModelSingleton, ModelSQL, ModelView):
@@ -10,10 +10,11 @@ class Configuration(ModelSingleton, ModelSQL, ModelView):
_description = __doc__
party_sequence = fields.Property(fields.Many2One('ir.sequence',
'Party Sequence', domain=[
('company', 'in', [Eval('company'), False]),
('code', '=', 'party.party'),
], required=True))
'Party Sequence', domain=[
('company', 'in',
[Get(Eval('context', {}), 'company'), False]),
('code', '=', 'party.party'),
], required=True))
party_lang = fields.Property(fields.Many2One("ir.lang", 'Party Language',
help=('The value set on this field will preset the language on new '
'parties')))
+6 -4
View File
@@ -6,6 +6,7 @@ from trytond.pyson import Not, Bool, Eval, Equal, In
STATES = {
'readonly': Not(Bool(Eval('active'))),
}
DEPENDS = ['active']
_TYPES = [
('phone', 'Phone'),
@@ -28,11 +29,12 @@ class ContactMechanism(ModelSQL, ModelView):
_rec_name = 'value'
type = fields.Selection(_TYPES, 'Type', required=True, states=STATES,
sort=False)
value = fields.Char('Value', select=1, states=STATES, on_change=['value'])
comment = fields.Text('Comment', states=STATES)
sort=False, depends=DEPENDS)
value = fields.Char('Value', select=1, states=STATES, on_change=['value'],
depends=DEPENDS)
comment = fields.Text('Comment', states=STATES, depends=DEPENDS)
party = fields.Many2One('party.party', 'Party', required=True,
ondelete='CASCADE', states=STATES, select=1)
ondelete='CASCADE', states=STATES, select=1, depends=DEPENDS)
active = fields.Boolean('Active', select=1)
sequence = fields.Integer('Sequence')
email = fields.Function(fields.Char('E-Mail', states={
+13 -9
View File
@@ -21,6 +21,7 @@ except ImportError:
STATES = {
'readonly': Not(Bool(Eval('active'))),
}
DEPENDS = ['active']
class Party(ModelSQL, ModelView):
@@ -29,29 +30,32 @@ class Party(ModelSQL, ModelView):
_name = "party.party"
name = fields.Char('Name', required=True, select=1,
states=STATES)
states=STATES, depends=DEPENDS)
code = fields.Char('Code', required=True, select=1,
readonly=True, order_field="%(table)s.code_length %(order)s, " \
"%(table)s.code %(order)s")
code_length = fields.Integer('Code Length', select=1, readonly=True)
lang = fields.Many2One("ir.lang", 'Language', states=STATES)
lang = fields.Many2One("ir.lang", 'Language', states=STATES,
depends=DEPENDS)
vat_number = fields.Char('VAT Number', help="Value Added Tax number",
states={
'readonly': Not(Bool(Eval('active'))),
'required': Bool(Eval('vat_country')),
})
states={
'readonly': Not(Bool(Eval('active'))),
'required': Bool(Eval('vat_country')),
},
depends=['active', 'vat_country'])
vat_country = fields.Selection(VAT_COUNTRIES, 'VAT Country', states=STATES,
depends=DEPENDS,
help="Setting VAT country will enable validation of the VAT number.",
translate=False)
vat_code = fields.Function(fields.Char('VAT Code',
on_change_with=['vat_number', 'vat_country']), 'get_vat_code',
searcher='search_vat_code')
addresses = fields.One2Many('party.address', 'party',
'Addresses', states=STATES)
'Addresses', states=STATES, depends=DEPENDS)
contact_mechanisms = fields.One2Many('party.contact_mechanism', 'party',
'Contact Mechanisms', states=STATES)
'Contact Mechanisms', states=STATES, depends=DEPENDS)
categories = fields.Many2Many('party.party-party.category',
'party', 'category', 'Categories', states=STATES)
'party', 'category', 'Categories', states=STATES, depends=DEPENDS)
active = fields.Boolean('Active', select=1)
full_name = fields.Function(fields.Char('Full Name'), 'get_full_name')
phone = fields.Function(fields.Char('Phone'), 'get_mechanism')
+8 -1
View File
@@ -9,7 +9,8 @@ if os.path.isdir(DIR):
import unittest
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
@@ -30,6 +31,12 @@ class PartyTestCase(unittest.TestCase):
'''
test_view('party')
def test0006depends(self):
'''
Test depends.
'''
test_depends()
def test0010category(self):
'''
Create category.