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 2004e839c9c..08725e0cc5e 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1082,7 +1082,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 = { @@ -1151,24 +1151,17 @@ class account_move(osv.osv): return True def button_validate(self, cursor, user, ids, context=None): - def _get_chart_account(cursor, user, account): - if account.parent_id: - chart_account = _get_chart_account(cursor, user, account.parent_id) - else: - chart_account = account - return chart_account - for move in self.browse(cursor, user, ids): - lines = move.line_id - if lines: - ref_line = lines[0] - ref_chart_account = _get_chart_account(cursor, user, ref_line.account_id) - parent_left = ref_chart_account.parent_left - 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): - raise osv.except_osv(_('Error !'), _('You cannot validate a move unless accounts in its entry lines are in same Chart Of Accounts !')) + top = None + for line in move.line_id: + account = line.account_id + while account: + account2 = account + account = account.parent_id + if not top: + top = account2.id + elif top<>account2.id: + raise osv.except_osv(_('Error !'), _('You cannot validate a Journal Entry unless all journal items are in same chart of accounts !')) return self.post(cursor, user, ids, context=context) def button_cancel(self, cr, uid, ids, context={}): @@ -2046,7 +2039,7 @@ class account_model_line(osv.osv): 'currency_id': fields.many2one('res.currency', 'Currency'), 'partner_id': fields.many2one('res.partner', 'Partner'), - 'date_maturity': fields.selection([('today','Date of the day'), ('partner','Partner Payment Term')], 'Maturity date', help="The maturity date of the generated entries for this model. You can choose between the creation date or the creation date of the entries plus the partner payment terms."), + 'date_maturity': fields.selection([('today','Date of the day'), ('partner','Partner Payment Term')], 'Due date', help="The due date of the generated entries for this model. You can choose between the creation date or the creation date of the entries plus the partner payment terms."), 'date': fields.selection([('today','Date of the day'), ('partner','Partner Payment Term')], 'Current Date', required=True, help="The date of the generated entries"), } _defaults = { 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 8ac8d68ca6c..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): @@ -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: diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index 3e8be7dc2e6..977b2b4dfb3 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -123,6 +123,7 @@ 5 always + diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index ad48ea86c23..0cb9165490e 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -65,7 +65,7 @@ - + diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 24f4bb795a2..07f094d5867 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -7,6 +7,8 @@ + + diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index f28ebc76210..7be8cffa508 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -439,7 +439,7 @@ class account_move_line(osv.osv): 'blocked': fields.boolean('Litigation', help="You can check this box to mark this journal item as a litigation with the associated partner"), 'partner_id': fields.many2one('res.partner', 'Partner'), - 'date_maturity': fields.date('Maturity date', help="This field is used for payable and receivable journal entries. You can put the limit date for the payment of this line."), + 'date_maturity': fields.date('Due date', help="This field is used for payable and receivable journal entries. You can put the limit date for the payment of this line."), 'date': fields.related('move_id','date', string='Effective date', type='date', required=True, store={ 'account.move': (_get_move_lines, ['date'], 20) @@ -986,9 +986,10 @@ class account_move_line(osv.osv): if 'period_id' in vals and 'period_id' not in context: period_id = vals['period_id'] elif 'journal_id' not in context and 'move_id' in vals: - m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) - journal_id = m.journal_id.id - period_id = m.period_id.id + if vals['move_id']: + m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) + journal_id = m.journal_id.id + period_id = m.period_id.id else: journal_id = context.get('journal_id',False) period_id = context.get('period_id',False) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 4ae31b9b7f6..9b1a9369df8 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -91,15 +91,15 @@ form
- - + + - +