From 84c3d7d5d2f785b0e7a7f86d9c6bd18e76e2d4ec Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Sat, 4 Mar 2023 20:12:14 +0100 Subject: [PATCH] [MIG] account_payment_order_grouped_output: Migration to 15.0 --- .../README.rst | 10 +++---- .../__manifest__.py | 2 +- .../models/account_payment_order.py | 30 +++++++++++++------ .../static/description/index.html | 6 ++-- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/account_payment_order_grouped_output/README.rst b/account_payment_order_grouped_output/README.rst index 157587efd..52bc3b37d 100644 --- a/account_payment_order_grouped_output/README.rst +++ b/account_payment_order_grouped_output/README.rst @@ -14,13 +14,13 @@ Account Payment Order - Generate grouped moves :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github - :target: https://github.com/OCA/bank-payment/tree/14.0/account_payment_order_grouped_output + :target: https://github.com/OCA/bank-payment/tree/15.0/account_payment_order_grouped_output :alt: OCA/bank-payment .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/bank-payment-14-0/bank-payment-14-0-account_payment_order_grouped_output + :target: https://translation.odoo-community.org/projects/bank-payment-15-0/bank-payment-15-0-account_payment_order_grouped_output :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/bank-payment&target_branch=14.0 + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/bank-payment&target_branch=15.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -42,7 +42,7 @@ 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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -70,6 +70,6 @@ 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. -This module is part of the `OCA/bank-payment `_ project on GitHub. +This module is part of the `OCA/bank-payment `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_payment_order_grouped_output/__manifest__.py b/account_payment_order_grouped_output/__manifest__.py index 233548200..81550fcca 100644 --- a/account_payment_order_grouped_output/__manifest__.py +++ b/account_payment_order_grouped_output/__manifest__.py @@ -2,7 +2,7 @@ { "name": "Account Payment Order - Generate grouped moves", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV, Therp BV, Tecnativa, Akretion, " "Odoo Community Association (OCA)", diff --git a/account_payment_order_grouped_output/models/account_payment_order.py b/account_payment_order_grouped_output/models/account_payment_order.py index d72835d29..b3f384ce1 100644 --- a/account_payment_order_grouped_output/models/account_payment_order.py +++ b/account_payment_order_grouped_output/models/account_payment_order.py @@ -42,10 +42,11 @@ class AccountPaymentOrder(models.Model): def generated2uploaded(self): """Generate grouped moves if configured that way.""" - super().generated2uploaded() + res = super().generated2uploaded() for order in self: if order.payment_mode_id.generate_move: order.generate_move() + return res def generate_move(self): """Create the moves that pay off the move lines from the payment/debit order.""" @@ -77,11 +78,12 @@ class AccountPaymentOrder(models.Model): def reconcile_grouped_payments(self, move, payments): lines_to_rec = move.line_ids[:-1] for payment in payments: + journal = payment.journal_id lines_to_rec += payment.move_id.line_ids.filtered( lambda x: x.account_id in ( - payment.journal_id.payment_debit_account_id, - payment.journal_id.payment_credit_account_id, + journal._get_journal_inbound_outstanding_payment_accounts() + + journal._get_journal_inbound_outstanding_payment_accounts() ) ) lines_to_rec.reconcile() @@ -113,15 +115,26 @@ class AccountPaymentOrder(models.Model): vals["line_ids"].append((0, 0, trf_ml_vals)) return vals - def _prepare_move_line_partner_account(self, payment): - if self.payment_type == "inbound": - account = payment.journal_id.payment_debit_account_id + def _get_grouped_output_liquidity_account(self, payment): + domain = [ + ("journal_id", "=", self.journal_id.id), + ("payment_method_id", "=", payment.payment_method_id.id), + ("payment_type", "=", self.payment_type), + ] + apml = self.env["account.payment.method.line"].search(domain) + if apml.payment_account_id: + return apml.payment_account_id + elif self.payment_type == "inbound": + return payment.company_id.account_journal_payment_debit_account_id else: - account = payment.journal_id.payment_credit_account_id + return payment.company_id.account_journal_payment_credit_account_id + + def _prepare_move_line_partner_account(self, payment): if self.payment_type == "outbound": name = _("Payment bank line %s") % payment.name else: name = _("Debit bank line %s") % payment.name + account = self._get_grouped_output_liquidity_account(payment) sign = self.payment_type == "inbound" and -1 or 1 amount_company_currency = abs(payment.move_id.line_ids[0].balance) vals = { @@ -144,12 +157,11 @@ class AccountPaymentOrder(models.Model): ): if self.payment_type == "outbound": name = _("Payment order %s") % self.name - account = self.journal_id.payment_credit_account_id else: name = _("Debit order %s") % self.name - account = self.journal_id.payment_debit_account_id partner = self.env["res.partner"] for index, payment in enumerate(payments): + account = self._get_grouped_output_liquidity_account(payment) if index == 0: partner = payment.payment_line_ids[0].partner_id elif payment.payment_line_ids[0].partner_id != partner: diff --git a/account_payment_order_grouped_output/static/description/index.html b/account_payment_order_grouped_output/static/description/index.html index 0ff14a5c9..afeb9a53c 100644 --- a/account_payment_order_grouped_output/static/description/index.html +++ b/account_payment_order_grouped_output/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/bank-payment Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/bank-payment Translate me on Weblate Try me on Runboat

This module adds an option to generate extra grouped moves for the payment orders since the refactoring done to use native Odoo payments.

This serves for easing the reconciliation on bank statements of large payment @@ -388,7 +388,7 @@ orders, handling them as one or several journal entries according payment date.<

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 smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -409,7 +409,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

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.

-

This module is part of the OCA/bank-payment project on GitHub.

+

This module is part of the OCA/bank-payment project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.