diff --git a/addons/account/__init__.py b/addons/account/__init__.py index 24129306e13..52c65f0c3da 100644 --- a/addons/account/__init__.py +++ b/addons/account/__init__.py @@ -25,6 +25,7 @@ import project import partner import invoice import account_bank_statement +import account_bank import account_cash_statement import account_move_line import account_analytic_line diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index feeab771dcf..1b378e15e93 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -23,6 +23,7 @@ "version" : "1.1", "author" : "OpenERP SA", "category": 'Finance', + 'complexity': "normal", "description": """ Accounting and Financial Management. ==================================== @@ -121,13 +122,15 @@ module named account_voucher. 'company_view.xml', 'board_account_view.xml', "wizard/account_report_profit_loss_view.xml", - "wizard/account_report_balance_sheet_view.xml" + "wizard/account_report_balance_sheet_view.xml", + "account_bank_view.xml" ], 'demo_xml': [ - 'account_demo.xml', + 'demo/account_demo.xml', 'project/project_demo.xml', 'project/analytic_account_demo.xml', 'demo/account_minimal.xml', + 'demo/account_invoice_demo.xml', # 'account_unit_test.xml', ], 'test': [ diff --git a/addons/account/account.py b/addons/account/account.py index 03a9b628922..7bf9cbd187b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -102,7 +102,7 @@ class account_payment_term_line(osv.osv): ('fixed', 'Fixed Amount')], 'Valuation', required=True, help="""Select here the kind of valuation related to this payment term line. Note that you should have your last line with the type 'Balance' to ensure that the whole amount will be threated."""), - 'value_amount': fields.float('Value Amount', digits_compute=dp.get_precision('Payment Term'), help="For Value percent enter % ratio between 0-1."), + 'value_amount': fields.float('Amount To Pay', digits_compute=dp.get_precision('Payment Term'), help="For percent enter a ratio between 0-1."), 'days': fields.integer('Number of Days', required=True, help="Number of days to add before computation of the day of month." \ "If Date=15/01, Number of Days=22, Day of Month=-1, then the due date is 28/02."), 'days2': fields.integer('Day of the Month', required=True, help="Day of the month, set -1 for the last day of the current month. If it's positive, it gives the day of the next month. Set 0 for net days (otherwise it's based on the beginning of the month)."), @@ -131,7 +131,7 @@ class account_account_type(osv.osv): _name = "account.account.type" _description = "Account Type" _columns = { - 'name': fields.char('Acc. Type Name', size=64, required=True), + 'name': fields.char('Account Type', size=64, required=True), 'code': fields.char('Code', size=32, required=True), 'close_method': fields.selection([('none', 'None'), ('balance', 'Balance'), ('detail', 'Detail'), ('unreconciled', 'Unreconciled')], 'Deferral Method', required=True, help="""Set here the method that will be used to generate the end of year journal entries for all the accounts of this type. @@ -146,7 +146,7 @@ class account_account_type(osv.osv): ('expense','Profit & Loss (Expense Accounts)'), ('asset','Balance Sheet (Assets Accounts)'), ('liability','Balance Sheet (Liability Accounts)') - ],'P&L / BS Category', select=True, readonly=False, help="According value related accounts will be display on respective reports (Balance Sheet Profit & Loss Account)", required=True), + ],'P&L / BS Category', select=True, readonly=False, help="This field is used to generate legal reports: profit and loss, balance sheet.", required=True), 'note': fields.text('Description'), } _defaults = { @@ -358,13 +358,13 @@ class account_account(osv.osv): ('liquidity','Liquidity'), ('consolidation', 'Consolidation'), ('closed', 'Closed'), - ], 'Internal Type', required=True, help="This type is used to differentiate types with "\ - "special effects in OpenERP: view can not have entries, consolidation are accounts that "\ + ], 'Internal Type', required=True, help="The 'Internal Type' is used for features available on "\ + "different types of accounts: view can not have journal items, consolidation are accounts that "\ "can have children accounts for multi-company consolidations, payable/receivable are for "\ "partners accounts (for debit/credit computations), closed for depreciated accounts."), 'user_type': fields.many2one('account.account.type', 'Account Type', required=True, - help="These types are defined according to your country. The type contains more information "\ - "about the account and its specificities."), + help="Account Type is used for information purpose, to generate " + "country-specific legal reports, and set the rules to close a fiscal year and generate opening entries."), 'parent_id': fields.many2one('account.account', 'Parent', ondelete='cascade', domain=[('type','=','view')]), 'child_parent_ids': fields.one2many('account.account','parent_id','Children'), 'child_consol_ids': fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children'), @@ -602,13 +602,13 @@ class account_journal(osv.osv): _description = "Journal" _columns = { 'name': fields.char('Journal Name', size=64, required=True), - 'code': fields.char('Code', size=5, required=True, help="The code will be used to generate the numbers of the journal entries of this journal."), + 'code': fields.char('Code', size=5, required=True, help="The code will be displayed on reports."), 'type': fields.selection([('sale', 'Sale'),('sale_refund','Sale Refund'), ('purchase', 'Purchase'), ('purchase_refund','Purchase Refund'), ('cash', 'Cash'), ('bank', 'Bank and Cheques'), ('general', 'General'), ('situation', 'Opening/Closing Situation')], 'Type', size=32, required=True, - help="Select 'Sale' for Sale journal to be used at the time of making invoice."\ - " Select 'Purchase' for Purchase Journal to be used at the time of approving purchase order."\ - " Select 'Cash' to be used at the time of making payment."\ - " Select 'General' for miscellaneous operations."\ - " Select 'Opening/Closing Situation' to be used at the time of new fiscal year creation or end of year entries generation."), + help="Select 'Sale' for customer invoices journals."\ + " Select 'Purchase' for supplier invoices journals."\ + " Select 'Cash' or 'Bank' for journals that are used in customer or supplier payments."\ + " Select 'General' for miscellaneous operations journals."\ + " Select 'Opening/Closing Situation' for entries generated for new fiscal years."), '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')]), 'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells OpenERP 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."), @@ -1141,7 +1141,7 @@ class account_move(osv.osv): 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", store=True), 'amount': fields.function(_amount_compute, string='Amount', digits_compute=dp.get_precision('Account'), type='float', fnct_search=_search_amount), 'date': fields.date('Date', required=True, states={'posted':[('readonly',True)]}, select=True), - 'narration':fields.text('Narration'), + 'narration':fields.text('Internal Note'), 'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True), } _defaults = { @@ -2675,9 +2675,10 @@ class wizard_multi_charts_accounts(osv.osv_memory): return False def _get_default_accounts(self, cr, uid, context=None): - return [{'acc_name': _('Current'),'account_type':'bank'}, - {'acc_name': _('Deposit'),'account_type':'bank'}, - {'acc_name': _('Cash'),'account_type':'cash'}] + return [ + {'acc_name': _('Bank Account'),'account_type':'bank'}, + {'acc_name': _('Cash'),'account_type':'cash'} + ] _defaults = { 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, [uid], c)[0].company_id.id, diff --git a/addons/account/account_bank.py b/addons/account/account_bank.py new file mode 100644 index 00000000000..a3d66ccdf7c --- /dev/null +++ b/addons/account/account_bank.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from tools.translate import _ +from osv import fields, osv + +class bank(osv.osv): + _inherit = "res.partner.bank" + _columns = { + 'journal_id': fields.many2one('account.journal', 'Account Journal', help="This journal will be created automatically for this bank account when you save the record"), + } + def create(self, cr, uid, data, context={}): + result = super(bank, self).create(cr, uid, data, context=context) + self.post_write(cr, uid, [result], context=context) + return result + + def write(self, cr, uid, ids, data, context={}): + result = super(bank, self).write(cr, uid, ids, data, context=context) + self.post_write(cr, uid, ids, context=context) + return result + + def post_write(self, cr, uid, ids, context={}): + obj_acc = self.pool.get('account.account') + obj_data = self.pool.get('ir.model.data') + for bank in self.browse(cr, uid, ids, context): + if bank.company_id and not bank.journal_id: + # Find the code and parent of the bank account to create + dig = 6 + current_num = 1 + ids = obj_acc.search(cr, uid, [('type','=','liquidity')], context=context) + # No liquidity account exists, no template available + if not ids: continue + + ref_acc_bank_temp = obj_acc.browse(cr, uid, ids[0], context=context) + ref_acc_bank = ref_acc_bank_temp.parent_id + while True: + new_code = str(ref_acc_bank.code.ljust(dig-len(str(current_num)), '0')) + str(current_num) + ids = obj_acc.search(cr, uid, [('code', '=', new_code), ('company_id', '=', bank.company_id.id)]) + if not ids: + break + current_num += 1 + + acc = { + 'name': (bank.bank_name or '')+' '+bank.acc_number, + 'currency_id': bank.company_id.currency_id.id, + 'code': new_code, + 'type': 'liquidity', + 'user_type': ref_acc_bank_temp.user_type.id, + 'reconcile': False, + 'parent_id': ref_acc_bank.id, + 'company_id': bank.company_id.id, + } + acc_bank_id = obj_acc.create(cr,uid,acc,context=context) + + # Get the journal view id + data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')]) + data = obj_data.browse(cr, uid, data_id[0], context=context) + view_id_cash = data.res_id + + jour_obj = self.pool.get('account.journal') + new_code = 1 + while True: + code = _('BNK')+str(new_code) + ids = jour_obj.search(cr, uid, [('code','=',code)], context=context) + if not ids: + break + new_code += 1 + + #create the bank journal + vals_journal = { + 'name': (bank.bank_name or '')+' '+bank.acc_number, + 'code': code, + 'type': 'bank', + 'company_id': bank.company_id.id, + 'analytic_journal_id': False, + 'currency_id': False, + 'default_credit_account_id': acc_bank_id, + 'default_debit_account_id': acc_bank_id, + 'view_id': view_id_cash + } + journal_id = jour_obj.create(cr, uid, vals_journal, context=context) + + self.write(cr, uid, [bank.id], {'journal_id': journal_id}, context=context) + return True + diff --git a/addons/account/account_bank_view.xml b/addons/account/account_bank_view.xml new file mode 100644 index 00000000000..d91739817ac --- /dev/null +++ b/addons/account/account_bank_view.xml @@ -0,0 +1,48 @@ + + + + + + + + Partner Bank Accounts - Journal + res.partner.bank + form + + + + + + + + + + + + + + Bank Accounts + res.partner.bank + form + tree,form + + Configure your company's bank account and select those that must appear on the report footer. You can drag & drop bank in the list view to reorder bank accounts. If you use the accounting application of OpenERP, journals and accounts will be created automatically based on these data. + + + + + + + + 4 + + + + + diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index d3acde730a9..151f7bbc0f0 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -19,9 +19,9 @@ Configure - - 23 - + + 23 + @@ -52,7 +52,7 @@ - + @@ -82,7 +82,7 @@ 3 - special + automatic diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index be431c9b2e7..b21d3e9604f 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -203,7 +203,7 @@ -