ACCOUNT: remove active on account.account and add new type closed

bzr revid: ced-5f466cc918ff20cf9d08d5223a75c6335837f48c
This commit is contained in:
ced 2007-05-14 10:40:57 +00:00
parent 129fcdf5cf
commit 0d82aa7ffc
6 changed files with 20 additions and 11 deletions

View File

@ -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."),

View File

@ -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\',\'&lt;&gt;\',\'view\')]"')
attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'&lt;&gt;\',\'view\'), (\'type\',\'&lt;&gt;\',\'closed\')]"')
if field.readonly:
attrs.append('readonly="1"')
if field.required:

View File

@ -122,7 +122,6 @@
<field name="currency_id" select="1"/>
<field name="close_method"/>
<field name="reconcile"/>
<field name="active" select="1" />
<newline/>
<field name="parent_id" colspan="4"/>
<field name="tax_ids" colspan="4"/>

View File

@ -43,5 +43,9 @@
<field name="name">Equity</field>
<field name="code">equity</field>
</record>
<record model="account.account.type" id="account_type_closed">
<field name="name">Closed</field>
<field name="code">closed</field>
</record>
</data>
</terp>

View File

@ -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'),

View File

@ -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]))