From 1daa6977d0678da40805229765f8d0fd207204b3 Mon Sep 17 00:00:00 2001 From: qdp Date: Thu, 4 Sep 2008 14:01:44 +0200 Subject: [PATCH] *moved sign of account_account on account_account_type *splitted type of accounts into 2 fields: a fiels.selection for internal purpose (static) and a many2one to account_account_type for user categorization. *changed demo data accordingly *modified wizard of closing fiscalyear and views accordingly bzr revid: qdp@tinyerp.com-20080904120144-t0izbg80ot7tpth6 --- addons/account/account.py | 45 +++++++++-- addons/account/account_view.xml | 12 +-- addons/account/data/account_data1.xml | 74 +++++-------------- addons/account/data/account_minimal.xml | 5 ++ .../account/wizard/wizard_fiscalyear_close.py | 6 +- 5 files changed, 70 insertions(+), 72 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 52e260f4f5d..093c40fd8ff 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -104,10 +104,12 @@ class account_account_type(osv.osv): 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of account types."), 'partner_account': fields.boolean('Partner account'), 'close_method': fields.selection([('none','None'), ('balance','Balance'), ('detail','Detail'),('unreconciled','Unreconciled')], 'Deferral Method', required=True), + 'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign on Reports', required=True, help='Allows to change the displayed amount of the balance in the reports, in order to see positive results instead of negative ones in expenses accounts.'), } _defaults = { 'close_method': lambda *a: 'none', 'sequence': lambda *a: 5, + 'sign': lambda *a: 1, } _order = "sequence" account_account_type() @@ -224,10 +226,23 @@ class account_account(osv.osv): _columns = { 'name': fields.char('Name', size=128, required=True, select=True), - 'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign', required=True, help='Allows to change the displayed amount of the balance to see positive results instead of negative ones in expenses accounts'), 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Force all moves for this account to have this secondary currency."), 'code': fields.char('Code', size=64), - 'type': fields.selection(_code_get, 'Account Type', required=True), + 'type': fields.selection([ + ('receivable','Receivable'), + ('payable','Payable'), + ('view','View'), + ('consolidation','Consolidation'), + ('income','Income'), + ('expense','Expense'), + ('tax','Tax'), + ('cash','Cash'), + #('asset','Asset'), + #('equity','Equity'), + ('closed','Closed'), + ], 'Internal Type', required=True,), + + 'user_type': fields.many2one('account.account.type', 'Account Type'), # 'parent_id': fields.many2many('account.account', 'account_account_rel', 'child_id', 'parent_id', 'Parents'), 'parent_id': fields.many2one('account.account','Parent', ondelete='cascade'), 'child_parent_ids':fields.one2many('account.account','parent_id','Children'), @@ -258,7 +273,6 @@ class account_account(osv.osv): return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] _defaults = { - 'sign': lambda *a: 1, 'type' : lambda *a :'view', 'reconcile': lambda *a: False, 'company_id': _default_company, @@ -1656,10 +1670,23 @@ class account_account_template(osv.osv): _columns = { 'name': fields.char('Name', size=128, required=True, select=True), - 'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign', required=True, help='Allows to change the displayed amount of the balance to see positive results instead of negative ones in expenses accounts.'), + #'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign', required=True, help='Allows to change the displayed amount of the balance to see positive results instead of negative ones in expenses accounts.'), 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Force all moves for this account to have this secondary currency."), 'code': fields.char('Code', size=64), - 'type': fields.selection(_code_get, 'Account Type', required=True), + 'type': fields.selection([ + ('receivable','Receivable'), + ('payable','Payable'), + ('view','View'), + ('consolidation','Consolidation'), + ('income','Income'), + ('expense','Expense'), + ('tax','Tax'), + ('cash','Cash'), + #('asset','Asset'), + #('equity','Equity'), + ('closed','Closed'), + ], 'Internal Type', required=True,), + 'user_type': fields.many2one('account.account.type', 'Account Type'), 'reconcile': fields.boolean('Allow Reconciliation', help="Check this option if the user can make a reconciliation of the entries in this account."), 'shortcut': fields.char('Shortcut', size=12), 'note': fields.text('Note'), @@ -1669,7 +1696,7 @@ class account_account_template(osv.osv): } _defaults = { - 'sign': lambda *a: 1, + #'sign': lambda *a: 1, 'reconcile': lambda *a: False, 'type' : lambda *a :'view', } @@ -1948,10 +1975,11 @@ class wizard_multi_charts_accounts(osv.osv_memory): #create the account_account vals={ 'name': (obj_acc_root.id == account_template.id) and obj_multi.company_id.name or account_template.name, - 'sign': account_template.sign, + #'sign': account_template.sign, 'currency_id': account_template.currency_id and account_template.currency_id.id or False, 'code': account_template.code, 'type': account_template.type, + 'user_type': account_template.user_type or False, 'reconcile': account_template.reconcile, 'shortcut': account_template.shortcut, 'note': account_template.note, @@ -2015,10 +2043,11 @@ class wizard_multi_charts_accounts(osv.osv_memory): tmp = self.pool.get('res.partner.bank').name_get(cr, uid, [line.acc_no.id])[0][1] vals={ 'name': line.acc_no.bank and line.acc_no.bank.name+' '+tmp or tmp, - 'sign': ref_acc_bank.sign, + #'sign': ref_acc_bank.sign, 'currency_id': line.currency_id and line.currency_id.id or False, 'code': ref_acc_bank.code+str(current_num), 'type': 'cash', + 'user_type': account_template.user_type or False, 'reconcile': True, 'parent_id': acc_template_ref[ref_acc_bank.id] or False, 'company_id': company_id, diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 9782dc91799..aea2e8235d4 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -120,8 +120,8 @@ - - + + @@ -418,8 +418,8 @@ tree - + @@ -432,6 +432,7 @@ + @@ -1482,9 +1483,10 @@ - - + + + diff --git a/addons/account/data/account_data1.xml b/addons/account/data/account_data1.xml index 1d6e0f44b48..0ef92f05bd5 100644 --- a/addons/account/data/account_data1.xml +++ b/addons/account/data/account_data1.xml @@ -5,68 +5,30 @@ Account Type --> - - Receivable - receivable - True - balance - - - Payable - payable - True - balance - - - Total Account - view - none - - - - Consolidation - consolidation - none - - - Income - income - unreconciled - - - Expense - expense - unreconciled - - - - Tax - tax - balance - - - Cash - cash - balance - Asset asset + none + + + Liability + liability + unreconciled + + + Income + income balance - - Equity - equity - none + + Expense + expense + unreconciled - - Closed - closed - none + + Cash Moves + cash + unreconciled diff --git a/addons/account/data/account_minimal.xml b/addons/account/data/account_minimal.xml index 325326f8754..5c21ebf9aa2 100644 --- a/addons/account/data/account_minimal.xml +++ b/addons/account/data/account_minimal.xml @@ -19,6 +19,7 @@ your own accounts. Main Receivable x 40000 receivable + @@ -33,6 +34,7 @@ your own chart of account. Main Payable x 440000 payable + @@ -48,6 +50,7 @@ your own chart of account. Petty Cash x 570000 cash + @@ -62,6 +65,7 @@ your own chart of account. Products Purchase x 600000 expense + @@ -75,6 +79,7 @@ your own chart of account. Products Sales x 701000 income + diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index 9a4ba7d81c0..455ab049649 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -88,11 +88,11 @@ def _data_save(self, cr, uid, data, context): obj='account_move_line', context={'fiscalyear': fy_id}) cr.execute('select id from account_account WHERE active') ids = map(lambda x: x[0], cr.fetchall()) - accnt_type_obj = pool.get('account.account.type') for account in pool.get('account.account').browse(cr, uid, ids, context={'fiscalyear': fy_id}): - accnt_type_ids = accnt_type_obj.search(cr, uid, [('code','=',account.type)]) - accnt_type_data = accnt_type_obj.browse(cr, uid, accnt_type_ids[0]) + accnt_type_data = account.user_type + if not accnt_type_data: + continue if accnt_type_data.close_method=='none' or account.type == 'view': continue if accnt_type_data.close_method=='balance':