Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] account_payment_order_transfer_journal #1108

9 changes: 6 additions & 3 deletions account_banking_pain_base/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_account_config_settings" model="ir.ui.view">
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">pain.group.on.account.config.settings</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form" />
<field
name="inherit_id"
ref="account_payment_order.res_config_settings_view_form"
/>
<field name="arch" type="xml">
<xpath expr="//div[@id='analytic']" position="after">
<xpath expr="//div[@id='transfer_journal']" position="after">
<h2>SEPA/PAIN</h2>
<div class="row mt16 o_settings_container" id="pain">
<div class="col-xs-12 col-md-6 o_setting_box">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_account_config_settings" model="ir.ui.view">
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">sepa_direct_debit.account_config_settings.form
</field>
<field name="model">res.config.settings</field>
<field
name="inherit_id"
ref="account_banking_pain_base.view_account_config_settings"
ref="account_banking_pain_base.res_config_settings_view_form"
/>
<field name="arch" type="xml">
<xpath expr="//div[@id='pain']/div/div/div" position="inside">
Expand Down
9 changes: 7 additions & 2 deletions account_payment_order/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Account Payment Order
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0399e2f98f07d9c21c128885229a0263686b56ece85f6c3fdf4f2a61445b62fe
!! source digest: sha256:e63957550e8783d01276210fe7a10bd1a9d70efdd9d245bcd998f61c89322919
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
Expand Down Expand Up @@ -61,7 +61,11 @@ You can create a Debit order via the menu Invoicing/Accounting > Customers > Deb

This module also adds an action *Add to Payment Order* on supplier invoices and *Add to Debit Order* on customer invoices.

You can print a Payment order via the menu Invoicing/Accounting > Vendors > Payment Orders and then select the payment oder to print.
You can print a Payment order via the menu Invoicing/Accounting > Vendors > Payment Orders and then select the payment order to print.

You can set a transfer journal via Accounting Settings or on the Payment Mode.
If there is no transfer journal, the bank journal itself will be used for the journal entry
created when confirming a payment order.

Bug Tracker
===========
Expand Down Expand Up @@ -119,6 +123,7 @@ Contributors

* Ammar Officewala <aofficewala@opensourceintegrators.com>
* Marçal Isern <marsal.isern@qubiq.es>
* Luc De Meyer <luc.demeyer@noviat.com> (https://noviat.com)

Maintainers
~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions account_payment_order/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"data/payment_seq.xml",
"report/print_account_payment_order.xml",
"report/account_payment_order.xml",
"wizard/res_config_settings.xml",
],
"demo": ["demo/payment_demo.xml"],
"installable": True,
Expand Down
1 change: 1 addition & 0 deletions account_payment_order/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
from . import account_payment_method
from . import account_journal
from . import account_payment
from . import res_company
4 changes: 3 additions & 1 deletion account_payment_order/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def _compute_payment_method_line_fields(self):
for pay in self:
if pay.payment_order_id:
pay.available_payment_method_line_ids = (
pay.journal_id._get_available_payment_method_lines(pay.payment_type)
pay.payment_order_id.journal_id._get_available_payment_method_lines(
pay.payment_type
)
)
else:
pay.available_payment_method_line_ids = (
Expand Down
7 changes: 7 additions & 0 deletions account_payment_order/models/account_payment_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,11 @@ def _prepare_account_payment_vals(self):
vals[
"destination_account_id"
] = self.partner_id.property_account_payable_id.id

transfer_journal = (
self.order_id.payment_mode_id.transfer_journal_id
or self.company_id.transfer_journal_id
)
if transfer_journal:
vals["journal_id"] = transfer_journal.id
return vals
6 changes: 6 additions & 0 deletions account_payment_order/models/account_payment_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class AccountPaymentMode(models.Model):
"(other modules can set additional fields to restrict the "
"grouping.)",
)
transfer_journal_id = fields.Many2one(
comodel_name="account.journal",
string="Transfer journal on payment/debit orders",
domain="[('type', '=', 'general')]",
help="Journal to write payment entries when confirming payment/debit orders",
)

@api.onchange("payment_method_id")
def payment_method_id_change(self):
Expand Down
15 changes: 15 additions & 0 deletions account_payment_order/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Noviat
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

transfer_journal_id = fields.Many2one(
comodel_name="account.journal",
string="Transfer journal on payment/debit orders",
domain="[('type', '=', 'general')]",
help="Journal to write payment entries when confirming payment/debit orders",
)
1 change: 1 addition & 0 deletions account_payment_order/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@

* Ammar Officewala <aofficewala@opensourceintegrators.com>
* Marçal Isern <marsal.isern@qubiq.es>
* Luc De Meyer <luc.demeyer@noviat.com> (https://noviat.com)
6 changes: 5 additions & 1 deletion account_payment_order/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ You can create a Debit order via the menu Invoicing/Accounting > Customers > Deb

This module also adds an action *Add to Payment Order* on supplier invoices and *Add to Debit Order* on customer invoices.

You can print a Payment order via the menu Invoicing/Accounting > Vendors > Payment Orders and then select the payment oder to print.
You can print a Payment order via the menu Invoicing/Accounting > Vendors > Payment Orders and then select the payment order to print.

You can set a transfer journal via Accounting Settings or on the Payment Mode.
If there is no transfer journal, the bank journal itself will be used for the journal entry
created when confirming a payment order.
8 changes: 6 additions & 2 deletions account_payment_order/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Account Payment Order</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0399e2f98f07d9c21c128885229a0263686b56ece85f6c3fdf4f2a61445b62fe
!! source digest: sha256:e63957550e8783d01276210fe7a10bd1a9d70efdd9d245bcd998f61c89322919
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/bank-payment/tree/16.0/account_payment_order"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/bank-payment-16-0/bank-payment-16-0-account_payment_order"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/bank-payment&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds support for payment orders and debit orders.</p>
Expand Down Expand Up @@ -406,7 +406,10 @@ <h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
<p>You can create a Payment order via the menu Invoicing/Accounting &gt; Vendors &gt; Payment Orders and then select the move lines to pay.</p>
<p>You can create a Debit order via the menu Invoicing/Accounting &gt; Customers &gt; Debit Orders and then select the move lines to debit.</p>
<p>This module also adds an action <em>Add to Payment Order</em> on supplier invoices and <em>Add to Debit Order</em> on customer invoices.</p>
<p>You can print a Payment order via the menu Invoicing/Accounting &gt; Vendors &gt; Payment Orders and then select the payment oder to print.</p>
<p>You can print a Payment order via the menu Invoicing/Accounting &gt; Vendors &gt; Payment Orders and then select the payment order to print.</p>
<p>You can set a transfer journal via Accounting Settings or on the Payment Mode.
If there is no transfer journal, the bank journal itself will be used for the journal entry
created when confirming a payment order.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
Expand Down Expand Up @@ -464,6 +467,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
</ul>
</li>
<li>Marçal Isern &lt;<a class="reference external" href="mailto:marsal.isern&#64;qubiq.es">marsal.isern&#64;qubiq.es</a>&gt;</li>
<li>Luc De Meyer &lt;<a class="reference external" href="mailto:luc.demeyer&#64;noviat.com">luc.demeyer&#64;noviat.com</a>&gt; (<a class="reference external" href="https://noviat.com">https://noviat.com</a>)</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
1 change: 1 addition & 0 deletions account_payment_order/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from . import test_payment_order_inbound
from . import test_payment_order_outbound
from . import test_account_payment
from . import test_payment_order_transfer_journal
52 changes: 52 additions & 0 deletions account_payment_order/tests/test_payment_order_transfer_journal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2023 Noviat
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import odoo.tests
from odoo import fields

from odoo.addons.account.tests.common import AccountTestInvoicingCommon


@odoo.tests.tagged("post_install", "-at_install")
class TestPaymentOrderTranserJournal(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
today = fields.Date.today()
cls.in_invoice = cls.init_invoice(
"in_invoice", invoice_date=today, products=cls.product_a
)
cls.bank_journal = cls.company_data["default_journal_bank"]
cls.misc_journal = cls.company_data["default_journal_misc"]
cls.payment_mode = cls.env["account.payment.mode"].create(
{
"name": "Test Credit Transfer to Suppliers",
"company_id": cls.env.company.id,
"payment_method_id": cls.env.ref(
"account.account_payment_method_manual_out"
).id,
"fixed_journal_id": cls.bank_journal.id,
"bank_account_link": "fixed",
}
)

def test_payment_order_transfer_journal(self):
self.in_invoice._post()
self.payment_mode.transfer_journal_id = self.misc_journal
ap_aml = self.in_invoice.line_ids.filtered(
lambda r: r.account_type == "liability_payable"
)
payline_vals = {
"move_line_id": ap_aml.id,
"partner_id": self.in_invoice.partner_id.id,
"communication": "F0123",
"amount_currency": -ap_aml.amount_currency,
}
order_vals = {
"payment_type": "outbound",
"payment_mode_id": self.payment_mode.id,
"payment_line_ids": [(0, 0, payline_vals)],
}
order = self.env["account.payment.order"].create(order_vals)
order.draft2open()
self.assertEqual(order.mapped("move_ids.journal_id"), self.misc_journal)
3 changes: 3 additions & 0 deletions account_payment_order/views/account_payment_mode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<field name="payment_type" position="after">
<field name="payment_order_ok" />
</field>
<field name="variable_journal_ids" position="after">
<field name="transfer_journal_id" />
</field>
<group name="main" position="after">
<group
name="payment_order_options"
Expand Down
1 change: 1 addition & 0 deletions account_payment_order/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import account_payment_line_create
from . import account_invoice_payment_line_multi
from . import res_config_settings
12 changes: 12 additions & 0 deletions account_payment_order/wizard/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2023 Noviat
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

transfer_journal_id = fields.Many2one(
related="company_id.transfer_journal_id", readonly=False
)
30 changes: 30 additions & 0 deletions account_payment_order/wizard/res_config_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.payment</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='analytic']" position="after">
<h2>Payment Orders</h2>
<div class="row mt16 o_settings_container" id="transfer_journal">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_right_pane">
<div class="content-group">
<div class="row mt16">
<label
for="transfer_journal_id"
class="col-md-6 o_light_label"
/>
<field name="transfer_journal_id" />
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>

</odoo>
Loading