mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[fix] account_statement_ext: trigger for a related field
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
'security/ir.model.access.csv',
|
||||
'security/ir_rule.xml'],
|
||||
'demo_xml': [],
|
||||
'test': [],
|
||||
'test': ['test/test_balance_check.yml'],
|
||||
'installable': True,
|
||||
'images': [],
|
||||
'auto_install': False,
|
||||
|
||||
@@ -159,6 +159,13 @@ class AccountBankStatement(Model):
|
||||
|
||||
return profile_ids[0] if profile_ids else False
|
||||
|
||||
def _get_statement_from_profile(self, cr, uid, profile_ids, context=None):
|
||||
"""Weirdness warning! self is another class."""
|
||||
triggered = []
|
||||
for profile in self.browse(cr, uid, profile_ids, context=context):
|
||||
triggered += [st.id for st in profile.bank_statement_ids]
|
||||
return triggered
|
||||
|
||||
_columns = {
|
||||
'profile_id': fields.many2one(
|
||||
'account.statement.profile',
|
||||
@@ -178,8 +185,12 @@ class AccountBankStatement(Model):
|
||||
'balance_check',
|
||||
type='boolean',
|
||||
string='Balance check',
|
||||
store=True,
|
||||
readonly=True),
|
||||
store={
|
||||
'account.statement.profile': (
|
||||
_get_statement_from_profile, ['balance_check'], 10),
|
||||
},
|
||||
readonly=True
|
||||
),
|
||||
'journal_id': fields.related(
|
||||
'profile_id',
|
||||
'journal_id',
|
||||
|
||||
50
account_statement_ext/test/test_balance_check.yml
Normal file
50
account_statement_ext/test/test_balance_check.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
-
|
||||
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
|
||||
Reference in New Issue
Block a user