diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index f7d2406dc61..da1f95de301 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -53,11 +53,11 @@ module named account_voucher. 'wizard/account_move_bank_reconcile_view.xml', 'wizard/account_use_model_view.xml', 'account_installer.xml', + 'wizard/account_period_close_view.xml', 'account_view.xml', 'account_report.xml', 'wizard/account_report_common_view.xml', 'wizard/account_invoice_refund_view.xml', - 'wizard/account_period_close_view.xml', 'wizard/account_fiscalyear_close_state.xml', 'wizard/account_chart_view.xml', 'wizard/account_tax_chart_view.xml', diff --git a/addons/account/account.py b/addons/account/account.py index 483652fd579..652eddb4218 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -536,7 +536,7 @@ class account_account(osv.osv): def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} - + if 'company_id' in vals: move_lines = self.pool.get('account.move.line').search(cr, uid, [('account_id', 'in', ids)]) if move_lines: @@ -1080,7 +1080,7 @@ class account_move(osv.osv): 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner"), 'amount': fields.function(_amount_compute, method=True, string='Amount', digits_compute=dp.get_precision('Account'), type='float', fnct_search=_search_amount), 'date': fields.date('Date', required=True, states={'posted':[('readonly',True)]}), - 'narration':fields.text('Narration', select=True), + 'narration':fields.text('Narration'), 'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company',store=True), } _defaults = { @@ -1147,7 +1147,7 @@ class account_move(osv.osv): else: raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !')) return True - + def button_validate(self, cursor, user, ids, context=None): def _get_chart_account(cursor, user, account): if account.parent_id: @@ -1155,7 +1155,7 @@ class account_move(osv.osv): else: chart_account = account return chart_account - + for move in self.browse(cursor, user, ids): lines = move.line_id if lines: @@ -1165,7 +1165,7 @@ class account_move(osv.osv): parent_right = ref_chart_account.parent_right result = True for line in lines[1:]: - if not(line.account_id.parent_left > parent_left and line.account_id.parent_left < parent_right): + if not (line.account_id.parent_left > parent_left and line.account_id.parent_left < parent_right): raise osv.except_osv(_('Error !'), _('You cannot validate a move unless accounts in its entry lines are in same Chart Of Accounts !')) return self.post(cursor, user, ids, context=context) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 6d5a6ac470b..f7c943f71d3 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -720,4 +720,4 @@ class account_bank_statement_line(osv.osv): account_bank_statement_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 2dec01fd74c..5ed057536a8 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -232,7 +232,7 @@ class account_cash_statement(osv.osv): 'starting_details_ids':False }) res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context) - self.write(cr, uid, [res_id], {}) + #self.write(cr, uid, [res_id], {}) return res_id def write(self, cr, uid, ids, vals, context=None): @@ -302,7 +302,7 @@ class account_cash_statement(osv.osv): if statement.name and statement.name == '/': number = self.pool.get('ir.sequence').get(cr, uid, 'account.cash.statement') vals.update({ - 'name':number + 'name': number }) cr.execute("select id from account_bank_statement where journal_id=%s and user_id=%s and state=%s order by id desc limit 1", (statement.journal_id.id, uid, 'confirm')) @@ -344,6 +344,7 @@ class account_cash_statement(osv.osv): res_users_obj = self.pool.get('res.users') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') + account_analytic_line_obj = self.pool.get('account.analytic.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') company_currency_id = res_users_obj.browse(cr, uid, uid, context=context).company_id.currency_id.id @@ -372,6 +373,10 @@ class account_cash_statement(osv.osv): # In line we get reconcile_id on bank.ste.rec. # in bank stat.rec we get line_new_ids on bank.stat.rec.line for move in st.line_ids: + if move.analytic_account_id: + if not st.journal_id.analytic_journal_id: + raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (st.journal_id.name,)) + context.update({'date':move.date}) move_id = account_move_obj.create(cr, uid, { 'journal_id': st.journal_id.id, @@ -410,6 +415,7 @@ class account_cash_statement(osv.osv): 'journal_id': st.journal_id.id, 'period_id': st.period_id.id, 'currency_id': st.currency.id, + 'analytic_account_id': move.analytic_account_id and move.analytic_account_id.id or False } amount = res_currency_obj.compute(cr, uid, st.currency.id, @@ -430,8 +436,28 @@ class account_cash_statement(osv.osv): move.account_id.currency_id.id, amount, context=context, account=acc_cur) val['amount_currency'] = amount_cur + move_line_id = account_move_line_obj.create(cr, uid, val , context=context) + torec.append(move_line_id) - torec.append(account_move_line_obj.create(cr, uid, val , context=context)) + if move.analytic_account_id: + anal_val = {} + amt = (val['credit'] or 0.0) - (val['debit'] or 0.0) + anal_val = { + 'name': val['name'], + 'ref': val['ref'], + 'date': val['date'], + 'amount': amt, + 'account_id': val['analytic_account_id'], + 'currency_id': val['currency_id'], + 'general_account_id': val['account_id'], + 'journal_id': st.journal_id.analytic_journal_id.id, + 'period_id': val['period_id'], + 'user_id': uid, + 'move_id': move_line_id + } + if val.get('amount_currency', False): + anal_val['amount_currency'] = val['amount_currency'] + account_analytic_line_obj.create(cr, uid, anal_val, context=context) if move.reconcile_id and move.reconcile_id.line_new_ids: for newline in move.reconcile_id.line_new_ids: @@ -496,8 +522,8 @@ class account_cash_statement(osv.osv): account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_acc_id=writeoff_acc_id, writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context) else: account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context) - - account_move_obj.write(cr, uid, [move_id], {'state':'posted'}) + move_name = st.name + ' - ' + str(move.sequence) + account_move_obj.write(cr, uid, [move_id], {'state':'posted', 'name': move_name}) done.append(st.id) vals = { diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index b0a0e8e059e..3e8be7dc2e6 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -125,16 +125,5 @@ always - - ir.actions.todo - account_installer_action_replace - tree - - - -