diff --git a/addons/account/account.py b/addons/account/account.py index 61e1fb021a9..41d4673df0a 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -139,7 +139,7 @@ class account_account_type(osv.osv): 'Balance' will generally be used for cash accounts. 'Detail' will copy each existing journal item of the previous year, even the reconciled ones. 'Unreconciled' will copy only the journal items that were unreconciled on the first day of the new fiscal year."""), - 'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign on Reports', required=True, help='Allows you to change the sign of the balance amount displayed in the reports, so that you can see positive figures instead of negative ones in expenses accounts.'), + 'sign': fields.selection([(-1, 'Reverse balance sign'), (1, 'Preserve balance sign')], 'Sign on Reports', required=True, help='For accounts that are typically more debited than credited and that you would like to print as negative amounts in your reports, you should reverse the sign of the balance; e.g.: Expense account. The same applies for accounts that are typically more credited than debited and that you would like to print as positive amounts in your reports; e.g.: Income account.'), 'report_type':fields.selection([ ('none','/'), ('income','Profit & Loss (Income Accounts)'), @@ -250,6 +250,7 @@ class account_account(osv.osv): #compute for each account the balance/debit/credit from the move lines accounts = {} res = {} + null_result = dict((fn, 0.0) for fn in field_names) if children_and_consolidated: aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) @@ -306,12 +307,11 @@ class account_account(osv.osv): sums[current.id][fn] += sums[child.id][fn] else: sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context) - null_result = dict((fn, 0.0) for fn in field_names) for id in ids: res[id] = sums.get(id, null_result) else: for id in ids: - res[id] = 0.0 + res[id] = null_result return res def _get_company_currency(self, cr, uid, ids, field_name, arg, context=None): @@ -2637,6 +2637,10 @@ class account_fiscal_position_account_template(osv.osv): account_fiscal_position_account_template() +# --------------------------------------------------------- +# Account Financial Report +# --------------------------------------------------------- + class account_financial_report(osv.osv): _name = "account.financial.report" _description = "Account Report" @@ -2691,17 +2695,19 @@ class account_financial_report(osv.osv): 'parent_id': fields.many2one('account.financial.report', 'Parent'), 'children_ids': fields.one2many('account.financial.report', 'parent_id', 'Account Report'), 'sequence': fields.integer('Sequence'), + 'note': fields.text('Notes'), + 'balance': fields.function(_get_balance, 'Balance'), + 'level': fields.function(_get_level, string='Level', store=True, type='integer'), 'type': fields.selection([ - ('sum','Sum'), + ('sum','View'), ('accounts','Accounts'), - ('account_report','Account Report'), + ('account_type','Account Type'), + ('account_report','Report Value'), ],'Type'), 'account_ids': fields.many2many('account.account', 'account_account_financial_report', 'report_line_id', 'account_id', 'Accounts'), - 'note': fields.text('Notes'), - 'account_report_id': fields.many2one('account.financial.report', 'Account Report'), - 'balance': fields.function(_get_balance, 'Balance'), - 'display_detail': fields.boolean('Display the account list'), - 'level': fields.function(_get_level, string='Level', store=True, type='integer'), + 'display_detail': fields.boolean('Display details', help='Display every account with its balance instead of the sum.'), + 'account_report_id': fields.many2one('account.financial.report', 'Report Value'), + 'account_type_ids': fields.many2many('account.account.type', 'account_account_financial_report_type', 'report_id', 'account_type_id', 'Account Types'), } _defaults = { @@ -2710,7 +2716,9 @@ class account_financial_report(osv.osv): account_financial_report() - # Multi charts of Accounts wizard +# --------------------------------------------------------- +# Account generation from template wizards +# --------------------------------------------------------- class wizard_multi_charts_accounts(osv.osv_memory): """ diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 277e2aa04b1..4cc2ed89786 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -117,6 +117,12 @@ class account_bank_statement(osv.osv): res[statement_id] = (currency_id, currency_names[currency_id]) return res + def _get_statement(self, cr, uid, ids, context=None): + result = {} + for line in self.pool.get('account.bank.statement.line').browse(cr, uid, ids, context=context): + result[line.statement_id.id] = True + return result.keys() + _order = "date desc, id desc" _name = "account.bank.statement" _description = "Bank Statement" @@ -131,15 +137,19 @@ class account_bank_statement(osv.osv): states={'confirm':[('readonly',True)]}), 'balance_end_real': fields.float('Ending Balance', digits_compute=dp.get_precision('Account'), states={'confirm': [('readonly', True)]}), - 'balance_end': fields.function(_end_balance, store=True, # store=True for account_cash_statement - string="Balance", help='Balance as calculated based on Starting Balance and transaction lines'), + 'balance_end': fields.function(_end_balance, + store = { + 'account.bank.statement': (lambda self, cr, uid, ids, c={}: ids, ['line_ids','move_line_ids'], 10), + 'account.bank.statement.line': (_get_statement, ['amount'], 10), + }, + string="Computed Balance", help='Balance as calculated based on Starting Balance and transaction lines'), 'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), 'line_ids': fields.one2many('account.bank.statement.line', 'statement_id', 'Statement lines', states={'confirm':[('readonly', True)]}), 'move_line_ids': fields.one2many('account.move.line', 'statement_id', 'Entry lines', states={'confirm':[('readonly',True)]}), - 'state': fields.selection([('draft', 'Draft'), + 'state': fields.selection([('draft', 'New'), ('open','Open'), # used by cash statements ('confirm', 'Closed')], 'State', required=True, readonly="1", @@ -306,7 +316,7 @@ class account_bank_statement(osv.osv): return self.write(cr, uid, ids, {'state':'confirm'}, context=context) def check_status_condition(self, cr, uid, state, journal_type='bank'): - return state=='draft' + return state in ('draft','open') def button_confirm_bank(self, cr, uid, ids, context=None): obj_seq = self.pool.get('ir.sequence') @@ -465,7 +475,7 @@ class account_bank_statement_line(osv.osv): } _defaults = { 'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'), - 'date': lambda *a: time.strftime('%Y-%m-%d'), + 'date': lambda self,cr,uid,context={}: context.get('date', time.strftime('%Y-%m-%d')), 'type': 'general', } diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 3957e75c860..dc78d19bab4 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -184,31 +184,33 @@ class account_cash_statement(osv.osv): res['end'] = end_l return res + def _get_statement(self, cr, uid, ids, context=None): + result = {} + for line in self.pool.get('account.bank.statement.line').browse(cr, uid, ids, context=context): + result[line.statement_id.id] = True + return result.keys() + _columns = { - 'total_entry_encoding': fields.function(_get_sum_entry_encoding, store=True, string="Cash Transaction", help="Total cash transactions"), + 'total_entry_encoding': fields.function(_get_sum_entry_encoding, string="Cash Transaction", help="Total cash transactions", + store = { + 'account.bank.statement': (lambda self, cr, uid, ids, c={}: ids, ['line_ids','move_line_ids'], 10), + 'account.bank.statement.line': (_get_statement, ['amount'], 10), + }), 'closing_date': fields.datetime("Closed On"), - 'balance_end_cash': fields.function(_balance_end_cash, store=True, string='Balance', help="Closing balance based on cashBox"), + 'balance_end_cash': fields.function(_balance_end_cash, store=True, string='Closing Balance', help="Closing balance based on cashBox"), 'starting_details_ids': fields.one2many('account.cashbox.line', 'starting_id', string='Opening Cashbox'), 'ending_details_ids': fields.one2many('account.cashbox.line', 'ending_id', string='Closing Cashbox'), 'user_id': fields.many2one('res.users', 'Responsible', required=False), } _defaults = { 'state': 'draft', - 'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), + 'date': lambda self,cr,uid,context={}: context.get('date', time.strftime("%Y-%m-%d %H:%M:%S")), 'user_id': lambda self, cr, uid, context=None: uid, 'starting_details_ids': _get_cash_open_box_lines, 'ending_details_ids': _get_default_cash_close_box_lines } def create(self, cr, uid, vals, context=None): - sql = [ - ('journal_id', '=', vals.get('journal_id', False)), - ('state', '=', 'open') - ] - open_jrnl = self.search(cr, uid, sql) - if open_jrnl: - raise osv.except_osv(_('Error'), _('You can not have two open register for the same journal!')) - if self.pool.get('account.journal').browse(cr, uid, vals['journal_id'], context=context).type == 'cash': open_close = self._get_cash_open_close_box_lines(cr, uid, context) if vals.get('starting_details_ids', False): @@ -300,7 +302,6 @@ class account_cash_statement(osv.osv): }) vals.update({ - 'date': time.strftime("%Y-%m-%d %H:%M:%S"), 'state': 'open', }) self.write(cr, uid, [statement.id], vals, context=context) @@ -310,7 +311,7 @@ class account_cash_statement(osv.osv): if journal_type == 'bank': return super(account_cash_statement, self).balance_check(cr, uid, cash_id, journal_type, context) if not self._equal_balance(cr, uid, cash_id, context): - raise osv.except_osv(_('Error !'), _('CashBox Balance is not matching with Calculated Balance !')) + raise osv.except_osv(_('Error !'), _('The closing balance should be the same than the computed balance !')) return True def statement_close(self, cr, uid, ids, journal_type='bank', context=None): diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index 374304135df..361a371fb97 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -85,5 +85,58 @@ automatic + + Define your Bank Account + ir.actions.act_window + res.partner.bank + form + form + + + + + + + + + Review your Financial Accounts + ir.actions.act_window + account.account + form + tree,form + + + + + + + + + + Review your Financial Journal + ir.actions.act_window + account.journal + form + tree,form + + + + + + + + + Review your Payment Terms + ir.actions.act_window + account.payment.term + form + tree,form + + + + + + + diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 97852a11b5f..09a90b98686 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -205,7 +205,7 @@ - +