Jean-Sébastien SUZANNE has proposed merging
lp:~openerp-community-testers/openobject-addons/trunk-bug-1059328 into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
Related bugs:
Bug #1059328 in OpenERP Addons: "[trunk] Regression - Accounts of type <>
view allow be setted as parent of other account"
https://bugs.launchpad.net/openobject-addons/+bug/1059328
For more details, see:
https://code.launchpad.net/~openerp-community-testers/openobject-addons/trunk-bug-1059328/+merge/132056
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"
--
https://code.launchpad.net/~openerp-community-testers/openobject-addons/trunk-bug-1059328/+merge/132056
Your team OpenERP Community Testers is subscribed to branch
lp:~openerp-community-testers/openobject-addons/trunk-bug-1059328.
=== modified file 'account/__openerp__.py'
--- account/__openerp__.py 2012-09-26 12:16:27 +0000
+++ account/__openerp__.py 2012-10-30 11:00:33 +0000
@@ -44,7 +44,7 @@
* Company Analysis
* Graph of Treasury
-The processes like maintaining of general ledger is done through the defined financial Journals (entry move line orgrouping is maintained through journal)
+The processes like maintaining of general ledger is done through the defined financial Journals (entry move line orgrouping is maintained through journal)
for a particular financial year and for preparation of vouchers there is a module named account_voucher.
""",
'website': 'http://www.openerp.com',
@@ -143,6 +143,7 @@
# 'account_unit_test.xml',
],
'test': [
+ 'test/account_account_parent_type.yml',
'test/account_customer_invoice.yml',
'test/account_supplier_invoice.yml',
'test/account_change_currency.yml',
=== modified file 'account/account.py'
--- account/account.py 2012-10-25 13:09:30 +0000
+++ account/account.py 2012-10-30 11:00:33 +0000
@@ -2501,6 +2501,13 @@
_name = "account.account.template"
_description ='Templates for Accounts'
+ def _check_type(self, cr, uid, ids, context=None):
+ accounts = self.browse(cr, uid, ids, context=context)
+ for account in accounts:
+ if account.child_parent_ids and account.type not in ('view', 'consolidation'):
+ return False
+ return True
+
_columns = {
'name': fields.char('Name', size=256, required=True, select=True),
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all moves for this account to have this secondary currency."),
@@ -2540,6 +2547,7 @@
_check_recursion = check_cycle
_constraints = [
(_check_recursion, 'Error!\nYou cannot create recursive account templates.', ['parent_id']),
+ (_check_type, 'Configuration Error!\nYou cannot define children to an account template with internal type different of "View".', ['type']),
]
def name_get(self, cr, uid, ids, context=None):
=== added file 'account/test/account_account_parent_type.yml'
--- account/test/account_account_parent_type.yml 1970-01-01 00:00:00 +0000
+++ account/test/account_account_parent_type.yml 2012-10-30 11:00:33 +0000
@@ -0,0 +1,96 @@
+-
+ Add account.account.template with type == view and Add child
+-
+ !record {model: account.account.template, id: account_account_template_type_view}:
+ name: view account
+ code: 1234
+ type: view
+ user_type: account.account_type_income_view1
+ child_parent_ids:
+ - name: child account
+ code: 5678
+ type: other
+ user_type: account.account_type_income_view1
+-
+ Add account.account.template with type <> view and Add child
+-
+ !python {model: account.account.template}: |
+ from osv import orm
+ try:
+ user_type = ref('account.account_type_income_view1')
+ self.create(cr, uid, {
+ 'name': 'other account',
+ 'code': '0123',
+ 'type': 'other',
+ 'user_type': user_type,
+ 'child_parent_ids': [(0, 0, {
+ 'name': 'other child account',
+ 'code': '4567',
+ 'type': 'other',
+ 'user_type': user_type,
+ },
+ ),
+ ],
+ })
+ assert False, "You can't create an account template with a parent type <> view"
+ except orm.except_orm:
+ pass
+-
+ Search account.account.template with type == view and with child, change the type of the template
+-
+ !python {model: account.account.template}: |
+ from osv import orm
+ try:
+ account_id = ref("account_account_template_type_view")
+ self.write(cr, uid, [account_id], {'type': 'other'})
+ assert False, "You can't modify an account with type <> view and with a child"
+ except orm.except_orm:
+ pass
+-
+ Add account.account with type == view and Add child
+-
+ !record {model: account.account, id: account_account_type_view}:
+ name: view account
+ code: 1234
+ type: view
+ user_type: account_type_income_view1
+ child_parent_ids:
+ - name: child account
+ code: 5678
+ type: other
+ user_type: account_type_income_view1
+-
+ Add account.account with type <> view and Add child
+-
+ !python {model: account.account}: |
+ from osv import orm
+ try:
+ user_type = ref('account.account_type_income_view1')
+ self.create(cr, uid, {
+ 'name': 'other account',
+ 'code': '0123',
+ 'type': 'other',
+ 'user_type': user_type,
+ 'child_parent_ids': [(0, 0, {
+ 'name': 'other child account',
+ 'code': '4567',
+ 'type': 'other',
+ 'user_type': user_type,
+ },
+ ),
+ ],
+ })
+ assert False, "You can't create an account template with a parent type <> view"
+ except orm.except_orm:
+ pass
+-
+ Search account.account with type == view and with child, change the type of the account
+-
+ !python {model: account.account}: |
+ from osv import orm
+ try:
+ account_id = ref("account_account_type_view")
+ self.write(cr, uid, [account_id], {'type': 'other'})
+ assert False, "You can't modify an account with type <> view and with a child"
+ except orm.except_orm:
+ pass
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp