From e3f82f1fc915218a396ee85e29dba5abc506f932 Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 7 Apr 2022 12:06:29 +0200 Subject: [PATCH] [MIG]account_banking_mandate: Migration to 15.0 [UPD] Update account_banking_mandate.pot [UPD] README.rst --- account_banking_mandate/README.rst | 11 ++--- account_banking_mandate/__manifest__.py | 2 +- .../i18n/account_banking_mandate.pot | 43 +++++-------------- .../migrations/14.0.1.0.0/post-migrate.py | 31 ------------- .../models/account_banking_mandate.py | 4 +- .../models/account_payment_line.py | 26 +++++------ .../models/account_payment_method.py | 1 - account_banking_mandate/models/res_partner.py | 9 ++-- .../readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 7 +-- .../tests/test_invoice_mandate.py | 36 ++++++++++++---- .../views/account_banking_mandate_view.xml | 2 +- 12 files changed, 70 insertions(+), 103 deletions(-) delete mode 100644 account_banking_mandate/migrations/14.0.1.0.0/post-migrate.py diff --git a/account_banking_mandate/README.rst b/account_banking_mandate/README.rst index 5cfc4468b..96258fd7a 100644 --- a/account_banking_mandate/README.rst +++ b/account_banking_mandate/README.rst @@ -14,13 +14,13 @@ Account Banking Mandate :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_banking_mandate + :target: https://github.com/OCA/bank-payment/tree/15.0/account_banking_mandate :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_banking_mandate + :target: https://translation.odoo-community.org/projects/bank-payment-15-0/bank-payment-15-0-account_banking_mandate :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/173/14.0 + :target: https://runbot.odoo-community.org/runbot/173/15.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -58,7 +58,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. @@ -84,6 +84,7 @@ Contributors * Carlos Dauden * Marçal Isern * Andrea Stirpe +* Manuel Regidor Maintainers ~~~~~~~~~~~ @@ -98,6 +99,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_banking_mandate/__manifest__.py b/account_banking_mandate/__manifest__.py index 86fd7697d..9c85add5b 100644 --- a/account_banking_mandate/__manifest__.py +++ b/account_banking_mandate/__manifest__.py @@ -7,7 +7,7 @@ { "name": "Account Banking Mandate", "summary": "Banking mandates", - "version": "14.0.1.2.0", + "version": "15.0.1.0.0", "license": "AGPL-3", "author": "Compassion CH, " "Tecnativa, " diff --git a/account_banking_mandate/i18n/account_banking_mandate.pot b/account_banking_mandate/i18n/account_banking_mandate.pot index 242b5cdd8..1148d87a7 100644 --- a/account_banking_mandate/i18n/account_banking_mandate.pot +++ b/account_banking_mandate/i18n/account_banking_mandate.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -98,7 +98,6 @@ msgstr "" #. module: account_banking_mandate #: model_terms:ir.ui.view,arch_db:account_banking_mandate.view_mandate_form -#: model_terms:ir.ui.view,arch_db:account_banking_mandate.view_mandate_tree msgid "Banking Mandate" msgstr "" @@ -199,13 +198,6 @@ msgstr "" #. module: account_banking_mandate #: model:ir.model.fields,field_description:account_banking_mandate.field_account_banking_mandate__display_name -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_move__display_name -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_move_line__display_name -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_payment_line__display_name -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_payment_method__display_name -#: model:ir.model.fields,field_description:account_banking_mandate.field_bank_payment_line__display_name -#: model:ir.model.fields,field_description:account_banking_mandate.field_res_partner__display_name -#: model:ir.model.fields,field_description:account_banking_mandate.field_res_partner_bank__display_name msgid "Display Name" msgstr "" @@ -233,11 +225,6 @@ msgstr "" msgid "Followers" msgstr "" -#. module: account_banking_mandate -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_banking_mandate__message_channel_ids -msgid "Followers (Channels)" -msgstr "" - #. module: account_banking_mandate #: model:ir.model.fields,field_description:account_banking_mandate.field_account_banking_mandate__message_partner_ids msgid "Followers (Partners)" @@ -264,15 +251,13 @@ msgstr "" msgid "Group By" msgstr "" +#. module: account_banking_mandate +#: model:ir.model.fields,field_description:account_banking_mandate.field_account_banking_mandate__has_message +msgid "Has Message" +msgstr "" + #. module: account_banking_mandate #: model:ir.model.fields,field_description:account_banking_mandate.field_account_banking_mandate__id -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_move__id -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_move_line__id -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_payment_line__id -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_payment_method__id -#: model:ir.model.fields,field_description:account_banking_mandate.field_bank_payment_line__id -#: model:ir.model.fields,field_description:account_banking_mandate.field_res_partner__id -#: model:ir.model.fields,field_description:account_banking_mandate.field_res_partner_bank__id msgid "ID" msgstr "" @@ -315,13 +300,6 @@ msgstr "" #. module: account_banking_mandate #: model:ir.model.fields,field_description:account_banking_mandate.field_account_banking_mandate____last_update -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_move____last_update -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_move_line____last_update -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_payment_line____last_update -#: model:ir.model.fields,field_description:account_banking_mandate.field_account_payment_method____last_update -#: model:ir.model.fields,field_description:account_banking_mandate.field_bank_payment_line____last_update -#: model:ir.model.fields,field_description:account_banking_mandate.field_res_partner____last_update -#: model:ir.model.fields,field_description:account_banking_mandate.field_res_partner_bank____last_update msgid "Last Modified on" msgstr "" @@ -567,16 +545,17 @@ msgstr "" #: code:addons/account_banking_mandate/models/account_payment_line.py:0 #, python-format msgid "" -"The payment line number %s a different company than that of the linked " -"mandate %s)." +"The payment line number {line_number} a different company than that of the " +"linked mandate {mandate})." msgstr "" #. module: account_banking_mandate #: code:addons/account_banking_mandate/models/account_payment_line.py:0 #, python-format msgid "" -"The payment line number %s has the bank account '%s' which is not attached " -"to the mandate '%s' (this mandate is attached to the bank account '%s')." +"The payment line number {line_number} has the bank account " +"'{line_bank_account}' which is not attached to the mandate '{mandate_ref}' " +"(this mandate is attached to the bank account '{mandate_bank_account}')." msgstr "" #. module: account_banking_mandate diff --git a/account_banking_mandate/migrations/14.0.1.0.0/post-migrate.py b/account_banking_mandate/migrations/14.0.1.0.0/post-migrate.py deleted file mode 100644 index 3d52a5778..000000000 --- a/account_banking_mandate/migrations/14.0.1.0.0/post-migrate.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2021 Opener B.V. - Stefan Rijnhart -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -import logging - -from odoo.tools.sql import column_exists - - -def migrate(cr, version): - logger = logging.getLogger( - "odoo.addons.account_banking_mandate.migrations.14.0.1.0.0" - ) - if not column_exists(cr, "account_move_line", "mandate_id"): - logger.warning( - "Column account_move_line.mandate_id not found when " - "populating account_move.mandate_id" - ) - return - logger.info( - "Populating account_move.mandate_id from obsolete " - "account_move_line.mandate_id" - ) - cr.execute( - """ - UPDATE account_move am - SET mandate_id = aml.mandate_id - FROM account_move_line aml - WHERE aml.mandate_id IS NOT NULL - AND am.mandate_id IS NULL - AND am.id=aml.move_id - """ - ) diff --git a/account_banking_mandate/models/account_banking_mandate.py b/account_banking_mandate/models/account_banking_mandate.py index 4cf2f2098..3ea1e5751 100644 --- a/account_banking_mandate/models/account_banking_mandate.py +++ b/account_banking_mandate/models/account_banking_mandate.py @@ -60,9 +60,7 @@ class AccountBankingMandate(models.Model): required=True, default=lambda self: self.env.company, ) - unique_mandate_reference = fields.Char( - string="Unique Mandate Reference", tracking=10, copy=False - ) + unique_mandate_reference = fields.Char(tracking=10, copy=False) signature_date = fields.Date( string="Date of Signature of the Mandate", tracking=50, diff --git a/account_banking_mandate/models/account_payment_line.py b/account_banking_mandate/models/account_payment_line.py index 7acd965c8..92a40b2a7 100644 --- a/account_banking_mandate/models/account_payment_line.py +++ b/account_banking_mandate/models/account_payment_line.py @@ -30,15 +30,16 @@ class AccountPaymentLine(models.Model): ): raise ValidationError( _( - "The payment line number %s has the bank account " - "'%s' which is not attached to the mandate '%s' (this " - "mandate is attached to the bank account '%s')." - ) - % ( - pline.name, - pline.partner_bank_id.acc_number, - pline.mandate_id.unique_mandate_reference, - pline.mandate_id.partner_bank_id.acc_number, + "The payment line number {line_number} has " + "the bank account '{line_bank_account}' which " + "is not attached to the mandate '{mandate_ref}' " + "(this mandate is attached to the bank account " + "'{mandate_bank_account}')." + ).format( + line_number=pline.name, + line_bank_account=pline.partner_bank_id.acc_number, + mandate_ref=pline.mandate_id.unique_mandate_reference, + mandate_bank_account=pline.mandate_id.partner_bank_id.acc_number, ) ) @@ -51,10 +52,11 @@ class AccountPaymentLine(models.Model): ): raise ValidationError( _( - "The payment line number %s a different company than " - "that of the linked mandate %s)." + "The payment line number {line_number} a different " + "company than that of the linked mandate {mandate})." + ).format( + line_number=pline.name, mandate=pline.mandate_id.display_name ) - % (pline.name, pline.mandate_id.display_name) ) def draft2open_payment_line_check(self): diff --git a/account_banking_mandate/models/account_payment_method.py b/account_banking_mandate/models/account_payment_method.py index 26cad8a8d..de57f69ae 100644 --- a/account_banking_mandate/models/account_payment_method.py +++ b/account_banking_mandate/models/account_payment_method.py @@ -8,7 +8,6 @@ class AccountPaymentMethod(models.Model): _inherit = "account.payment.method" mandate_required = fields.Boolean( - string="Mandate Required", help="Activate this option if this payment method requires your " "customer to sign a direct debit mandate with your company.", ) diff --git a/account_banking_mandate/models/res_partner.py b/account_banking_mandate/models/res_partner.py index 4673831cc..92cf18ad0 100644 --- a/account_banking_mandate/models/res_partner.py +++ b/account_banking_mandate/models/res_partner.py @@ -31,11 +31,6 @@ class ResPartner(models.Model): def _compute_valid_mandate_id(self): # Dict for reducing the duplicated searches on parent/child partners company_id = self.env.company.id - if company_id: - company = self.env["res.company"].browse(company_id) - else: - company = self.env.company - mandates_dic = {} for partner in self: commercial_partner_id = partner.commercial_partner_id.id @@ -44,7 +39,9 @@ class ResPartner(models.Model): else: mandates = partner.commercial_partner_id.bank_ids.mapped( "mandate_ids" - ).filtered(lambda x: x.state == "valid" and x.company_id == company) + ).filtered( + lambda x: x.state == "valid" and x.company_id.id == company_id + ) first_valid_mandate_id = mandates[:1].id partner.valid_mandate_id = first_valid_mandate_id mandates_dic[commercial_partner_id] = first_valid_mandate_id diff --git a/account_banking_mandate/readme/CONTRIBUTORS.rst b/account_banking_mandate/readme/CONTRIBUTORS.rst index 32c61ff9f..848ab9aa5 100644 --- a/account_banking_mandate/readme/CONTRIBUTORS.rst +++ b/account_banking_mandate/readme/CONTRIBUTORS.rst @@ -7,3 +7,4 @@ * Carlos Dauden * Marçal Isern * Andrea Stirpe +* Manuel Regidor diff --git a/account_banking_mandate/static/description/index.html b/account_banking_mandate/static/description/index.html index ca199c844..b46bc2871 100644 --- a/account_banking_mandate/static/description/index.html +++ b/account_banking_mandate/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 Runbot

+

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

This module adds a generic model for banking mandates. These mandates can be specialized to fit any banking mandates (such as sepa or lsv).

A banking mandate is attached to a bank account and represents an @@ -404,7 +404,7 @@ account.

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.

@@ -429,6 +429,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
  • Carlos Dauden <carlos.dauden@tecnativa.com>
  • Marçal Isern <marsal.isern@qubiq.es>
  • Andrea Stirpe <a.stirpe@onestein.nl>
  • +
  • Manuel Regidor <manuel.regidor@sygel.es>
  • @@ -438,7 +439,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.

    diff --git a/account_banking_mandate/tests/test_invoice_mandate.py b/account_banking_mandate/tests/test_invoice_mandate.py index f7d302120..aec660c85 100644 --- a/account_banking_mandate/tests/test_invoice_mandate.py +++ b/account_banking_mandate/tests/test_invoice_mandate.py @@ -1,10 +1,14 @@ # Copyright 2017 Creu Blanca # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from unittest.mock import patch + from odoo import fields from odoo.exceptions import UserError from odoo.tests.common import TransactionCase +from odoo.addons.account.models.account_payment_method import AccountPaymentMethod + class TestInvoiceMandate(TransactionCase): def test_post_invoice_01(self): @@ -76,6 +80,7 @@ class TestInvoiceMandate(TransactionCase): "date": fields.Date.today(), "reason": "no reason", "refund_method": "refund", + "journal_id": self.invoice.journal_id.id, } ) ) @@ -117,6 +122,16 @@ class TestInvoiceMandate(TransactionCase): self.assertEqual(invoice.mandate_id, mandate_2) def test_onchange_payment_mode(self): + + Method_get_payment_method_information = ( + AccountPaymentMethod._get_payment_method_information + ) + + def _get_payment_method_information(self): + res = Method_get_payment_method_information(self) + res["test"] = {"mode": "multi", "domain": [("type", "=", "bank")]} + return res + invoice = self.env["account.move"].new( { "partner_id": self.partner.id, @@ -126,14 +141,19 @@ class TestInvoiceMandate(TransactionCase): ) invoice._onchange_partner_id() - pay_method_test = self.env["account.payment.method"].create( - { - "name": "Test", - "code": "test", - "payment_type": "inbound", - "mandate_required": False, - } - ) + with patch.object( + AccountPaymentMethod, + "_get_payment_method_information", + _get_payment_method_information, + ): + pay_method_test = self.env["account.payment.method"].create( + { + "name": "Test", + "code": "test", + "payment_type": "inbound", + "mandate_required": False, + } + ) mode_inbound_acme_2 = self.env["account.payment.mode"].create( { "name": "Inbound Credit ACME Bank 2", diff --git a/account_banking_mandate/views/account_banking_mandate_view.xml b/account_banking_mandate/views/account_banking_mandate_view.xml index c31374da4..820808a21 100644 --- a/account_banking_mandate/views/account_banking_mandate_view.xml +++ b/account_banking_mandate/views/account_banking_mandate_view.xml @@ -114,7 +114,7 @@ view.mandate.tree account.banking.mandate - +