diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 04f55566d40..fe3f93b492c 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -113,8 +113,6 @@ module named account_vouchers 'report/account_invoice_report_view.xml', 'report/account_entries_report_view.xml', 'report/account_report_view.xml', - 'report/account_analytic_report_view.xml', - 'report/account_account_report_view.xml', 'report/account_analytic_entries_report_view.xml', 'board_account_view.xml', "wizard/account_pl_report_view.xml", diff --git a/addons/account/account.py b/addons/account/account.py index 0abdd2af7e0..210ae5b3157 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -81,7 +81,7 @@ class account_payment_term(osv.osv): if amt: next_date = datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days) if line.days2 < 0: - next_date += relativedelta(day=line.days2) + next_date += relativedelta(day=31) if line.days2 > 0: next_date += relativedelta(day=line.days2, months=1) result.append( (next_date.strftime('%Y-%m-%d'), amt) ) @@ -586,7 +586,7 @@ class account_journal_column(osv.osv): for col in cols: if col in ('period_id', 'journal_id'): continue - + result.append( (col, cols[col].string) ) result.sort() return result @@ -687,8 +687,7 @@ class account_fiscalyear(osv.osv): _columns = { 'name': fields.char('Fiscal Year', size=64, required=True), 'code': fields.char('Code', size=6, required=True), - 'company_id': fields.many2one('res.company', 'Company', - help="Keep empty if the fiscal year belongs to several companies.", required=True), + 'company_id': fields.many2one('res.company', 'Company', required=True), 'date_start': fields.date('Start Date', required=True), 'date_stop': fields.date('End Date', required=True), 'period_ids': fields.one2many('account.period', 'fiscalyear_id', 'Periods'), @@ -772,7 +771,7 @@ class account_period(osv.osv): 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly',True)]}, select=True), 'state': fields.selection([('draft','Draft'), ('done','Done')], 'State', readonly=True, help='When monthly periods are created. The state is \'Draft\'. At the end of monthly period it is in \'Done\' state.'), - 'company_id': fields.related('fiscalyear_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True) + 'company_id': fields.related('fiscalyear_id', 'company_id', type='many2one', relation='res.company', string='Company'), } _defaults = { 'state': lambda *a: 'draft', @@ -2120,7 +2119,7 @@ class account_tax_code_template(osv.osv): 'info': fields.text('Description'), 'parent_id': fields.many2one('account.tax.code.template', 'Parent Code', select=True), 'child_ids': fields.one2many('account.tax.code.template', 'parent_id', 'Child Codes'), - 'sign': fields.float('Sign for parent', required=True), + 'sign': fields.float('Sign for parent', required=True, help="Choose 1.00 to add the total to the parent account or -1.00 to subtract it"), 'notprintable':fields.boolean("Not Printable in Invoice", help="Check this box if you don't want any VAT related to this Tax Code to appear on invoices"), } @@ -2152,7 +2151,7 @@ class account_chart_template(osv.osv): _columns={ 'name': fields.char('Name', size=64, required=True), - 'account_root_id': fields.many2one('account.account.template','Root Account',required=True,domain=[('parent_id','=',False)]), + 'account_root_id': fields.many2one('account.account.template','Root Account',required=True,domain=[('parent_id','=',False)], help=""), 'tax_code_root_id': fields.many2one('account.tax.code.template','Root Tax Code',required=True,domain=[('parent_id','=',False)]), 'tax_template_ids': fields.one2many('account.tax.template', 'chart_template_id', 'Tax Template List', help='List of all the taxes that have to be installed by the wizard'), 'bank_account_view_id': fields.many2one('account.account.template','Bank Account',required=True), diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 0e46944a436..572cb9d04fd 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -303,6 +303,13 @@ class account_bank_statement(osv.osv): _('Ledger Posting line "%s" is not valid') % line.name) if move.reconcile_id and move.reconcile_id.line_ids: + ## Search if move has already a partial reconciliation + previous_partial = False + for line_reconcile_move in move.reconcile_id.line_ids: + if line_reconcile_move.reconcile_partial_id: + previous_partial = True + break + ## torec += map(lambda x: x.id, move.reconcile_id.line_ids) #try: if abs(move.reconcile_amount-move.amount)<0.0001: @@ -312,8 +319,14 @@ class account_bank_statement(osv.osv): for entry in move.reconcile_id.line_new_ids: writeoff_acc_id = entry.account_id.id break - - 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) + ## If we have already a partial reconciliation + ## We need to make a partial reconciliation + ## To add this amount to previous paid amount + if previous_partial: + account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context) + ## If it's the first reconciliation, we do a full reconciliation as regular + else: + 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) #except: diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index eea57359099..8380a19b411 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -26,16 +26,16 @@ from mx import DateTime from decimal import Decimal from tools.translate import _ -class singer_statement(osv.osv): +class account_cashbox_line(osv.osv): - """ Singer Statements """ + """ Cash Box Details """ - _name = 'singer.statement' - _description = 'Statement' + _name = 'account.cashbox.line' + _description = 'CashBox Line' def _sub_total(self, cr, uid, ids, name, arg, context=None): - """ Calculates Sub total" + """ Calculates Sub total @param name: Names of fields. @param arg: User defined arguments @return: Dictionary of values. @@ -61,7 +61,7 @@ class singer_statement(osv.osv): 'starting_id': fields.many2one('account.bank.statement',ondelete='cascade'), 'ending_id': fields.many2one('account.bank.statement',ondelete='cascade'), } -singer_statement() +account_cashbox_line() class account_cash_statement(osv.osv): @@ -157,22 +157,31 @@ class account_cash_statement(osv.osv): res[r] = round(res[r], 2) return res + def _get_company(self, cr, uid, ids, context={}): + user_pool = self.pool.get('res.users') + company_pool = self.pool.get('res.company') + user = user_pool.browse(cr, uid, uid, uid) + company_id = user.company_id and user.company_id.id + if not company_id: + company_id = company_pool.search(cr, uid, [])[0] + + return company_id + _columns = { 'company_id':fields.many2one('res.company', 'Company', required=False), 'journal_id': fields.many2one('account.journal', 'Journal', required=True), - 'balance_start': fields.function(_get_starting_balance, method=True, string='Opening Balance', type='float',digits=(16,2), help="Opening balance based on cashBox"), + 'balance_start': fields.function(_get_starting_balance, store=True, method=True, string='Opening Balance', type='float',digits=(16,2), help="Opening balance based on cashBox"), 'balance_end_real': fields.float('Closing Balance', digits=(16,2), states={'confirm':[('readonly', True)]}, help="closing balance entered by the cashbox verifier"), 'state': fields.selection( [('draft', 'Draft'), ('confirm', 'Confirm'), ('open','Open')], 'State', required=True, states={'confirm': [('readonly', True)]}, readonly="1"), - 'total_entry_encoding':fields.function(_get_sum_entry_encoding, method=True, string="Cash Transaction", help="Total cash transactions"), - 'date':fields.datetime("Open On"), + 'total_entry_encoding':fields.function(_get_sum_entry_encoding, method=True, store=True, string="Cash Transaction", help="Total cash transactions"), 'closing_date':fields.datetime("Closed On"), - 'balance_end': fields.function(_end_balance, method=True, string='Balance', help="Closing balance based on transactions"), - 'balance_end_cash': fields.function(_balance_end_cash, method=True, string='Balance', help="Closing balance based on cashBox"), - 'starting_details_ids': fields.one2many('singer.statement', 'starting_id', string='Opening Cashbox'), - 'ending_details_ids': fields.one2many('singer.statement', 'ending_id', string='Closing Cashbox'), + 'balance_end': fields.function(_end_balance, method=True, store=True, string='Balance', help="Closing balance based on transactions"), + 'balance_end_cash': fields.function(_balance_end_cash, method=True, store=True, string='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'), 'name': fields.char('Name', size=64, required=True, readonly=True), 'user_id':fields.many2one('res.users', 'Responsible', required=False), } @@ -181,7 +190,8 @@ class account_cash_statement(osv.osv): 'name': lambda *a: '/', 'date': lambda *a:time.strftime("%Y-%m-%d %H:%M:%S"), 'journal_id': _default_journal_id, - 'user_id': lambda self, cr, uid, context=None: uid + 'user_id': lambda self, cr, uid, context=None: uid, + 'company_id': _get_company } def create(self, cr, uid, vals, context=None): @@ -205,7 +215,7 @@ class account_cash_statement(osv.osv): @return: Dictionary of changed values """ - cash_pool = self.pool.get('singer.statement') + cash_pool = self.pool.get('account.cashbox.line') statement_pool = self.pool.get('account.bank.statement') res = {} @@ -220,17 +230,30 @@ class account_cash_statement(osv.osv): res = super(account_cash_statement, self).onchange_journal_id(cr, uid, statement_id, journal_id, context) return res - + + def _equal_balance(self, cr, uid, ids, statement, context={}): + if statement.balance_end != statement.balance_end_cash: + return False + else: + return True + + def _user_allow(self, cr, uid, ids, statement, context={}): + return True + def button_open(self, cr, uid, ids, context=None): """ Changes statement state to Running. @return: True """ - cash_pool = self.pool.get('singer.statement') + cash_pool = self.pool.get('account.cashbox.line') statement_pool = self.pool.get('account.bank.statement') statement = statement_pool.browse(cr, uid, ids[0]) - number = self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement') + + if not self._user_allow(cr, uid, ids, statement, context={}): + raise osv.except_osv(_('Error !'), _('User %s does not have rights to access %s journal !' % (statement.user_id.name, statement.journal_id.name))) + + number = self.pool.get('ir.sequence').get(cr, uid, statement.journal_id.sequence_id.code) if len(statement.starting_details_ids) > 0: sid = [] @@ -280,7 +303,7 @@ class account_cash_statement(osv.osv): if not st.state == 'open': continue - if st.balance_end != st.balance_end_cash: + if not self._equal_balance(cr, uid, ids, st, context): raise osv.except_osv(_('Error !'), _('Cash balance is not matching with closing balance !')) if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001): diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 0bc9e476601..3a0f889d931 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -508,7 +508,7 @@ class account_move_line(osv.osv): _constraints = [ (_check_no_view, 'You can not create move line on view account.', ['account_id']), (_check_no_closed, 'You can not create move line on closed account.', ['account_id']), - (_check_company_id,'Company must be same for its related account and period.',['company_id'] ), + (_check_company_id, 'Company must be same for its related account and period.', ['company_id']), ] #TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 4067423cc3f..5946661136f 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -12,12 +12,14 @@ form
- - + + + + @@ -29,8 +31,8 @@ - - + + + + diff --git a/addons/account_voucher_payment/account_voucher_payment_wizard.xml b/addons/account_voucher_payment/account_voucher_payment_wizard.xml deleted file mode 100644 index 0551b1bbcb5..00000000000 --- a/addons/account_voucher_payment/account_voucher_payment_wizard.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/addons/account_voucher_payment/account_voucher_unreconcile.py b/addons/account_voucher_payment/account_voucher_unreconcile.py deleted file mode 100644 index f36af98dc1c..00000000000 --- a/addons/account_voucher_payment/account_voucher_unreconcile.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 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 . -# -############################################################################## - -import wizard -import pooler - -_info_form = ''' -
- - -