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_invoice_view.xml b/addons/account/account_invoice_view.xml index fc10c58cc8f..7394fc54b7e 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -205,7 +205,7 @@ + + 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 = ''' -
- - -