diff --git a/account_payment_return/README.rst b/account_payment_return/README.rst index 46b18f5cd63d..fb510b3e1525 100644 --- a/account_payment_return/README.rst +++ b/account_payment_return/README.rst @@ -7,8 +7,8 @@ Returned Customers Payment Orders ================================= This module implements customer receivables returns and allows to send -related reconciled account move lines back to a state where -the debt is still open, and letting history of it. +related reconciled account move lines back to a state where the debt is still +open, and letting history of it. This module can be extended adding importers that automatically fills the full returned payment record. @@ -20,6 +20,10 @@ Go to Accounting > Customers > Customer Payment Returns, and create a new record, register on each line a paid (reconciled) receivable journal item, and input the amount that is going to be returned. +Another option to fill info is setting references and click match button to +find matches with invoices, move lines or moves. This functionality is extended +by other modules as *account_payment_return_import_sepa_pain* + Next, press button "Confirm" to create a new move line that removes the balance from the bank journal and reconcile items together to show payment history through it. @@ -52,9 +56,10 @@ Contributors ------------ * 7 i TRIA * Avanzosc -* Pedro M. Baeza +* Pedro M. Baeza * Markus Schneider -* Sergio Teruel +* Sergio Teruel +* Carlos Dauden Maintainer ---------- diff --git a/account_payment_return/__init__.py b/account_payment_return/__init__.py index e7a68e1715f7..eac9698cdb07 100644 --- a/account_payment_return/__init__.py +++ b/account_payment_return/__init__.py @@ -1,27 +1,9 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (c) 2011-2012 7 i TRIA -# Copyright (c) 2011-2012 Avanzosc -# Copyright (c) 2013 Serv. Tecnol. Avanzados -# Pedro M. Baeza -# Copyright (c) 2014 initOS GmbH & Co. KG -# Markus Schneider -# -# 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 . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2011-2012 7 i TRIA +# © 2011-2012 Avanzosc +# © 2013 Pedro M. Baeza +# © 2014 Markus Schneider +# © 2016 Carlos Dauden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models diff --git a/account_payment_return/__openerp__.py b/account_payment_return/__openerp__.py index 80d42306f3d9..2734ee5557bf 100644 --- a/account_payment_return/__openerp__.py +++ b/account_payment_return/__openerp__.py @@ -1,33 +1,12 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (c) 2011-2012 7 i TRIA -# Copyright (c) 2011-2012 Avanzosc -# Copyright (c) 2013 Serv. Tecnol. Avanzados -# Pedro M. Baeza -# Copyright (c) 2014 initOS GmbH & Co. KG -# Markus Schneider -# Copyright (c) 2015 Incaser Informatica -# Sergio Teruel -# Copyright (c) 2015 Serv. Tecnol. Avanzados -# Pedro M. Baeza -# -# 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 . -# -############################################################################## - +# © 2011-2012 7 i TRIA +# © 2011-2012 Avanzosc +# © 2013 Pedro M. Baeza +# © 2014 Markus Schneider +# © 2015 Sergio Teruel +# © 2015 Pedro M. Baeza +# © 2016 Carlos Dauden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Account Payment Returns", @@ -39,11 +18,10 @@ 'account', ], 'author': '7 i TRIA, ' - 'Serv. Tecnol. Avanzados - Pedro M. Baeza, ' - 'Incaser Informática, ' + 'Tecnativa, ' 'initOS GmbH & Co., ' 'Odoo Community Association (OCA)', - 'website': 'http://www.serviciosbaeza.com', + 'website': 'http://www.tecnativa.com', 'data': [ 'security/ir.model.access.csv', 'security/account_payment_return_security.xml', diff --git a/account_payment_return/i18n/account_payment_return.pot b/account_payment_return/i18n/account_payment_return.pot deleted file mode 100644 index 4e2cddcf4b95..000000000000 --- a/account_payment_return/i18n/account_payment_return.pot +++ /dev/null @@ -1,275 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * account_payment_return -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-02-12 16:33+0000\n" -"PO-Revision-Date: 2015-02-12 16:33+0000\n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: account_payment_return -#: field:payment.return.line,amount:0 -msgid "Amount" -msgstr "" - -#. module: account_payment_return -#: help:payment.return.line,amount:0 -msgid "Returned amount. Can be different from the move amount" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,journal_id:0 -msgid "Bank journal" -msgstr "" - -#. module: account_payment_return -#: view:payment.return:account_payment_return.payment_return_form_view -msgid "Cancel" -msgstr "" - -#. module: account_payment_return -#: selection:payment.return,state:0 -msgid "Cancelled" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,company_id:0 -#: help:payment.return,company_id:0 -msgid "Company" -msgstr "" - -#. module: account_payment_return -#: field:payment.return.line,concept:0 -msgid "Concept" -msgstr "" - -#. module: account_payment_return -#: view:payment.return:account_payment_return.payment_return_form_view -msgid "Confirm" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,create_uid:0 -#: field:payment.return.line,create_uid:0 -msgid "Created by" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,create_date:0 -#: field:payment.return.line,create_date:0 -msgid "Created on" -msgstr "" - -#. module: account_payment_return -#: field:payment.return.line,partner_id:0 -msgid "Customer" -msgstr "" - -#. module: account_payment_return -#: help:payment.return,message_last_post:0 -msgid "Date of the last message posted on the record." -msgstr "" - -#. module: account_payment_return -#: selection:payment.return,state:0 -msgid "Done" -msgstr "" - -#. module: account_payment_return -#: view:payment.return:account_payment_return.payment_return_form_view -#: selection:payment.return,state:0 -msgid "Draft" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,period_id:0 -msgid "Forced period" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,id:0 -#: field:payment.return.line,id:0 -msgid "ID" -msgstr "" - -#. module: account_payment_return -#: selection:payment.return,state:0 -msgid "Imported" -msgstr "" - -#. module: account_payment_return -#: model:ir.model,name:account_payment_return.model_account_invoice -msgid "Invoice" -msgstr "" - -#. module: account_payment_return -#: help:account.invoice,returned_payment:0 -msgid "Invoice has been included on a payment that has been returned later." -msgstr "" - -#. module: account_payment_return -#: view:account.invoice:account_payment_return.view_account_invoice_filter_return -msgid "Invoices whose payment has been returned" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,message_last_post:0 -msgid "Last Message Date" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,write_uid:0 -#: field:payment.return.line,write_uid:0 -msgid "Last Updated by" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,write_date:0 -#: field:payment.return.line,write_date:0 -msgid "Last Updated on" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,line_ids:0 -msgid "Line ids" -msgstr "" - -#. module: account_payment_return -#: view:payment.return:account_payment_return.payment_return_form_view -msgid "Lines" -msgstr "" - -#. module: account_payment_return -#: view:payment.return:account_payment_return.payment_return_form_view -#: field:payment.return,notes:0 -#: field:payment.return.line,notes:0 -msgid "Notes" -msgstr "" - -#. module: account_payment_return -#: field:payment.return.line,partner_name:0 -msgid "Partner name" -msgstr "" - -#. module: account_payment_return -#: field:payment.return.line,move_line_id:0 -msgid "Payment Reference" -msgstr "" - -#. module: account_payment_return -#: model:ir.model,name:account_payment_return.model_payment_return -#: view:payment.return:account_payment_return.payment_return_form_view -#: field:payment.return.line,return_id:0 -msgid "Payment return" -msgstr "" - -#. module: account_payment_return -#: model:ir.model,name:account_payment_return.model_payment_return_line -#: view:payment.return:account_payment_return.payment_return_form_view -msgid "Payment return lines" -msgstr "" - -#. module: account_payment_return -#: field:account.invoice,returned_payment:0 -msgid "Retuned payment" -msgstr "" - -#. module: account_payment_return -#: model:ir.actions.act_window,name:account_payment_return.payment_return_action -#: model:ir.ui.menu,name:account_payment_return.payment_return_menu -#: view:payment.return:account_payment_return.payment_return_tree_view -msgid "Customer Payment Returns" -msgstr "" - -#. module: account_payment_return -#: help:payment.return.line,concept:0 -#: help:payment.return.line,date:0 -#: help:payment.return.line,partner_name:0 -#: help:payment.return.line,reason:0 -msgid "Read from imported file. Only for reference." -msgstr "" - -#. module: account_payment_return -#: field:payment.return.line,reconcile_id:0 -msgid "Reconcile" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,name:0 -msgid "Reference" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,move_id:0 -msgid "Reference to the created journal entry" -msgstr "" - -#. module: account_payment_return -#: help:payment.return.line,reconcile_id:0 -msgid "Reference to the reconcile object." -msgstr "" - -#. module: account_payment_return -#: field:payment.return,date:0 -#: field:payment.return.line,date:0 -msgid "Return date" -msgstr "" - -#. module: account_payment_return -#: field:payment.return.line,reason:0 -msgid "Return reason" -msgstr "" - -#. module: account_payment_return -#: view:account.invoice:account_payment_return.view_account_invoice_filter_return -msgid "Returned" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,state:0 -msgid "State" -msgstr "" - -#. module: account_payment_return -#: model:mail.message.subtype,name:account_payment_return.mt_payment_return_state_change -msgid "Status Change" -msgstr "" - -#. module: account_payment_return -#: model:mail.message.subtype,description:account_payment_return.mt_payment_return_state_change -msgid "Status changed" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,message_summary:0 -msgid "Summary" -msgstr "" - -#. module: account_payment_return -#: help:payment.return,date:0 -msgid "This date will be used as the account entry date." -msgstr "" - -#. module: account_payment_return -#: field:payment.return,message_unread:0 -msgid "Unread Messages" -msgstr "" - -#. module: account_payment_return -#: field:payment.return,website_message_ids:0 -msgid "Website Messages" -msgstr "" - -#. module: account_payment_return -#: help:payment.return,website_message_ids:0 -msgid "Website communication history" -msgstr "" - diff --git a/account_payment_return/i18n/es.po b/account_payment_return/i18n/es.po index 5f519354c206..b30c9796709a 100644 --- a/account_payment_return/i18n/es.po +++ b/account_payment_return/i18n/es.po @@ -1,33 +1,28 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_payment_return +# * account_payment_return # # Sergio Teruel Albert, 2015. msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-02-12 16:35+0000\n" -"PO-Revision-Date: 2015-02-12 17:35+0100\n" -"Last-Translator: Sergio Teruel Albert\n" +"POT-Creation-Date: 2016-04-08 16:31+0000\n" +"PO-Revision-Date: 2016-04-08 18:34+0100\n" +"Last-Translator: Carlos Incaser \n" "Language-Team: Spanish \n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: \n" -"Language: es\n" -"X-Generator: Lokalize 1.4\n" +"X-Generator: Poedit 1.5.4\n" #. module: account_payment_return #: field:payment.return.line,amount:0 msgid "Amount" msgstr "Importe" -#. module: account_payment_return -#: help:payment.return.line,amount:0 -msgid "Returned amount. Can be different from the move amount" -msgstr "Importe devuelto. Puede ser distinto al importe pagado" - #. module: account_payment_return #: field:payment.return,journal_id:0 msgid "Bank journal" @@ -43,9 +38,13 @@ msgstr "Cancelar" msgid "Cancelled" msgstr "Cancelada" +#. module: account_payment_return +#: field:payment.return.reason,code:0 +msgid "Code" +msgstr "Código" + #. module: account_payment_return #: field:payment.return,company_id:0 -#: help:payment.return,company_id:0 msgid "Company" msgstr "Compañía" @@ -60,14 +59,14 @@ msgid "Confirm" msgstr "Confirmar" #. module: account_payment_return -#: field:payment.return,create_uid:0 -#: field:payment.return.line,create_uid:0 +#: field:payment.return,create_uid:0 field:payment.return.line,create_uid:0 +#: field:payment.return.reason,create_uid:0 msgid "Created by" msgstr "Creado por" #. module: account_payment_return -#: field:payment.return,create_date:0 -#: field:payment.return.line,create_date:0 +#: field:payment.return,create_date:0 field:payment.return.line,create_date:0 +#: field:payment.return.reason,create_date:0 msgid "Created on" msgstr "Creado el" @@ -76,6 +75,13 @@ msgstr "Creado el" msgid "Customer" msgstr "Cliente" +#. module: account_payment_return +#: model:ir.actions.act_window,name:account_payment_return.payment_return_action +#: model:ir.ui.menu,name:account_payment_return.payment_return_menu +#: view:payment.return:account_payment_return.payment_return_tree_view +msgid "Customer Payment Returns" +msgstr "Devoluciones de cobros" + #. module: account_payment_return #: help:payment.return,message_last_post:0 msgid "Date of the last message posted on the record." @@ -92,17 +98,34 @@ msgstr "Realizada" msgid "Draft" msgstr "Borrador" +#. module: account_payment_return +#: field:payment.return,message_follower_ids:0 +msgid "Followers" +msgstr "Seguidores" + #. module: account_payment_return #: field:payment.return,period_id:0 msgid "Forced period" msgstr "Periodo forzado" #. module: account_payment_return -#: field:payment.return,id:0 -#: field:payment.return.line,id:0 +#: help:payment.return,message_summary:0 +msgid "" +"Holds the Chatter summary (number of messages, ...). This summary is " +"directly in html format in order to be inserted in kanban views." +msgstr "" + +#. module: account_payment_return +#: field:payment.return,id:0 field:payment.return.line,id:0 +#: field:payment.return.reason,id:0 msgid "ID" msgstr "ID" +#. module: account_payment_return +#: help:payment.return,message_unread:0 +msgid "If checked new messages require your attention." +msgstr "Si esta marcado nuevos mensajes requieren tu atención." + #. module: account_payment_return #: selection:payment.return,state:0 msgid "Imported" @@ -118,25 +141,36 @@ msgstr "Factura" 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:278 +#, python-format +msgid "Invoice: %s" +msgstr "Factura: %s" + #. module: account_payment_return #: view:account.invoice:account_payment_return.view_account_invoice_filter_return msgid "Invoices whose payment has been returned" msgstr "Facturas cuyo pago haya sido devuelto" +#. module: account_payment_return +#: field:payment.return,message_is_follower:0 +msgid "Is a Follower" +msgstr "Es seguidor" + #. module: account_payment_return #: field:payment.return,message_last_post:0 msgid "Last Message Date" msgstr "Fecha del último mensaje" #. module: account_payment_return -#: field:payment.return,write_uid:0 -#: field:payment.return.line,write_uid:0 +#: field:payment.return,write_uid:0 field:payment.return.line,write_uid:0 +#: field:payment.return.reason,write_uid:0 msgid "Last Updated by" msgstr "Última actualización de" #. module: account_payment_return -#: field:payment.return,write_date:0 -#: field:payment.return.line,write_date:0 +#: field:payment.return,write_date:0 field:payment.return.line,write_date:0 +#: field:payment.return.reason,write_date:0 msgid "Last Updated on" msgstr "Última actualización en" @@ -152,10 +186,30 @@ msgstr "Líneas" #. module: account_payment_return #: view:payment.return:account_payment_return.payment_return_form_view -#: field:payment.return,notes:0 -#: field:payment.return.line,notes:0 -msgid "Notes" -msgstr "Notas" +msgid "Match" +msgstr "Casar referencias" + +#. module: account_payment_return +#: field:payment.return,message_ids:0 +msgid "Messages" +msgstr "Mensajes" + +#. module: account_payment_return +#: help:payment.return,message_ids:0 +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:299 +#, python-format +msgid "Move lines: %s" +msgstr "Apuntes: %s" + +#. module: account_payment_return +#: code:addons/account_payment_return/models/payment_return.py:322 +#, python-format +msgid "Move: %s" +msgstr "Asiento: %s" #. module: account_payment_return #: field:payment.return.line,partner_name:0 @@ -163,9 +217,15 @@ msgid "Partner name" msgstr "Nombre del cliente" #. module: account_payment_return -#: field:payment.return.line,move_line_id:0 +#: code:addons/account_payment_return/models/payment_return.py:68 +#, fuzzy, python-format +msgid "Payment Line: %s (%s) in Payment Return: %s" +msgstr "Linea de cobro: %s en Devolución de cobro: %s" + +#. module: account_payment_return +#: field:payment.return.line,move_line_ids:0 msgid "Payment Reference" -msgstr "Referencia de pago" +msgstr "Referencia de cobro" #. module: account_payment_return #: model:ir.model,name:account_payment_return.model_payment_return @@ -181,35 +241,41 @@ msgid "Payment return lines" msgstr "Líneas de la devolución" #. module: account_payment_return -#: field:account.invoice,returned_payment:0 -msgid "Returned payment" -msgstr "Pago devuelto" +#: model:ir.model,name:account_payment_return.model_payment_return_reason +msgid "Payment return reason" +msgstr "Motivos de devolución" #. module: account_payment_return -#: model:ir.actions.act_window,name:account_payment_return.payment_return_action -#: model:ir.ui.menu,name:account_payment_return.payment_return_menu -#: view:payment.return:account_payment_return.payment_return_tree_view -msgid "Customer Payment Returns" -msgstr "Devoluciones de cobros" +#: field:account.invoice,returned_payment:0 +msgid "Payment returned" +msgstr "Devolución de cobro" #. module: account_payment_return -#: help:payment.return.line,concept:0 -#: help:payment.return.line,date:0 +#: help:payment.return.line,concept:0 help:payment.return.line,date:0 #: help:payment.return.line,partner_name:0 -#: help:payment.return.line,reason:0 msgid "Read from imported file. Only for reference." msgstr "Leído del archivo importado. Sólo como referencia." +#. module: account_payment_return +#: field:payment.return.reason,name:0 +msgid "Reason" +msgstr "Motivo" + #. module: account_payment_return #: field:payment.return.line,reconcile_id:0 msgid "Reconcile" msgstr "Conciliación" #. module: account_payment_return -#: field:payment.return,name:0 +#: field:payment.return,name:0 field:payment.return.line,reference:0 msgid "Reference" msgstr "Referencia" +#. module: account_payment_return +#: help:payment.return.line,reference:0 +msgid "Reference to match moves from related documents" +msgstr "Referencia a los asientos coincidentes desde documentos relacionados" + #. module: account_payment_return #: field:payment.return,move_id:0 msgid "Reference to the created journal entry" @@ -221,8 +287,14 @@ msgid "Reference to the reconcile object." msgstr "Referencia al objeto de conciliación." #. module: account_payment_return -#: field:payment.return,date:0 -#: field:payment.return.line,date:0 +#: code:addons/account_payment_return/models/payment_return.py:111 +#: code:addons/account_payment_return/models/payment_return.py:130 +#, python-format +msgid "Return %s" +msgstr "Devolución %s" + +#. module: account_payment_return +#: field:payment.return,date:0 field:payment.return.line,date:0 msgid "Return date" msgstr "Fecha de devolución" @@ -236,21 +308,16 @@ msgstr "Motivo de la devolución" msgid "Returned" msgstr "Devuelta" +#. module: account_payment_return +#: help:payment.return.line,amount:0 +msgid "Returned amount. Can be different from the move amount" +msgstr "Importe devuelto. Puede ser distinto al importe pagado" + #. module: account_payment_return #: field:payment.return,state:0 msgid "State" msgstr "Estado" -#. module: account_payment_return -#: model:mail.message.subtype,name:account_payment_return.mt_payment_return_state_change -msgid "Status Change" -msgstr "Cambio de estado" - -#. module: account_payment_return -#: model:mail.message.subtype,description:account_payment_return.mt_payment_return_state_change -msgid "Status changed" -msgstr "Estado cambiado" - #. module: account_payment_return #: field:payment.return,message_summary:0 msgid "Summary" @@ -267,13 +334,26 @@ msgid "Unread Messages" msgstr "Mensajes sin leer" #. module: account_payment_return -#: field:payment.return,website_message_ids:0 -msgid "Website Messages" -msgstr "Mensajes del sitio web" +#: code:addons/account_payment_return/models/payment_return.py:107 +#: code:addons/account_payment_return/models/payment_return.py:125 +#, python-format +msgid "You must input all moves references in the payment return." +msgstr "Debes informar todas las referencias de cobro." -#. module: account_payment_return -#: help:payment.return,website_message_ids:0 -msgid "Website communication history" -msgstr "Historial de comunicación del sitio web" +#~ msgid "Website Messages" +#~ msgstr "Mensajes del sitio web" + +#~ msgid "Website communication history" +#~ msgstr "Historial de comunicación del sitio web" + +#~ msgid "Notes" +#~ msgstr "Notas" + +#~ msgid "Returned payment" +#~ msgstr "Pago devuelto" +#~ msgid "Status Change" +#~ msgstr "Cambio de estado" +#~ msgid "Status changed" +#~ msgstr "Estado cambiado" diff --git a/account_payment_return/models/__init__.py b/account_payment_return/models/__init__.py index 9689c6f5c974..9abf67178f43 100644 --- a/account_payment_return/models/__init__.py +++ b/account_payment_return/models/__init__.py @@ -1,28 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (c) 2011-2012 7 i TRIA -# Copyright (c) 2011-2012 Avanzosc -# Copyright (c) 2013 Serv. Tecnol. Avanzados -# Pedro M. Baeza -# Copyright (c) 2014 initOS GmbH & Co. KG -# Markus Schneider -# -# 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 . -# -############################################################################## +# © 2011-2012 7 i TRIA +# © 2011-2012 Avanzosc +# © 2013 Pedro M. Baeza +# © 2014 Markus Schneider +# © 2016 Carlos Dauden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import payment_return from . import account_invoice +from . import payment_return_reason diff --git a/account_payment_return/models/account_invoice.py b/account_payment_return/models/account_invoice.py index 0bcede89b656..58211d0bf3d4 100644 --- a/account_payment_return/models/account_invoice.py +++ b/account_payment_return/models/account_invoice.py @@ -1,26 +1,8 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (c) 2013 Serv. Tecnol. Avanzados -# Pedro M. Baeza -# Copyright (c) 2014 initOS GmbH & Co. KG -# Markus Schneider -# -# 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 . -# -############################################################################## +# © 2013 Pedro M. Baeza +# © 2014 Markus Schneider +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from openerp import models, fields diff --git a/account_payment_return/models/payment_return.py b/account_payment_return/models/payment_return.py index b4e6e9c0bd72..c474a12d6882 100644 --- a/account_payment_return/models/payment_return.py +++ b/account_payment_return/models/payment_return.py @@ -1,28 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (c) 2011-2012 7 i TRIA -# Copyright (c) 2011-2012 Avanzosc -# Copyright (c) 2013 Serv. Tecnol. Avanzados -# Pedro M. Baeza -# Copyright (c) 2014 initOS GmbH & Co. KG -# Markus Schneider -# -# 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 . -# -############################################################################## +# © 2011-2012 7 i TRIA +# © 2011-2012 Avanzosc +# © 2013 Pedro M. Baeza +# © 2014 Markus Schneider +# © 2016 Carlos Dauden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from openerp import models, fields, api, _ from openerp.exceptions import Warning as UserError import openerp.addons.decimal_precision as dp @@ -77,21 +60,68 @@ class PaymentReturn(models.Model): string='State', readonly=True, default='draft', track_visibility='onchange') + @api.multi + @api.constrains('line_ids') + def _check_duplicate_move_line(self): + def append_error(error_line): + error_list.append( + _("Payment Line: %s (%s) in Payment Return: %s") % ( + ', '.join(error_line.mapped('move_line_ids.name')), + error_line.partner_id.name, + error_line.return_id.name + ) + ) + error_list = [] + all_move_lines = self.env['account.move.line'] + for line in self.mapped('line_ids'): + for move_line in line.move_line_ids: + if move_line in all_move_lines: + append_error(line) + all_move_lines |= move_line + if (not error_list) and all_move_lines: + duplicate_lines = self.env['payment.return.line'].search([ + ('move_line_ids', 'in', all_move_lines.ids), + ('return_id.state', '=', 'done'), + ]) + if duplicate_lines: + for line in duplicate_lines: + append_error(line) + if error_list: + raise UserError( + "Payment reference must be unique!\n" + "%s" % '\n'.join(error_list) + ) + def _get_invoices(self, move_lines): - invoice_moves = self.env['account.move'] - for invoice_move_line in move_lines.filtered('debit'): - invoice_moves += invoice_move_line.move_id + invoice_moves = move_lines.filtered('debit').mapped('move_id') invoices = self.env['account.invoice'].search( [('move_id', 'in', invoice_moves.ids)]) return invoices - @api.one + def _get_move_amount(self, return_line, move_line): + return return_line.amount + + def _prepare_invoice_returned_vals(self): + return {'returned_payment': True} + + def _prepare_invoice_returned_cancel_vals(self): + return {'returned_payment': False} + + @api.multi + def button_match(self): + self.mapped('line_ids').filtered(lambda x: ( + (not x.move_line_ids) and x.reference))._find_match() + self._check_duplicate_move_line() + + @api.multi def action_confirm(self): + self.ensure_one() # Check for incomplete lines - if any(not x.move_line_id for x in self.line_ids): + if self.line_ids.filtered(lambda x: not x.move_line_ids): raise UserError( _("You must input all moves references in the payment " "return.")) + invoices_returned = self.env['account.invoice'] move = { 'name': '/', 'ref': _('Return %s') % self.name, @@ -103,38 +133,41 @@ def action_confirm(self): } move_id = self.env['account.move'].create(move) for return_line in self.line_ids: - move_line = return_line.move_line_id - old_reconcile = move_line.reconcile_id - lines2reconcile = old_reconcile.line_id - invoices = self._get_invoices(lines2reconcile) - move_line2 = move_line.copy( - default={ - 'move_id': move_id.id, - 'debit': return_line.amount, - 'name': move['ref'], - 'credit': 0, - }) - lines2reconcile += move_line2 - move_line2.copy( - default={ - 'debit': 0, - 'credit': return_line.amount, - 'account_id': self.journal_id.default_credit_account_id.id, - }) - # Break old reconcile and - # make a new one with at least three moves - old_reconcile.unlink() + lines2reconcile = return_line.move_line_ids.mapped( + 'reconcile_id.line_id') + invoices_returned |= self._get_invoices(lines2reconcile) + for move_line in return_line.move_line_ids: + move_amount = self._get_move_amount(return_line, move_line) + move_line2 = move_line.copy( + default={ + 'move_id': move_id.id, + 'debit': move_amount, + 'name': move['ref'], + 'credit': 0, + }) + lines2reconcile |= move_line2 + move_line2.copy( + default={ + 'debit': 0, + 'credit': move_amount, + 'account_id': + self.journal_id.default_credit_account_id.id, + }) + # Break old reconcile + move_line.reconcile_id.unlink() + # Make a new one with at least three moves lines2reconcile.reconcile_partial() return_line.write( {'reconcile_id': move_line2.reconcile_partial_id.id}) - # Mark invoice as payment refused - invoices.write({'returned_payment': True}) + # Mark invoice as payment refused + invoices_returned.write(self._prepare_invoice_returned_vals()) move_id.button_validate() self.write({'state': 'done', 'move_id': move_id.id}) return True - @api.one + @api.multi def action_cancel(self): + self.ensure_one() if not self.move_id: return True for return_line in self.line_ids: @@ -148,8 +181,8 @@ def action_cancel(self): if lines2reconcile: lines2reconcile.reconcile() return_line.write({'reconcile_id': False}) - # Remove payment refused flag on invoice - invoices.write({'returned_payment': False}) + # Remove payment refused flag on invoice + invoices.write(self._prepare_invoice_returned_cancel_vals()) self.move_id.button_cancel() self.move_id.unlink() self.write({'state': 'cancelled', 'move_id': False}) @@ -171,10 +204,14 @@ class PaymentReturnLine(models.Model): concept = fields.Char( string='Concept', help="Read from imported file. Only for reference.") - reason = fields.Char( - string='Return reason', readonly=True, - help="Read from imported file. Only for reference.") - move_line_id = fields.Many2one( + reason = fields.Many2one( + comodel_name='payment.return.reason', + string='Return reason', + ) + reference = fields.Char( + string='Reference', + help="Reference to match moves from related documents") + move_line_ids = fields.Many2many( comodel_name='account.move.line', string='Payment Reference') date = fields.Date( string='Return date', readonly=True, @@ -194,6 +231,99 @@ class PaymentReturnLine(models.Model): comodel_name='account.move.reconcile', string='Reconcile', help="Reference to the reconcile object.") - @api.onchange('move_line_id') - def onchange_move_line(self): - self.amount = self.move_line_id.credit + @api.multi + def _compute_amount(self): + for line in self: + line.amount = sum(line.move_line_ids.mapped('credit')) + + @api.multi + def _get_partner_from_move(self): + for line in self.filtered(lambda x: not x.partner_id): + partners = line.move_line_ids.mapped('partner_id') + if len(partners) > 1: + raise UserError( + "All payments must be owned by the same partner") + line.partner_id = partners[:1].id + line.partner_name = partners[:1].name + + @api.onchange('move_line_ids') + def _onchange_move_line(self): + self._compute_amount() + + @api.multi + def match_invoice(self): + for line in self: + if line.partner_id: + domain = [('partner_id', '=', line.partner_id.id)] + else: + domain = [] + domain.append(('number', '=', line.reference)) + invoice = self.env['account.invoice'].search(domain) + if invoice: + payments = invoice.payment_ids.filtered( + lambda x: x.credit > 0.0) + if payments: + line.move_line_ids = payments[0].ids + if not line.concept: + line.concept = _('Invoice: %s') % invoice.number + + @api.multi + def match_move_lines(self): + for line in self: + if line.partner_id: + domain = [('partner_id', '=', line.partner_id.id)] + else: + domain = [] + domain += [ + ('account_id.type', '=', 'receivable'), + ('credit', '>', 0.0), + ('reconcile_ref', '!=', False), + '|', + ('name', '=', line.reference), + ('ref', '=', line.reference), + ] + move_lines = self.env['account.move.line'].search(domain) + if move_lines: + line.move_line_ids = move_lines.ids + if not line.concept: + line.concept = (_('Move lines: %s') % + ', '.join(move_lines.mapped('name'))) + + @api.multi + def match_move(self): + for line in self: + if line.partner_id: + domain = [('partner_id', '=', line.partner_id.id)] + else: + domain = [] + domain.append(('name', '=', line.reference)) + move = self.env['account.move'].search(domain) + if move: + if len(move) > 1: + raise UserError( + "More than one matches to move reference: %s" % + self.reference) + line.move_line_ids = move.line_id.filtered(lambda l: ( + l.account_id.type == 'receivable' and + l.credit > 0 and + l.reconcile_ref + )).ids + if not line.concept: + line.concept = _('Move: %s') % move.ref + + @api.multi + def _find_match(self): + # we filter again to remove all ready matched lines in inheritance + lines2match = self.filtered(lambda x: ( + (not x.move_line_ids) and x.reference)) + lines2match.match_invoice() + + lines2match = lines2match.filtered(lambda x: ( + (not x.move_line_ids) and x.reference)) + lines2match.match_move_lines() + + lines2match = lines2match.filtered(lambda x: ( + (not x.move_line_ids) and x.reference)) + lines2match.match_move() + self._get_partner_from_move() + self.filtered(lambda x: not x.amount)._compute_amount() diff --git a/account_payment_return/models/payment_return_reason.py b/account_payment_return/models/payment_return_reason.py new file mode 100644 index 000000000000..0cd851dbf8ca --- /dev/null +++ b/account_payment_return/models/payment_return_reason.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# © 2016 Carlos Dauden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields, api + + +class PaymentReturnReason(models.Model): + _name = "payment.return.reason" + _description = 'Payment return reason' + + code = fields.Char() + name = fields.Char(string='Reason', translate=True) + + @api.model + def name_search(self, name, args=None, operator='ilike', limit=100): + args = args or [] + recs = self.browse() + if name: + recs = self.search([('code', '=', name)] + args, limit=limit) + if not recs: + recs = self.search([('name', operator, name)] + args, limit=limit) + return recs.name_get() diff --git a/account_payment_return/security/ir.model.access.csv b/account_payment_return/security/ir.model.access.csv index 2f7ea7aea56a..ebe938718c78 100644 --- a/account_payment_return/security/ir.model.access.csv +++ b/account_payment_return/security/ir.model.access.csv @@ -1,3 +1,4 @@ -"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_payment_return","payment.return","model_payment_return","account.group_account_invoice",1,1,1,1 -"access_payment_return_line","payment.return.line","model_payment_return_line","account.group_account_invoice",1,1,1,1 +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_payment_return,payment.return,model_payment_return,account.group_account_invoice,1,1,1,1 +access_payment_return_line,payment.return.line,model_payment_return_line,account.group_account_invoice,1,1,1,1 +access_payment_return_reason,payment.return.reason,model_payment_return_reason,account.group_account_invoice,1,1,1,1 diff --git a/account_payment_return/tests/test_payment_return.py b/account_payment_return/tests/test_payment_return.py index fdfa42015783..f9c010796e87 100644 --- a/account_payment_return/tests/test_payment_return.py +++ b/account_payment_return/tests/test_payment_return.py @@ -37,20 +37,20 @@ def setUp(self): {'journal_id': self.env.ref('account.bank_journal').id, 'line_ids': [ (0, 0, {'partner_id': self.partner.id, - 'move_line_id': self.receivable_line.id, - 'amount': self.receivable_line.debit})]}) + 'move_line_ids': [(6, 0, self.payment_line.ids)], + 'amount': self.payment_line.credit})]}) self.payment_return.journal_id.update_posted = True def test_confirm_error(self): - self.payment_return.line_ids[0].move_line_id = False + self.payment_return.line_ids[0].move_line_ids = False with self.assertRaises(UserError): self.payment_return.action_confirm() def test_onchange_move_line(self): with self.env.do_in_onchange(): record = self.env['payment.return.line'].new() - record.move_line_id = self.payment_line.id - record.onchange_move_line() + record.move_line_ids = self.payment_line.ids + record._onchange_move_line() self.assertEqual(record.amount, self.payment_line.credit) def test_payment_return(self): @@ -79,3 +79,40 @@ def test_payment_partial_return(self): len(self.receivable_line.reconcile_partial_id.line_partial_ids), 3) self.payment_return.action_cancel() self.assertEqual(self.invoice.state, 'paid') + + def test_find_match_invoice(self): + self.payment_return.line_ids.write({ + 'partner_id': False, + 'move_line_ids': [(6, 0, [])], + 'amount': 0.0, + 'reference': self.invoice.number, + }) + self.payment_return.button_match() + self.assertAlmostEqual( + self.payment_return.line_ids[0].amount, self.payment_line.credit) + + def test_find_match_move_line(self): + self.payment_line.name = 'test match move line 001' + self.payment_return.line_ids.write({ + 'partner_id': False, + 'move_line_ids': [(6, 0, [])], + 'amount': 0.0, + 'reference': self.payment_line.name, + }) + self.payment_return.button_match() + self.assertEqual(self.payment_return.line_ids[0].partner_id.id, + self.payment_line.partner_id.id) + + def test_find_match_move(self): + self.payment_move.name = 'TESTMOVEXX01' + self.payment_return.write({ + 'line_ids': [ + (0, 0, { + 'partner_id': False, + 'move_line_ids': [(6, 0, [])], + 'amount': 0.0, + 'reference': self.payment_move.name, + })] + }) + with self.assertRaises(UserError): + self.payment_return.button_match() diff --git a/account_payment_return/views/payment_return_view.xml b/account_payment_return/views/payment_return_view.xml index 32f6751692ab..754106429d5e 100644 --- a/account_payment_return/views/payment_return_view.xml +++ b/account_payment_return/views/payment_return_view.xml @@ -9,6 +9,7 @@