Add test for depends
This commit is contained in:
1 parent
0240f80293
commit
9604ebeda6
2 files changed
+105
-84
No files matched your search
+98
-83
@@ -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, fields
|
||||
from trytond.pyson import Not, Eval, Bool, Or, In, And
|
||||
from trytond.pyson import Not, Eval, Bool, Or, In, And, Get
|
||||
|
||||
|
||||
class Category(ModelSQL, ModelView):
|
||||
@@ -10,45 +10,45 @@ class Category(ModelSQL, ModelView):
|
||||
account_stock = fields.Property(fields.Many2One('account.account',
|
||||
'Account Stock', domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('company')),
|
||||
('company', '=', Get(Eval('context', {}), 'company')),
|
||||
], states={
|
||||
'invisible': Not(Bool(Eval('company'))),
|
||||
'invisible': Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
}))
|
||||
account_stock_supplier = fields.Property(fields.Many2One('account.account',
|
||||
'Account Stock Supplier', domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('company')),
|
||||
('company', '=', Get(Eval('context', {}), 'company')),
|
||||
], states={
|
||||
'invisible': Not(Bool(Eval('company'))),
|
||||
'invisible': Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
}))
|
||||
account_stock_customer = fields.Property(fields.Many2One('account.account',
|
||||
'Account Stock Customer', domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('company')),
|
||||
('company', '=', Get(Eval('context', {}), 'company')),
|
||||
], states={
|
||||
'invisible': Not(Bool(Eval('company'))),
|
||||
'invisible': Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
}))
|
||||
account_stock_lost_found = fields.Property(fields.Many2One(
|
||||
'account.account', 'Account Stock Lost and Found', domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('company')),
|
||||
('company', '=', Get(Eval('context', {}), 'company')),
|
||||
], states={
|
||||
'invisible': Not(Bool(Eval('company'))),
|
||||
'invisible': Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
}))
|
||||
account_journal_stock_supplier = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Journal Stock Supplier',
|
||||
states={
|
||||
'invisible': Not(Bool(Eval('company'))),
|
||||
'invisible': Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
}))
|
||||
account_journal_stock_customer = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Journal Stock Customer',
|
||||
states={
|
||||
'invisible': Not(Bool(Eval('company'))),
|
||||
'invisible': Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
}))
|
||||
account_journal_stock_lost_found = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Journal Stock Lost and Found',
|
||||
states={
|
||||
'invisible': Not(Bool(Eval('company'))),
|
||||
'invisible': Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
}))
|
||||
|
||||
Category()
|
||||
@@ -58,83 +58,98 @@ class Template(ModelSQL, ModelView):
|
||||
_name = 'product.template'
|
||||
|
||||
account_stock = fields.Property(fields.Many2One('account.account',
|
||||
'Account Stock', domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('company')),
|
||||
], states={
|
||||
'invisible': Or(Not(Bool(Eval('company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Eval('company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This account will be used instead of the one defined '
|
||||
'on the category.', depends=['account_category']))
|
||||
'Account Stock',
|
||||
domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Get(Eval('context', {}), 'company')),
|
||||
],
|
||||
states={
|
||||
'invisible': Or(Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Get(Eval('context', {}), 'company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This account will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_stock_supplier = fields.Property(fields.Many2One('account.account',
|
||||
'Account Stock Supplier', domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('company')),
|
||||
], states={
|
||||
'invisible': Or(Not(Bool(Eval('company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Eval('company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This account will be used instead of the one defined '
|
||||
'on the category.', depends=['account_category']))
|
||||
'Account Stock Supplier',
|
||||
domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Get(Eval('context', {}), 'company')),
|
||||
],
|
||||
states={
|
||||
'invisible': Or(Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Get(Eval('context', {}), 'company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This account will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_stock_customer = fields.Property(fields.Many2One('account.account',
|
||||
'Account Stock Customer', domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('company')),
|
||||
], states={
|
||||
'invisible': Or(Not(Bool(Eval('company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Eval('company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This account will be used instead of the one defined '
|
||||
'on the category.', depends=['account_category']))
|
||||
'Account Stock Customer',
|
||||
domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Get(Eval('context', {}), 'company')),
|
||||
],
|
||||
states={
|
||||
'invisible': Or(Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Get(Eval('context', {}), 'company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This account will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_stock_lost_found = fields.Property(fields.Many2One(
|
||||
'account.account', 'Account Stock Lost and Found', domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Eval('company')),
|
||||
], states={
|
||||
'invisible': Or(Not(Bool(Eval('company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Eval('company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This account will be used instead of the one defined '
|
||||
'on the category.', depends=['account_category']))
|
||||
'account.account', 'Account Stock Lost and Found',
|
||||
domain=[
|
||||
('kind', '!=', 'view'),
|
||||
('company', '=', Get(Eval('context', {}), 'company')),
|
||||
],
|
||||
states={
|
||||
'invisible': Or(Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Get(Eval('context', {}), 'company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This account will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_journal_stock_supplier = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Account Journal Stock Supplier',
|
||||
states={
|
||||
'invisible': Or(Not(Bool(Eval('company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Eval('company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This journal will be used instead of the one defined '
|
||||
'on the category.', depends=['account_category']))
|
||||
'account.journal', 'Account Journal Stock Supplier',
|
||||
states={
|
||||
'invisible': Or(Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Get(Eval('context', {}), 'company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This journal will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_journal_stock_customer = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Account Journal Stock Customer',
|
||||
states={
|
||||
'invisible': Or(Not(Bool(Eval('company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Eval('company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This journal will be used instead of the one defined '
|
||||
'on the category.', depends=['account_category']))
|
||||
'account.journal', 'Account Journal Stock Customer',
|
||||
states={
|
||||
'invisible': Or(Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Get(Eval('context', {}), 'company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This journal will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_journal_stock_lost_found = fields.Property(fields.Many2One(
|
||||
'account.journal', 'Account Journal Stock Lost and Found',
|
||||
states={
|
||||
'invisible': Or(Not(Bool(Eval('company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Eval('company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This journal will be used instead of the one defined '
|
||||
'on the category.', depends=['account_category']))
|
||||
'account.journal', 'Account Journal Stock Lost and Found',
|
||||
states={
|
||||
'invisible': Or(Not(Bool(Get(Eval('context', {}), 'company'))),
|
||||
Bool(Eval('account_category'))),
|
||||
'required': And(In(Eval('type'), ['stockable', 'consumable']),
|
||||
Bool(Get(Eval('context', {}), 'company')),
|
||||
Not(Bool(Eval('account_category')))),
|
||||
}, help='This journal will be used instead of the one defined '
|
||||
'on the category.',
|
||||
depends=['account_category', 'type']))
|
||||
account_stock_used = fields.Function(fields.Many2One('account.account',
|
||||
'Account Stock Used'), 'get_account')
|
||||
account_stock_supplier_used = fields.Function(fields.Many2One(
|
||||
|
||||
@@ -11,7 +11,7 @@ if os.path.isdir(DIR):
|
||||
import unittest
|
||||
import doctest
|
||||
import trytond.tests.test_tryton
|
||||
from trytond.tests.test_tryton import test_view
|
||||
from trytond.tests.test_tryton import test_view, test_depends
|
||||
from trytond.backend.sqlite.database import Database as SQLiteDatabase
|
||||
|
||||
|
||||
@@ -29,6 +29,12 @@ class AccountStockContinentalTestCase(unittest.TestCase):
|
||||
'''
|
||||
test_view('account_stock_continental')
|
||||
|
||||
def test0006depends(self):
|
||||
'''
|
||||
Test depends.
|
||||
'''
|
||||
test_depends()
|
||||
|
||||
def doctest_dropdb(test):
|
||||
'''
|
||||
Remove sqlite memory database
|
||||
|
||||
Reference in new issue
Block a user