Merge lp:~openerp-community-testers/openobject-addons/trunk-bug-1059328 into lp:openobject-addons

Proposed by Jean-Sébastien SUZANNE
Status: Needs review
Proposed branch: lp:~openerp-community-testers/openobject-addons/trunk-bug-1059328
Merge into: lp:openobject-addons
Diff against target: 159 lines (+118/-1)
3 files modified
account/__openerp__.py (+2/-1)
account/account.py (+8/-0)
account/test/account_account_parent_type.yml (+108/-0)
To merge this branch: bzr merge lp:~openerp-community-testers/openobject-addons/trunk-bug-1059328
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+132056@code.launchpad.net

Description of the change

Add yaml test on account:
 * Add account.account.template with type == view and Add child
 * Add account.account.template with type <> view and Add child
 * Search account.account.template with type == view and with child, change the type of the template
 * Add account.account with type == view and Add child
 * Add account.account with type <> view and Add child
 * Search account.account with type == view and with child, change the type of the account

Add the same constraints than account_account on account_account_template on the field "type"

To post a comment you must log in.
7896. By Jean-Sébastien SUZANNE

[FIX] Add savepoint on the test who call raise

7897. By Olivier Dony (Odoo)

[IMP] account.template: better error message for type constraint

Unmerged revisions

7897. By Olivier Dony (Odoo)

[IMP] account.template: better error message for type constraint

7896. By Jean-Sébastien SUZANNE

[FIX] Add savepoint on the test who call raise

7895. By Jean-Sébastien SUZANNE

[FIX] Add yaml test for the type of account.account and account.account.template and fix the account.account.template

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/__openerp__.py'
2--- account/__openerp__.py 2012-09-26 12:16:27 +0000
3+++ account/__openerp__.py 2012-11-05 10:43:22 +0000
4@@ -44,7 +44,7 @@
5 * Company Analysis
6 * Graph of Treasury
7
8-The processes like maintaining of general ledger is done through the defined financial Journals (entry move line orgrouping is maintained through journal)
9+The processes like maintaining of general ledger is done through the defined financial Journals (entry move line orgrouping is maintained through journal)
10 for a particular financial year and for preparation of vouchers there is a module named account_voucher.
11 """,
12 'website': 'http://www.openerp.com',
13@@ -143,6 +143,7 @@
14 # 'account_unit_test.xml',
15 ],
16 'test': [
17+ 'test/account_account_parent_type.yml',
18 'test/account_customer_invoice.yml',
19 'test/account_supplier_invoice.yml',
20 'test/account_change_currency.yml',
21
22=== modified file 'account/account.py'
23--- account/account.py 2012-10-25 13:09:30 +0000
24+++ account/account.py 2012-11-05 10:43:22 +0000
25@@ -2501,6 +2501,13 @@
26 _name = "account.account.template"
27 _description ='Templates for Accounts'
28
29+ def _check_type(self, cr, uid, ids, context=None):
30+ accounts = self.browse(cr, uid, ids, context=context)
31+ for account in accounts:
32+ if account.child_parent_ids and account.type not in ('view', 'consolidation'):
33+ return False
34+ return True
35+
36 _columns = {
37 'name': fields.char('Name', size=256, required=True, select=True),
38 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all moves for this account to have this secondary currency."),
39@@ -2540,6 +2547,7 @@
40 _check_recursion = check_cycle
41 _constraints = [
42 (_check_recursion, 'Error!\nYou cannot create recursive account templates.', ['parent_id']),
43+ (_check_type, 'Configuration Error!\nOnly "view" and "consolidation" accounts may have child accounts.', ['type']),
44 ]
45
46 def name_get(self, cr, uid, ids, context=None):
47
48=== added file 'account/test/account_account_parent_type.yml'
49--- account/test/account_account_parent_type.yml 1970-01-01 00:00:00 +0000
50+++ account/test/account_account_parent_type.yml 2012-11-05 10:43:22 +0000
51@@ -0,0 +1,108 @@
52+-
53+ Add account.account.template with type == view and Add child
54+-
55+ !record {model: account.account.template, id: account_account_template_type_view}:
56+ name: view account
57+ code: 1234
58+ type: view
59+ user_type: account.account_type_income_view1
60+ child_parent_ids:
61+ - name: child account
62+ code: 5678
63+ type: other
64+ user_type: account.account_type_income_view1
65+-
66+ Add account.account.template with type <> view and Add child
67+-
68+ !python {model: account.account.template}: |
69+ from osv import orm
70+ try:
71+ cr.execute("SAVEPOINT add_account_acount_template_type_not_view")
72+ user_type = ref('account.account_type_income_view1')
73+ self.create(cr, uid, {
74+ 'name': 'other account',
75+ 'code': '0123',
76+ 'type': 'other',
77+ 'user_type': user_type,
78+ 'child_parent_ids': [(0, 0, {
79+ 'name': 'other child account',
80+ 'code': '4567',
81+ 'type': 'other',
82+ 'user_type': user_type,
83+ },
84+ ),
85+ ],
86+ })
87+ assert False, "You can't create an account template with a parent type <> view"
88+ except orm.except_orm:
89+ pass
90+ finally:
91+ cr.execute("ROLLBACK TO SAVEPOINT add_account_acount_template_type_not_view")
92+-
93+ Search account.account.template with type == view and with child, change the type of the template
94+-
95+ !python {model: account.account.template}: |
96+ from osv import orm
97+ try:
98+ cr.execute("SAVEPOINT modify_account_acount_template_type_view")
99+ account_id = ref("account_account_template_type_view")
100+ self.write(cr, uid, [account_id], {'type': 'other'})
101+ assert False, "You can't modify an account with type <> view and with a child"
102+ except orm.except_orm:
103+ pass
104+ finally:
105+ cr.execute("ROLLBACK TO SAVEPOINT modify_account_acount_template_type_view")
106+-
107+ Add account.account with type == view and Add child
108+-
109+ !record {model: account.account, id: account_account_type_view}:
110+ name: view account
111+ code: 1234
112+ type: view
113+ user_type: data_account_type_view
114+ child_parent_ids:
115+ - name: child account
116+ code: 5678
117+ type: other
118+ user_type: account_type_income_view1
119+-
120+ Add account.account with type <> view and Add child
121+-
122+ !python {model: account.account}: |
123+ from osv import orm
124+ try:
125+ cr.execute("SAVEPOINT add_account_acount_type_not_view")
126+ user_type = ref('account.account_type_income_view1')
127+ id = self.create(cr, uid, {
128+ 'name': 'other account',
129+ 'code': '0123',
130+ 'type': 'other',
131+ 'user_type': user_type,
132+ 'child_parent_ids': [(0, 0, {
133+ 'name': 'other child account',
134+ 'code': '4567',
135+ 'type': 'other',
136+ 'user_type': user_type,
137+ },
138+ ),
139+ ],
140+ })
141+ assert False, "You can't create an account template with a parent type <> view"
142+ except orm.except_orm:
143+ pass
144+ finally:
145+ cr.execute("ROLLBACK TO SAVEPOINT add_account_acount_type_not_view")
146+-
147+ Search account.account with type == view and with child, change the type of the account
148+-
149+ !python {model: account.account}: |
150+ from osv import orm
151+ try:
152+ cr.execute("SAVEPOINT modify_account_acount_type_view")
153+ account_id = ref("account_account_type_view")
154+ self.write(cr, uid, [account_id], {'type': 'other'})
155+ assert False, "You can't modify an account with type <> view and with a child"
156+ except orm.except_orm:
157+ pass
158+ finally:
159+ cr.execute("ROLLBACK TO SAVEPOINT modify_account_acount_type_view")

Subscribers

People subscribed via source and target branches

to all changes: