From 0d82aa7ffcaeaa7ebc9de442f8db48a2857723e9 Mon Sep 17 00:00:00 2001 From: ced <> Date: Mon, 14 May 2007 10:40:57 +0000 Subject: [PATCH] ACCOUNT: remove active on account.account and add new type closed bzr revid: ced-5f466cc918ff20cf9d08d5223a75c6335837f48c --- addons/account/account.py | 6 ++---- addons/account/account_move_line.py | 14 +++++++++++--- addons/account/account_view.xml | 1 - addons/account/data/account_data1.xml | 4 ++++ addons/account/invoice.py | 4 ++-- addons/account/transfer.py | 2 +- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 5998404fc54..f2ef729e3f9 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -211,7 +211,6 @@ class account_account(osv.osv): 'close_method': fields.selection([('none','None'), ('balance','Balance'), ('detail','Detail'),('unreconciled','Unreconciled')], 'Deferral Method', required=True, help="Tell Tiny ERP how to process the entries of this account when you close a fiscal year. None removes all entries to start with an empty account for the new fiscal year. Balance creates only one entry to keep the balance for the new fiscal year. Detail keeps the detail of all entries of the preceeding years. Unreconciled keeps the detail of unreconciled entries only."), 'tax_ids': fields.many2many('account.tax', 'account_account_tax_default_rel', 'account_id','tax_id', 'Default Taxes'), - 'active': fields.boolean('Active'), 'note': fields.text('Note'), 'company_currency_id': fields.function(_get_company_currency, method=True, type='many2one', relation='res.currency', string='Company Currency'), 'company_id': fields.many2one('res.company', 'Company', required=True), @@ -225,7 +224,6 @@ class account_account(osv.osv): _defaults = { 'sign': lambda *a: 1, 'type': lambda *a: 'view', - 'active': lambda *a: True, 'reconcile': lambda *a: False, 'close_method': lambda *a: 'balance', 'company_id': _default_company, @@ -328,8 +326,8 @@ class account_journal(osv.osv): 'code': fields.char('Code', size=16), 'type': fields.selection([('sale','Sale'), ('purchase','Purchase'), ('cash','Cash'), ('general','General'), ('situation','Situation')], 'Type', size=32, required=True), - 'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view')]), - 'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view')]), + 'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]), + 'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view'), ('type', '<>', 'closed')]), 'active': fields.boolean('Active'), 'view_id': fields.many2one('account.journal.view', 'View', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tell Tiny ERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."), diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 23ae41f8623..0f75f2203aa 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -160,7 +160,7 @@ class account_move_line(osv.osv): 'quantity': fields.float('Quantity', digits=(16,2), help="The optionnal quantity expressed by this line, eg: number of product sold. The quantity is not a legal requirement but is very usefull for some reports."), 'debit': fields.float('Debit', digits=(16,2), states={'reconciled':[('readonly',True)]}), 'credit': fields.float('Credit', digits=(16,2), states={'reconciled':[('readonly',True)]}), - 'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", states={'reconciled':[('readonly',True)]}, domain=[('type','<>','view')]), + 'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", states={'reconciled':[('readonly',True)]}, domain=[('type','<>','view'), ('type', '<>', 'closed')]), 'move_id': fields.many2one('account.move', 'Entry', required=True, ondelete="cascade", states={'reconciled':[('readonly',True)]}, help="The entry of this entry line.", select=True), @@ -208,8 +208,16 @@ class account_move_line(osv.osv): return False return True + def _check_no_closed(self, cr, uid, ids): + lines = self.browse(cr, uid, ids) + for l in lines: + if l.account_id.type == 'closed': + return False + return True + _constraints = [ - (_check_no_view, 'You can not create move line on view account.', ['account_id']) + (_check_no_view, 'You can not create move line on view account.', ['account_id']), + (_check_no_closed, 'You can not create move line on closed account.', ['account_id']), ] def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, journal=False): @@ -359,7 +367,7 @@ class account_move_line(osv.osv): fields.append(field.field) attrs = [] if field.field=='account_id' and journal.id: - attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\')]"') + attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]"') if field.readonly: attrs.append('readonly="1"') if field.required: diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 57baddc34f6..bd1932fbcf0 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -122,7 +122,6 @@ - diff --git a/addons/account/data/account_data1.xml b/addons/account/data/account_data1.xml index 81857a37e84..fa5b5235f9a 100644 --- a/addons/account/data/account_data1.xml +++ b/addons/account/data/account_data1.xml @@ -43,5 +43,9 @@ Equity equity + + Closed + closed + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 95fd7e88405..662bf4c5336 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -605,7 +605,7 @@ class account_invoice_line(osv.osv): 'invoice_id': fields.many2one('account.invoice', 'Invoice Ref', ondelete='cascade', select=True), 'uos_id': fields.many2one('product.uom', 'Unit', ondelete='set null'), 'product_id': fields.many2one('product.product', 'Product', ondelete='set null'), - 'account_id': fields.many2one('account.account', 'Source Account', required=True, domain=[('type','<>','view')]), + 'account_id': fields.many2one('account.account', 'Source Account', required=True, domain=[('type','<>','view'), ('type', '<>', 'closed')]), 'price_unit': fields.float('Unit Price', required=True, digits=(16, int(config['price_accuracy']))), 'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal'), 'quantity': fields.float('Quantity', required=True), @@ -742,7 +742,7 @@ class account_invoice_tax(osv.osv): _columns = { 'invoice_id': fields.many2one('account.invoice', 'Invoice Line', ondelete='cascade', select=True), 'name': fields.char('Tax Description', size=64, required=True), - 'account_id': fields.many2one('account.account', 'Tax Account', required=True, domain=[('type','<>','view'),('type','<>','income')]), + 'account_id': fields.many2one('account.account', 'Tax Account', required=True, domain=[('type','<>','view'),('type','<>','income'), ('type', '<>', 'closed')]), 'base': fields.float('Base', digits=(16,2)), 'amount': fields.float('Amount', digits=(16,2)), 'manual': fields.boolean('Manual'), diff --git a/addons/account/transfer.py b/addons/account/transfer.py index 50e9d16c423..325ca37a9d1 100644 --- a/addons/account/transfer.py +++ b/addons/account/transfer.py @@ -100,7 +100,7 @@ class account_transfer(osv.osv): 'refund': ('receivable','income'), 'sale': ('income','cash'), } - d = {'account_src_id': [('type','<>','view')], 'account_dest_id': [('type','<>','view')]} + d = {'account_src_id': [('type','<>','view'), ('type', '<>', 'closed')], 'account_dest_id': [('type','<>','view'), ('type', '<>', 'closed')]} if type_acc.has_key(type): d['account_src_id'].append(('type','=',type_acc[type][0])) d['account_dest_id'].append(('type','=',type_acc[type][1]))