diff --git a/account_payment_order_return/README.rst b/account_payment_order_return/README.rst new file mode 100644 index 000000000..f977cf7ac --- /dev/null +++ b/account_payment_order_return/README.rst @@ -0,0 +1,63 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================ +Account Payment Order Return +============================ + +This module adds a check in the wizard where move lines are imported into +payment order. +This check lets include in selection lines from invoices linked to a +payment return. + +Installation +============ + +This module is auto-installed when you install *account_payment_return* and +*account_payment_order*. + +Usage +===== + +#. Go to Invoicing > Payments > Debit Orders. +#. Create a new record. +#. Click on button "Create Payment Lines fron Journal Items" to open the + wizard. +#. Click on the "Include move lines from returns " check. +#. Fill other options. +#. Click on button "Add All Move Lines". + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/173/9.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ +* Luis M. Ontalba + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/account_payment_order_return/__init__.py b/account_payment_order_return/__init__.py new file mode 100644 index 000000000..50e32ca47 --- /dev/null +++ b/account_payment_order_return/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import wizard diff --git a/account_payment_order_return/__openerp__.py b/account_payment_order_return/__openerp__.py new file mode 100644 index 000000000..d1d99ad0c --- /dev/null +++ b/account_payment_order_return/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - Luis M. Ontalba +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + 'name': 'Account Payment Order Return', + 'version': '9.0.1.0.0', + 'category': 'Banking addons', + 'author': 'Tecnativa, ' + 'Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/bank-payment', + 'depends': [ + 'account_payment_return', + 'account_payment_order', + ], + 'data': [ + 'wizard/account_payment_line_create_view.xml', + ], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': True, +} diff --git a/account_payment_order_return/i18n/es.po b/account_payment_order_return/i18n/es.po new file mode 100644 index 000000000..40cbdf674 --- /dev/null +++ b/account_payment_order_return/i18n/es.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_order_return +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-13 08:31+0000\n" +"PO-Revision-Date: 2017-10-13 08:31+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_order_return +#: model:ir.model.fields,field_description:account_payment_order_return.field_account_payment_line_create_include_returned +msgid "Include move lines from returns" +msgstr "Incluir efectos devueltos" + +#. module: account_payment_order_return +#: model:ir.model,name:account_payment_order_return.model_account_payment_line_create +msgid "Wizard to create payment lines" +msgstr "Asistente para crear lĂ­neas de pago" + diff --git a/account_payment_order_return/static/description/icon.png b/account_payment_order_return/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_payment_order_return/static/description/icon.png differ diff --git a/account_payment_order_return/tests/__init__.py b/account_payment_order_return/tests/__init__.py new file mode 100644 index 000000000..1e2614008 --- /dev/null +++ b/account_payment_order_return/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 + +from . import test_account_payment_order_return diff --git a/account_payment_order_return/tests/test_account_payment_order_return.py b/account_payment_order_return/tests/test_account_payment_order_return.py new file mode 100644 index 000000000..f8bbedc93 --- /dev/null +++ b/account_payment_order_return/tests/test_account_payment_order_return.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - Luis M. Ontalba +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 + +from openerp.tests import common +from openerp import fields + + +class TestAccountPaymentOrderReturn(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestAccountPaymentOrderReturn, cls).setUpClass() + cls.account_type = cls.env['account.account.type'].create({ + 'name': 'Test Account Type'}) + cls.a_receivable = cls.env['account.account'].create({ + 'code': 'TAA', + 'name': 'Test Receivable Account', + 'internal_type': 'receivable', + 'user_type_id': cls.account_type.id, + }) + cls.partner = cls.env['res.partner'].create({ + 'name': 'Test Partner 2', + 'parent_id': False, + }) + cls.journal = cls.env['account.journal'].create({ + 'name': 'Test Journal', + 'type': 'bank', + }) + cls.invoice = cls.env['account.invoice'].create({ + 'name': 'Test Invoice 3', + 'partner_id': cls.partner.id, + 'type': 'out_invoice', + 'journal_id': cls.journal.id, + 'invoice_line_ids': [(0, 0, { + 'account_id': cls.a_receivable.id, + 'name': 'Test line', + 'quantity': 1.0, + 'price_unit': 100.00, + })], + }) + cls.payment_mode = cls.env['account.payment.mode'].create({ + 'name': 'Test payment mode', + 'fixed_journal_id': cls.journal.id, + 'bank_account_link': 'variable', + 'payment_method_id': cls.env.ref( + 'account.account_payment_method_manual_in').id}) + cls.payment_order = cls.env['account.payment.order'].create({ + 'payment_mode_id': cls.payment_mode.id, + 'date_prefered': 'due', + 'payment_type': 'inbound', + }) + + def test_global(self): + self.invoice.signal_workflow('invoice_open') + wizard_o = self.env['account.payment.line.create'] + context = wizard_o._context.copy() + context.update({ + 'active_model': 'account.payment.order', + 'active_id': self.payment_order.id, + }) + wizard = wizard_o.with_context(context).create({ + 'order_id': self.payment_order.id, + 'journal_ids': [(4, self.journal.id)], + 'allow_blocked': True, + 'date_type': 'move', + 'move_date': fields.Date.today(), + 'payment_mode': 'any', + 'invoice': True, + 'include_returned': True, + + }) + wizard.populate() + self.assertTrue(len(wizard.move_line_ids), 1) + self.receivable_line = self.invoice.move_id.line_ids.filtered( + lambda x: x.account_id.internal_type == 'receivable') + # Invert the move to simulate the payment + self.payment_move = self.invoice.move_id.copy({ + 'journal_id': self.journal.id + }) + for move_line in self.payment_move.line_ids: + move_line.with_context(check_move_validity=False).write({ + 'debit': move_line.credit, 'credit': move_line.debit}) + self.payment_line = self.payment_move.line_ids.filtered( + lambda x: x.account_id.internal_type == 'receivable') + # Reconcile both + (self.receivable_line | self.payment_line).reconcile() + # Create payment return + self.payment_return = self.env['payment.return'].create( + {'journal_id': self.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.action_confirm() + wizard.include_returned = False + wizard.populate() + self.assertFalse(wizard.move_line_ids) diff --git a/account_payment_order_return/wizard/__init__.py b/account_payment_order_return/wizard/__init__.py new file mode 100644 index 000000000..88586a32d --- /dev/null +++ b/account_payment_order_return/wizard/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import account_payment_line_create diff --git a/account_payment_order_return/wizard/account_payment_line_create.py b/account_payment_order_return/wizard/account_payment_line_create.py new file mode 100644 index 000000000..4cec05f1d --- /dev/null +++ b/account_payment_order_return/wizard/account_payment_line_create.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - Luis M. Ontalba +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import api, fields, models + + +class AccountPaymentLineCreate(models.TransientModel): + _inherit = 'account.payment.line.create' + + include_returned = fields.Boolean( + string='Include move lines from returns') + + @api.multi + def _prepare_move_line_domain(self): + domain = super(AccountPaymentLineCreate, + self)._prepare_move_line_domain() + if not self.include_returned: + domain.append(('invoice_id.returned_payment', '=', False)) + return domain diff --git a/account_payment_order_return/wizard/account_payment_line_create_view.xml b/account_payment_order_return/wizard/account_payment_line_create_view.xml new file mode 100644 index 000000000..bea4b1df3 --- /dev/null +++ b/account_payment_order_return/wizard/account_payment_line_create_view.xml @@ -0,0 +1,14 @@ + + + + + + account.payment.line.create + + + + + + + +