diff --git a/addons/account/account.py b/addons/account/account.py index e83568c9ee1..34306b703aa 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -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): @@ -722,8 +722,6 @@ class account_journal(osv.osv): name = rs.name if rs.currency: name = "%s (%s)" % (rs.name, rs.currency.name) - else: - name = "%s (%s)" % (rs.name, rs.company_id.currency_id.name) res += [(rs.id, name)] return res @@ -932,17 +930,10 @@ class account_period(osv.osv): return False def find(self, cr, uid, dt=None, context=None): - if context is None: context = {} if not dt: dt = time.strftime('%Y-%m-%d') #CHECKME: shouldn't we check the state of the period? - args = [('date_start', '<=' ,dt), ('date_stop', '>=', dt)] - if context.get('company_id', False): - args.append(('company_id', '=', context['company_id'])) - else: - company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id - args.append(('company_id', '=', company_id)) - ids = self.search(cr, uid, args, context=context) + ids = self.search(cr, uid, [('date_start','<=',dt),('date_stop','>=',dt)]) if not ids: raise osv.except_osv(_('Error !'), _('No period defined for this date: %s !\nPlease create one.')%dt) return ids 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..11ec7d8360a 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -205,7 +205,7 @@ - + - - - - - account.invoice.supplier.pay - account.invoice - form - - - - - + + account.invoice.customer.pay + account.invoice + form + + + + + + + account.invoice.supplier.pay + account.invoice + form + + + + + diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml index e44fd264879..8f8a0d0854a 100644 --- a/addons/account_voucher/account_voucher_view.xml +++ b/addons/account_voucher/account_voucher_view.xml @@ -43,7 +43,7 @@
- + @@ -102,7 +102,7 @@ - +