diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 03d127249fb..d04030c909e 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -163,8 +163,10 @@

-

@@ -309,9 +311,11 @@

-

diff --git a/addons/account_voucher/__openerp__.py b/addons/account_voucher/__openerp__.py index a7be61db2c9..16ea771d123 100644 --- a/addons/account_voucher/__openerp__.py +++ b/addons/account_voucher/__openerp__.py @@ -49,7 +49,6 @@ eInvoicing & Payments module manage all Voucher Entries such as "Reconciliation "account_voucher_sequence.xml", "account_voucher_workflow.xml", "account_voucher_report.xml", - "wizard/account_voucher_unreconcile_view.xml", "wizard/account_statement_from_invoice_view.xml", "account_voucher_view.xml", "voucher_payment_receipt_view.xml", diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index ce0c64337b9..1287c7b3c18 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -46,11 +46,7 @@ class account_voucher(osv.osv): def _check_paid(self, cr, uid, ids, name, args, context=None): res = {} for voucher in self.browse(cr, uid, ids, context=context): - paid = False - for line in voucher.move_ids: - if (line.account_id.type, 'in', ('receivable', 'payable')) and line.reconcile_id: - paid = True - res[voucher.id] = paid + res[voucher.id] = any([((line.account_id.type, 'in', ('receivable', 'payable')) and line.reconcile_id) for line in voucher.move_ids]) return res def _get_type(self, cr, uid, context=None): @@ -186,15 +182,16 @@ class account_voucher(osv.osv): res['arch'] = etree.tostring(doc) return res - def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount): + def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount, type): debit = credit = 0.0 + sign = type == 'payment' and -1 or 1 for l in line_dr_ids: debit += l['amount'] for l in line_cr_ids: credit += l['amount'] - return abs(amount - abs(credit - debit)) + return amount - sign * (credit - debit) - def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount, voucher_currency, context=None): + def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount, voucher_currency, type, context=None): context = context or {} if not line_dr_ids and not line_cr_ids: return {'value':{}} @@ -215,7 +212,7 @@ class account_voucher(osv.osv): if voucher_line.get('currency_id', company_currency) != company_currency: is_multi_currency = True break - return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount), 'is_multi_currency': is_multi_currency}} + return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount, type), 'is_multi_currency': is_multi_currency}} def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None): if not ids: return {} @@ -223,12 +220,13 @@ class account_voucher(osv.osv): res = {} debit = credit = 0.0 for voucher in self.browse(cr, uid, ids, context=context): + sign = voucher.type == 'payment' and -1 or 1 for l in voucher.line_dr_ids: debit += l.amount for l in voucher.line_cr_ids: credit += l.amount currency = voucher.currency_id or voucher.company_id.currency_id - res[voucher.id] = currency_obj.round(cr, uid, currency, abs(voucher.amount - abs(credit - debit))) + res[voucher.id] = currency_obj.round(cr, uid, currency, voucher.amount - sign * (credit - debit)) return res def _paid_amount_in_company_currency(self, cr, uid, ids, name, args, context=None): @@ -716,7 +714,7 @@ class account_voucher(osv.osv): default['value']['pre_line'] = 1 elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0: default['value']['pre_line'] = 1 - default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price) + default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price, ttype) return default def onchange_payment_rate_currency(self, cr, uid, ids, currency_id, payment_rate, payment_rate_currency_id, date, amount, company_id, context=None): diff --git a/addons/account_voucher/invoice.py b/addons/account_voucher/invoice.py index 006a622e25f..14b725cbeca 100644 --- a/addons/account_voucher/invoice.py +++ b/addons/account_voucher/invoice.py @@ -40,7 +40,7 @@ class invoice(osv.osv): 'domain': '[]', 'context': { 'default_partner_id': inv.partner_id.id, - 'default_amount': inv.residual, + 'default_amount': inv.type in ('out_refund', 'in_refund') and -inv.residual or inv.residual, 'default_name':inv.name, 'close_after_process': True, 'invoice_type':inv.type, diff --git a/addons/account_voucher/test/case1_usd_usd.yml b/addons/account_voucher/test/case1_usd_usd.yml index d8ac932a055..a30c85ffb71 100644 --- a/addons/account_voucher/test/case1_usd_usd.yml +++ b/addons/account_voucher/test/case1_usd_usd.yml @@ -173,12 +173,12 @@ self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount}) assert (voucher_id.state=='draft'), "Voucher is not in draft state" - - I check that writeoff amount computed is 10.0 + I check that writeoff amount computed is -10.0 - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_seagate'))]) voucher_id = self.browse(cr, uid, voucher[0]) - assert (voucher_id.writeoff_amount == 10.0), "Writeoff amount is not 10.0" + assert (voucher_id.writeoff_amount == -10.0), "Writeoff amount is not -10.0" - I confirm the voucher - @@ -266,12 +266,12 @@ self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount}) assert (voucher_id.state=='draft'), "Voucher is not in draft state" - - I check that writeoff amount computed is 5.0 + I check that writeoff amount computed is -5.0 - !python {model: account.voucher}: | voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_seagate'))]) voucher_id = self.browse(cr, uid, voucher[0]) - assert (voucher_id.writeoff_amount == 5.0), "Writeoff amount is not 5.0" + assert (voucher_id.writeoff_amount == -5.0), "Writeoff amount is not -5.0" - I confirm the voucher - diff --git a/addons/account_voucher/test/case_eur_usd.yml b/addons/account_voucher/test/case_eur_usd.yml index 72f0d22aead..53db4ffaf80 100644 --- a/addons/account_voucher/test/case_eur_usd.yml +++ b/addons/account_voucher/test/case_eur_usd.yml @@ -107,11 +107,11 @@ self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount}) assert (voucher.state=='draft'), "Voucher is not in draft state" - - I check that writeoff amount computed is 50.0 + I check that writeoff amount computed is -50.0 - !python {model: account.voucher}: | voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case')) - assert (voucher.writeoff_amount == 50.0), "Writeoff amount is not 50.0" + assert (voucher.writeoff_amount == -50.0), "Writeoff amount is not -50.0" - I confirm the voucher - @@ -167,4 +167,4 @@ move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)]) move_line = move_line_obj.browse(cr, uid, move_lines[0]) assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for Invoice" - \ No newline at end of file + diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 99ea3a2bbea..ef983145901 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -74,7 +74,7 @@ - + - + - + - + - - account.statement.from.invoice.form - account.statement.from.invoice - form - -
- - - - -
-
-
-
-
- - - Import Invoices in Statement - account.statement.from.invoice - form - tree,form - - new - - account.statement.from.invoice.lines.form account.statement.from.invoice.lines diff --git a/addons/account_voucher/wizard/account_voucher_unreconcile.py b/addons/account_voucher/wizard/account_voucher_unreconcile.py deleted file mode 100644 index 42a9e1c5ec2..00000000000 --- a/addons/account_voucher/wizard/account_voucher_unreconcile.py +++ /dev/null @@ -1,62 +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 . -# -############################################################################## - -from osv import osv -from osv import fields - -class account_voucher_unreconcile(osv.osv_memory): - _name = "account.voucher.unreconcile" - _description = "Account voucher unreconcile" - - _columns = { - 'remove':fields.boolean('Want to remove accounting entries too ?', required=False), - } - - _defaults = { - 'remove': True, - } - - def trans_unrec(self, cr, uid, ids, context=None): -# res = self.browse(cr, uid, ids[0]) - if context is None: - context = {} - voucher_pool = self.pool.get('account.voucher') - reconcile_pool = self.pool.get('account.move.reconcile') - if context.get('active_id'): - voucher = voucher_pool.browse(cr, uid, context.get('active_id'), context=context) - recs = [] - for line in voucher.move_ids: - if line.reconcile_id: - recs += [line.reconcile_id.id] - if line.reconcile_partial_id: - recs += [line.reconcile_partial_id.id] - #for rec in recs: - reconcile_pool.unlink(cr, uid, recs) -# if res.remove: - voucher_pool.cancel_voucher(cr, uid, [context.get('active_id')], context) -# wf_service = netsvc.LocalService("workflow") -# wf_service.trg_validate(uid, 'account.voucher', context.get('active_id'), 'cancel_voucher', cr) - - return {'type': 'ir.actions.act_window_close'} - -account_voucher_unreconcile() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_voucher/wizard/account_voucher_unreconcile_view.xml b/addons/account_voucher/wizard/account_voucher_unreconcile_view.xml deleted file mode 100644 index 04131b643eb..00000000000 --- a/addons/account_voucher/wizard/account_voucher_unreconcile_view.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - Account voucher unreconcile - account.voucher.unreconcile - form - -
- -
-
- - Unreconcile entries - account.voucher.unreconcile - form - form - - new - - -
-