From f2ed355306d92ce7630f525fd7de1bfe664aa0e4 Mon Sep 17 00:00:00 2001 From: Carlos Dauden Date: Wed, 26 Oct 2016 11:48:04 +0200 Subject: [PATCH] account_payment_return: Improvements to suite (#107) --- account_payment_return/i18n/es.po | 51 +++++++++++++------ .../models/payment_return.py | 7 +++ .../tests/test_payment_return.py | 51 ++++++++++--------- 3 files changed, 70 insertions(+), 39 deletions(-) diff --git a/account_payment_return/i18n/es.po b/account_payment_return/i18n/es.po index e12aaa200ddb..e33a448c0523 100644 --- a/account_payment_return/i18n/es.po +++ b/account_payment_return/i18n/es.po @@ -1,22 +1,24 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_payment_return -# +# # Translators: # Sergio Teruel Albert, 2015 msgid "" msgstr "" "Project-Id-Version: account-payment (8.0)\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-08-15 18:00+0000\n" -"PO-Revision-Date: 2016-09-16 21:45+0000\n" -"Last-Translator: OCA Transbot \n" -"Language-Team: Spanish (http://www.transifex.com/oca/OCA-account-payment-8-0/language/es/)\n" +"POT-Creation-Date: 2016-10-25 13:17+0200\n" +"PO-Revision-Date: 2016-10-25 13:19+0200\n" +"Last-Translator: Carlos Incaser \n" +"Language-Team: Spanish (http://www.transifex.com/oca/OCA-account-payment-8-0/" +"language/es/)\n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: es\n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 1.8.7.1\n" #. module: account_payment_return #: field:payment.return.line,amount:0 @@ -88,8 +90,7 @@ msgid "Date of the last message posted on the record." msgstr "Fecha del último mensaje publicado en el registro." #. module: account_payment_return -#: field:payment.return,display_name:0 -#: field:payment.return.line,display_name:0 +#: field:payment.return,display_name:0 field:payment.return.line,display_name:0 #: field:payment.return.reason,display_name:0 msgid "Display Name" msgstr "Nombre mostrado" @@ -121,6 +122,8 @@ msgid "" "Holds the Chatter summary (number of messages, ...). This summary is " "directly in html format in order to be inserted in kanban views." msgstr "" +"Contiene el resumen del chatter (nº de mensajes, ...). Este resumen está " +"directamente en formato html para ser insertado en vistas kanban." #. module: account_payment_return #: field:payment.return,id:0 field:payment.return.line,id:0 @@ -149,7 +152,7 @@ msgid "Invoice has been included on a payment that has been returned later." msgstr "La factura ha sido incluida en un pago que ha sido devuelto más tarde." #. module: account_payment_return -#: code:addons/account_payment_return/models/payment_return.py:268 +#: code:addons/account_payment_return/models/payment_return.py:275 #, python-format msgid "Invoice: %s" msgstr "Factura: %s" @@ -214,13 +217,13 @@ msgid "Messages and communication history" msgstr "Historial de comunicación del sitio web" #. module: account_payment_return -#: code:addons/account_payment_return/models/payment_return.py:289 +#: code:addons/account_payment_return/models/payment_return.py:296 #, python-format msgid "Move lines: %s" msgstr "Apuntes: %s" #. module: account_payment_return -#: code:addons/account_payment_return/models/payment_return.py:312 +#: code:addons/account_payment_return/models/payment_return.py:319 #, python-format msgid "Move: %s" msgstr "Asiento: %s" @@ -234,7 +237,7 @@ msgstr "Nombre del cliente" #: code:addons/account_payment_return/models/payment_return.py:68 #, python-format msgid "Payment Line: %s (%s) in Payment Return: %s" -msgstr "" +msgstr "Línea de pago: %s (%s) en devolución de pago: %s" #. module: account_payment_return #: field:payment.return.line,move_line_ids:0 @@ -301,7 +304,8 @@ msgid "Reference to the reconcile object." msgstr "Referencia al objeto de conciliación." #. module: account_payment_return -#: code:addons/account_payment_return/models/payment_return.py:127 +#: code:addons/account_payment_return/models/payment_return.py:111 +#: code:addons/account_payment_return/models/payment_return.py:134 #, python-format msgid "Return %s" msgstr "Devolución %s" @@ -347,7 +351,24 @@ msgid "Unread Messages" msgstr "Mensajes sin leer" #. module: account_payment_return -#: code:addons/account_payment_return/models/payment_return.py:122 +#: field:payment.return,website_message_ids:0 +msgid "Website Messages" +msgstr "Mensajes del sitio web" + +#. module: account_payment_return +#: help:payment.return,website_message_ids:0 +msgid "Website communication history" +msgstr "Historial de comunicaciones del sitio web" + +#. module: account_payment_return +#: code:addons/account_payment_return/models/payment_return.py:113 +#, python-format +msgid "You can not remove a payment return if state is 'Done'" +msgstr "No puede borrar una devolución de pagos en estado 'Realizado'" + +#. module: account_payment_return +#: code:addons/account_payment_return/models/payment_return.py:107 +#: code:addons/account_payment_return/models/payment_return.py:129 #, python-format msgid "You must input all moves references in the payment return." msgstr "Debes informar todas las referencias de cobro." diff --git a/account_payment_return/models/payment_return.py b/account_payment_return/models/payment_return.py index c474a12d6882..57d34a5e9cae 100644 --- a/account_payment_return/models/payment_return.py +++ b/account_payment_return/models/payment_return.py @@ -107,6 +107,13 @@ def _prepare_invoice_returned_vals(self): def _prepare_invoice_returned_cancel_vals(self): return {'returned_payment': False} + @api.multi + def unlink(self): + if self.filtered(lambda x: x.state == 'done'): + raise UserError(_( + "You can not remove a payment return if state is 'Done'")) + return super(PaymentReturn, self).unlink() + @api.multi def button_match(self): self.mapped('line_ids').filtered(lambda x: ( diff --git a/account_payment_return/tests/test_payment_return.py b/account_payment_return/tests/test_payment_return.py index f9c010796e87..c31d19a18c6c 100644 --- a/account_payment_return/tests/test_payment_return.py +++ b/account_payment_return/tests/test_payment_return.py @@ -3,43 +3,43 @@ # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from openerp.exceptions import Warning as UserError -from openerp.tests.common import TransactionCase +from openerp.tests.common import SavepointCase -class TestPaymentReturn(TransactionCase): - - def setUp(self): - super(TestPaymentReturn, self).setUp() - self.account_invoice_model = self.env['account.invoice'] - self.payment_return_model = self.env['payment.return'] - self.partner = self.env.ref('base.res_partner_1') +class TestPaymentReturn(SavepointCase): + @classmethod + def setUpClass(cls): + super(TestPaymentReturn, cls).setUpClass() + cls.account_invoice_model = cls.env['account.invoice'] + cls.payment_return_model = cls.env['payment.return'] + cls.partner = cls.env.ref('base.res_partner_1') # Prepare invoice and pay it for making the return - self.invoice = self.env.ref('account.invoice_2') - self.invoice.journal_id.update_posted = True - self.invoice.signal_workflow('invoice_open') - self.receivable_line = self.invoice.move_id.line_id.filtered( + cls.invoice = cls.env.ref('account.invoice_2') + cls.invoice.journal_id.update_posted = True + cls.invoice.signal_workflow('invoice_open') + cls.receivable_line = cls.invoice.move_id.line_id.filtered( lambda x: x.account_id.type == 'receivable') # Invert the move to simulate the payment - self.payment_move = self.invoice.move_id.copy() - for move_line in self.payment_move.line_id: + cls.payment_move = cls.invoice.move_id.copy() + for move_line in cls.payment_move.line_id: debit = move_line.debit move_line.write({'debit': move_line.credit, 'credit': debit}) - self.payment_line = self.payment_move.line_id.filtered( + cls.payment_line = cls.payment_move.line_id.filtered( lambda x: x.account_id.type == 'receivable') # Reconcile both - self.reconcile = self.env['account.move.reconcile'].create( + cls.reconcile = cls.env['account.move.reconcile'].create( {'type': 'manual', - 'line_id': [(4, self.payment_line.id), - (4, self.receivable_line.id)]}) + 'line_id': [(4, cls.payment_line.id), + (4, cls.receivable_line.id)]}) # Create payment return - self.payment_return = self.payment_return_model.create( - {'journal_id': self.env.ref('account.bank_journal').id, + cls.payment_return = cls.payment_return_model.create( + {'journal_id': cls.env.ref('account.bank_journal').id, 'line_ids': [ - (0, 0, {'partner_id': self.partner.id, - 'move_line_ids': [(6, 0, self.payment_line.ids)], - 'amount': self.payment_line.credit})]}) - self.payment_return.journal_id.update_posted = True + (0, 0, {'partner_id': cls.partner.id, + 'move_line_ids': [(6, 0, cls.payment_line.ids)], + 'amount': cls.payment_line.credit})]}) + cls.payment_return.journal_id.update_posted = True def test_confirm_error(self): self.payment_return.line_ids[0].move_line_ids = False @@ -63,11 +63,14 @@ def test_payment_return(self): self.assertEqual(self.invoice.residual, self.receivable_line.debit) self.assertEqual( len(self.receivable_line.reconcile_partial_id.line_partial_ids), 3) + with self.assertRaises(UserError): + self.payment_return.unlink() self.payment_return.action_cancel() self.assertEqual(self.payment_return.state, 'cancelled') self.assertEqual(self.invoice.state, 'paid') self.payment_return.action_draft() self.assertEqual(self.payment_return.state, 'draft') + self.payment_return.unlink() def test_payment_partial_return(self): self.payment_return.line_ids[0].amount = 5.0