[fix] other related fields found in the statement

This commit is contained in:
Leonardo Pistone
2014-03-06 18:14:44 +01:00
parent 2c763f77eb
commit 063812d7c4
4 changed files with 105 additions and 65 deletions

View File

@@ -79,7 +79,7 @@
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'security/ir_rule.xml'], 'security/ir_rule.xml'],
'demo_xml': [], 'demo_xml': [],
'test': ['test/test_balance_check.yml'], 'test': ['test/test_profile_related_fields.yml'],
'installable': True, 'installable': True,
'images': [], 'images': [],
'auto_install': False, 'auto_install': False,

View File

@@ -166,6 +166,9 @@ class AccountBankStatement(Model):
triggered += [st.id for st in profile.bank_statement_ids] triggered += [st.id for st in profile.bank_statement_ids]
return triggered return triggered
def _us(self, cr, uid, ids, context=None):
return ids
_columns = { _columns = {
'profile_id': fields.many2one( 'profile_id': fields.many2one(
'account.statement.profile', 'account.statement.profile',
@@ -178,7 +181,11 @@ class AccountBankStatement(Model):
type='many2one', type='many2one',
relation='res.partner', relation='res.partner',
string='Financial Partner', string='Financial Partner',
store=True, store={
'account.bank.statement': (_us, ['profile_id'], 10),
'account.statement.profile': (
_get_statement_from_profile, ['partner_id'], 10),
},
readonly=True), readonly=True),
'balance_check': fields.related( 'balance_check': fields.related(
'profile_id', 'profile_id',
@@ -186,6 +193,7 @@ class AccountBankStatement(Model):
type='boolean', type='boolean',
string='Balance check', string='Balance check',
store={ store={
'account.bank.statement': (_us, ['profile_id'], 10),
'account.statement.profile': ( 'account.statement.profile': (
_get_statement_from_profile, ['balance_check'], 10), _get_statement_from_profile, ['balance_check'], 10),
}, },
@@ -197,7 +205,11 @@ class AccountBankStatement(Model):
type='many2one', type='many2one',
relation='account.journal', relation='account.journal',
string='Journal', string='Journal',
store=True, store={
'account.bank.statement': (_us, ['profile_id'], 10),
'account.statement.profile': (
_get_statement_from_profile, ['journal_id'], 10),
},
readonly=True), readonly=True),
'period_id': fields.many2one( 'period_id': fields.many2one(
'account.period', 'account.period',

View File

@@ -1,50 +0,0 @@
-
In order to test the banking framework, I first need to create a profile
-
!record {model: account.statement.profile, id: profile_test1}:
name: Bank EUR Profile
journal_id: account.bank_journal
commission_account_id: account.a_expense
company_id: base.main_company
balance_check: True
-
I create a second profile
-
!record {model: account.statement.profile, id: profile_test2}:
name: Second profile
journal_id: account.bank_journal
commission_account_id: account.a_expense
company_id: base.main_company
balance_check: True
-
Now I create a statement.
-
!record {model: account.bank.statement, id: statement_test1}:
name: Statement 1
profile_id: profile_test1
company_id: base.main_company
-
Now I check that the balance_check of the statement is enabled.
-
!assert {model: account.bank.statement, id: statement_test1, string: We should check the balance}:
- balance_check is True
-
Now I set the flag to False in the profile
-
!record {model: account.statement.profile, id: profile_test1}:
balance_check: False
-
It should be false in the statement as well.
-
!assert {model: account.bank.statement, id: statement_test1, string: We should not check the balance}:
- balance_check is False
-
Now I change the profile associated to the statement.
-
!record {model: account.bank.statement, id: statement_test1}:
profile_id: profile_test2
-
The statement should receive information from the new statement.
-
!assert {model: account.bank.statement, id: statement_test1, string: We should check the balance}:
- balance_check is True

View File

@@ -0,0 +1,78 @@
-
In order to test the related fields in the profile, I first need to create a profile
-
!record {model: account.statement.profile, id: profile_test1}:
name: Bank EUR Profile
journal_id: account.bank_journal
commission_account_id: account.a_expense
company_id: base.main_company
partner_id: base.res_partner_1
journal_id: account.check_journal
balance_check: True
-
I create a second profile
-
!record {model: account.statement.profile, id: profile_test2}:
name: Second profile
journal_id: account.bank_journal
commission_account_id: account.a_expense
company_id: base.main_company
partner_id: base.res_partner_3
journal_id: account.bank_journal
balance_check: True
-
Now I create a statement.
-
!record {model: account.bank.statement, id: statement_test1}:
name: Statement 1
profile_id: profile_test1
company_id: base.main_company
-
Now I check that the related data come from the profile
-
!assert {model: account.bank.statement, id: statement_test1, string: Initial data should come from the profile}:
- balance_check is True
- credit_partner_id.id == _ref('base.res_partner_1')
- journal_id.id == _ref('account.check_journal')
-
Now I set the balance flag to False in the profile
-
!record {model: account.statement.profile, id: profile_test1}:
balance_check: False
-
It should be false in the statement as well.
-
!assert {model: account.bank.statement, id: statement_test1, string: We should not check the balance}:
- balance_check is False
-
Now I change the journal in the profile
-
!record {model: account.statement.profile, id: profile_test1}:
journal_id: account.cash_journal
-
The journal should propagate to the statement
-
!assert {model: account.bank.statement, id: statement_test1, string: The journal should be updated}:
- journal_id.id == _ref('account.cash_journal')
-
Now I change the partner in the profile
-
!record {model: account.statement.profile, id: profile_test1}:
partner_id: base.res_partner_2
-
The partner should propagate to the statement
-
!assert {model: account.bank.statement, id: statement_test1, string: The partner should be updated}:
- credit_partner_id.id == _ref('base.res_partner_2')
-
Now I change the profile associated to the statement.
-
!record {model: account.bank.statement, id: statement_test1}:
profile_id: profile_test2
-
The statement should receive information from the new statement.
-
!assert {model: account.bank.statement, id: statement_test1, string: All information should be probagated from the new profile}:
- balance_check is True
- credit_partner_id.id == _ref('base.res_partner_3')
- journal_id.id == _ref('account.bank_journal')