Skip to content

Commit

Permalink
account_payment_return: Improvements to suite (OCA#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdauden authored and joao-p-marques committed Mar 16, 2021
1 parent 6435154 commit 5b3884e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 39 deletions.
51 changes: 36 additions & 15 deletions account_payment_return/i18n/es.po
Original file line number Diff line number Diff line change
@@ -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 <transbot@odoo-community.org>\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 <carlos@incaser.es>\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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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."
7 changes: 7 additions & 0 deletions account_payment_return/models/payment_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: (
Expand Down
51 changes: 27 additions & 24 deletions account_payment_return/tests/test_payment_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5b3884e

Please sign in to comment.