mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[ADD] account_payment_order_return (#395)
This commit is contained in:
committed by
Pedro M. Baeza
parent
32e046bab4
commit
4afd597f47
63
account_payment_order_return/README.rst
Normal file
63
account_payment_order_return/README.rst
Normal file
@@ -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
|
||||
<https://github.com/OCA/bank-payment/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 <luis.martinez@tecnativa.com>
|
||||
|
||||
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.
|
||||
4
account_payment_order_return/__init__.py
Normal file
4
account_payment_order_return/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from . import wizard
|
||||
22
account_payment_order_return/__openerp__.py
Normal file
22
account_payment_order_return/__openerp__.py
Normal file
@@ -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,
|
||||
}
|
||||
27
account_payment_order_return/i18n/es.po
Normal file
27
account_payment_order_return/i18n/es.po
Normal file
@@ -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"
|
||||
|
||||
BIN
account_payment_order_return/static/description/icon.png
Normal file
BIN
account_payment_order_return/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
4
account_payment_order_return/tests/__init__.py
Normal file
4
account_payment_order_return/tests/__init__.py
Normal file
@@ -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
|
||||
@@ -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)
|
||||
4
account_payment_order_return/wizard/__init__.py
Normal file
4
account_payment_order_return/wizard/__init__.py
Normal file
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="account_payment_line_create_form" model="ir.ui.view">
|
||||
<field name="inherit_id" ref="account_payment_order.account_payment_line_create_form"/>
|
||||
<field name="model">account.payment.line.create</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="invoice" position="after">
|
||||
<field name="include_returned"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,3 +1,4 @@
|
||||
# list the OCA project dependencies, one per line
|
||||
# add a github url if you need a forked version
|
||||
account-payment https://github.com/OCA/account-payment
|
||||
connector
|
||||
|
||||
Reference in New Issue
Block a user