From eee740788bf4da9a7714c641fac215f2fc6138c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mar=C3=A7al=20Isern?=
Date: Fri, 27 Mar 2020 07:49:53 +0100
Subject: [PATCH] [MIG] account_banking_sepa_direct_debit: Migration to 13.0
---
account_banking_sepa_direct_debit/README.rst | 11 ++---
.../__manifest__.py | 2 +-
.../models/account_banking_mandate.py | 6 +--
.../models/account_payment_line.py | 4 +-
.../models/account_payment_method.py | 3 +-
.../models/account_payment_mode.py | 1 -
.../models/account_payment_order.py | 4 +-
.../models/bank_payment_line.py | 3 +-
.../models/res_company.py | 1 -
.../readme/CONTRIBUTORS.rst | 1 +
.../static/description/index.html | 7 +--
.../tests/test_mandate.py | 4 +-
.../tests/test_sdd.py | 44 ++++++++++---------
13 files changed, 42 insertions(+), 49 deletions(-)
diff --git a/account_banking_sepa_direct_debit/README.rst b/account_banking_sepa_direct_debit/README.rst
index 9e27232fa..fbac9519d 100644
--- a/account_banking_sepa_direct_debit/README.rst
+++ b/account_banking_sepa_direct_debit/README.rst
@@ -14,13 +14,13 @@ Account Banking SEPA Direct Debit
: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/12.0/account_banking_sepa_direct_debit
+ :target: https://github.com/OCA/bank-payment/tree/13.0/account_banking_sepa_direct_debit
: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-12-0/bank-payment-12-0-account_banking_sepa_direct_debit
+ :target: https://translation.odoo-community.org/projects/bank-payment-13-0/bank-payment-13-0-account_banking_sepa_direct_debit
: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/12.0
+ :target: https://runbot.odoo-community.org/runbot/173/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -98,7 +98,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.
@@ -122,6 +122,7 @@ Contributors
* Sandy Carter
* Antonio Espinosa
* Sergio Teruel
+* Marçal Isern
Maintainers
~~~~~~~~~~~
@@ -136,6 +137,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_sepa_direct_debit/__manifest__.py b/account_banking_sepa_direct_debit/__manifest__.py
index a75def61a..4dec981a3 100644
--- a/account_banking_sepa_direct_debit/__manifest__.py
+++ b/account_banking_sepa_direct_debit/__manifest__.py
@@ -6,7 +6,7 @@
{
"name": "Account Banking SEPA Direct Debit",
"summary": "Create SEPA files for Direct Debit",
- "version": "12.0.1.2.0",
+ "version": "13.0.1.0.0",
"license": "AGPL-3",
"author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/bank-payment",
diff --git a/account_banking_sepa_direct_debit/models/account_banking_mandate.py b/account_banking_sepa_direct_debit/models/account_banking_mandate.py
index 888396686..b9e3e0863 100644
--- a/account_banking_sepa_direct_debit/models/account_banking_mandate.py
+++ b/account_banking_sepa_direct_debit/models/account_banking_mandate.py
@@ -40,7 +40,6 @@ class AccountBankingMandate(models.Model):
unique_mandate_reference = fields.Char(size=35) # cf ISO 20022
display_name = fields.Char(compute="_compute_display_name2", store=True)
- @api.multi
@api.constrains("type", "recurrent_sequence_type")
def _check_recurring_type(self):
for mandate in self:
@@ -50,18 +49,16 @@ class AccountBankingMandate(models.Model):
% mandate.unique_mandate_reference
)
- @api.multi
@api.depends("unique_mandate_reference", "recurrent_sequence_type")
def _compute_display_name2(self):
for mandate in self:
if mandate.format == "sepa":
mandate.display_name = "{} ({})".format(
- mandate.unique_mandate_reference, mandate.recurrent_sequence_type,
+ mandate.unique_mandate_reference, mandate.recurrent_sequence_type
)
else:
mandate.display_name = mandate.unique_mandate_reference
- @api.multi
@api.onchange("partner_bank_id")
def mandate_partner_bank_change(self):
for mandate in self:
@@ -84,7 +81,6 @@ class AccountBankingMandate(models.Model):
}
return res
- @api.model
def _sdd_mandate_set_state_to_expired(self):
logger.info("Searching for SDD Mandates that must be set to Expired")
expire_limit_date = datetime.today() + relativedelta(
diff --git a/account_banking_sepa_direct_debit/models/account_payment_line.py b/account_banking_sepa_direct_debit/models/account_payment_line.py
index 769d37cd6..950dfa498 100644
--- a/account_banking_sepa_direct_debit/models/account_payment_line.py
+++ b/account_banking_sepa_direct_debit/models/account_payment_line.py
@@ -1,14 +1,13 @@
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import _, api, models
+from odoo import _, models
from odoo.exceptions import UserError
class AccountPaymentLine(models.Model):
_inherit = "account.payment.line"
- @api.multi
def draft2open_payment_line_check(self):
res = super(AccountPaymentLine, self).draft2open_payment_line_check()
sepa_dd_lines = self.filtered(
@@ -17,7 +16,6 @@ class AccountPaymentLine(models.Model):
sepa_dd_lines._check_sepa_direct_debit_ready()
return res
- @api.multi
def _check_sepa_direct_debit_ready(self):
"""
This method checks whether the payment line(s) are ready to be used
diff --git a/account_banking_sepa_direct_debit/models/account_payment_method.py b/account_banking_sepa_direct_debit/models/account_payment_method.py
index 93fc3d5ea..9086975d1 100644
--- a/account_banking_sepa_direct_debit/models/account_payment_method.py
+++ b/account_banking_sepa_direct_debit/models/account_payment_method.py
@@ -1,7 +1,7 @@
# Copyright 2016 Akretion (Alexis de Lattre )
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from odoo import api, fields, models
+from odoo import fields, models
class AccountPaymentMethod(models.Model):
@@ -16,7 +16,6 @@ class AccountPaymentMethod(models.Model):
]
)
- @api.multi
def get_xsd_file_path(self):
self.ensure_one()
if self.pain_version in [
diff --git a/account_banking_sepa_direct_debit/models/account_payment_mode.py b/account_banking_sepa_direct_debit/models/account_payment_mode.py
index d8744df70..621fa7675 100644
--- a/account_banking_sepa_direct_debit/models/account_payment_mode.py
+++ b/account_banking_sepa_direct_debit/models/account_payment_mode.py
@@ -23,7 +23,6 @@ class AccountPaymentMode(models.Model):
"- a country-specific identifier",
)
- @api.multi
@api.constrains("sepa_creditor_identifier")
def _check_sepa_creditor_identifier(self):
for payment_mode in self:
diff --git a/account_banking_sepa_direct_debit/models/account_payment_order.py b/account_banking_sepa_direct_debit/models/account_payment_order.py
index 7ef5eadba..257014a3e 100644
--- a/account_banking_sepa_direct_debit/models/account_payment_order.py
+++ b/account_banking_sepa_direct_debit/models/account_payment_order.py
@@ -4,14 +4,13 @@
from lxml import etree
-from odoo import _, api, exceptions, fields, models
+from odoo import _, exceptions, fields, models
from odoo.exceptions import UserError
class AccountPaymentOrder(models.Model):
_inherit = "account.payment.order"
- @api.multi
def generate_payment_file(self):
"""Creates the SEPA Direct Debit file. That's the important code !"""
self.ensure_one()
@@ -267,7 +266,6 @@ class AccountPaymentOrder(models.Model):
return self.finalize_sepa_file_creation(xml_root, gen_args)
- @api.multi
def generated2uploaded(self):
"""Write 'last debit date' on mandates
Set mandates from first to recurring
diff --git a/account_banking_sepa_direct_debit/models/bank_payment_line.py b/account_banking_sepa_direct_debit/models/bank_payment_line.py
index fb7646f4c..b1520d304 100644
--- a/account_banking_sepa_direct_debit/models/bank_payment_line.py
+++ b/account_banking_sepa_direct_debit/models/bank_payment_line.py
@@ -1,13 +1,12 @@
# Copyright 2015-2016 Akretion - Alexis de Lattre
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from odoo import api, models
+from odoo import models
class BankPaymentLine(models.Model):
_inherit = "bank.payment.line"
- @api.multi
def move_line_offsetting_account_hashcode(self):
"""
From my experience, even when you ask several direct debits
diff --git a/account_banking_sepa_direct_debit/models/res_company.py b/account_banking_sepa_direct_debit/models/res_company.py
index 346d66df2..d5ab947b4 100644
--- a/account_banking_sepa_direct_debit/models/res_company.py
+++ b/account_banking_sepa_direct_debit/models/res_company.py
@@ -22,7 +22,6 @@ class ResCompany(models.Model):
"identifier",
)
- @api.multi
@api.constrains("sepa_creditor_identifier")
def _check_sepa_creditor_identifier(self):
for company in self:
diff --git a/account_banking_sepa_direct_debit/readme/CONTRIBUTORS.rst b/account_banking_sepa_direct_debit/readme/CONTRIBUTORS.rst
index ec29073b0..0acc21d6f 100644
--- a/account_banking_sepa_direct_debit/readme/CONTRIBUTORS.rst
+++ b/account_banking_sepa_direct_debit/readme/CONTRIBUTORS.rst
@@ -6,3 +6,4 @@
* Sandy Carter
* Antonio Espinosa
* Sergio Teruel
+* Marçal Isern
diff --git a/account_banking_sepa_direct_debit/static/description/index.html b/account_banking_sepa_direct_debit/static/description/index.html
index 6d00ecb15..a9eb45a9b 100644
--- a/account_banking_sepa_direct_debit/static/description/index.html
+++ b/account_banking_sepa_direct_debit/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

Create SEPA files for Direct Debit
Module to export direct debit payment orders in SEPA XML file format.
SEPA PAIN (PAyment INitiation) is the new european standard for
@@ -444,7 +444,7 @@ you created during the configuration step.
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.
@@ -476,7 +477,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_sepa_direct_debit/tests/test_mandate.py b/account_banking_sepa_direct_debit/tests/test_mandate.py
index 61334ad87..ffdd8e611 100644
--- a/account_banking_sepa_direct_debit/tests/test_mandate.py
+++ b/account_banking_sepa_direct_debit/tests/test_mandate.py
@@ -4,13 +4,13 @@
from dateutil.relativedelta import relativedelta
from odoo import fields
-from odoo.exceptions import ValidationError
+from odoo.exceptions import UserError
from odoo.tests.common import TransactionCase
class TestMandate(TransactionCase):
def test_contrains(self):
- with self.assertRaises(ValidationError):
+ with self.assertRaises(UserError):
self.mandate.recurrent_sequence_type = False
self.mandate.type = "recurrent"
self.mandate._check_recurring_type()
diff --git a/account_banking_sepa_direct_debit/tests/test_sdd.py b/account_banking_sepa_direct_debit/tests/test_sdd.py
index 06be52276..97de426d0 100644
--- a/account_banking_sepa_direct_debit/tests/test_sdd.py
+++ b/account_banking_sepa_direct_debit/tests/test_sdd.py
@@ -3,10 +3,10 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import base64
-import time
from lxml import etree
+from odoo import fields
from odoo.tests import common
from odoo.tools import float_compare
@@ -16,7 +16,6 @@ class TestSDD(common.HttpCase):
super(TestSDD, self).setUp()
self.company = self.env["res.company"]
self.account_model = self.env["account.account"]
- self.move_model = self.env["account.move"]
self.journal_model = self.env["account.journal"]
self.payment_order_model = self.env["account.payment.order"]
self.payment_line_model = self.env["account.payment.line"]
@@ -24,8 +23,7 @@ class TestSDD(common.HttpCase):
self.bank_line_model = self.env["bank.payment.line"]
self.partner_bank_model = self.env["res.partner.bank"]
self.attachment_model = self.env["ir.attachment"]
- self.invoice_model = self.env["account.invoice"]
- self.invoice_line_model = self.env["account.invoice.line"]
+ self.invoice_model = self.env["account.move"]
self.partner_agrolait = self.env.ref("base.res_partner_2")
self.partner_c2c = self.env.ref("base.res_partner_12")
self.eur_currency = self.env.ref("base.EUR")
@@ -44,9 +42,11 @@ class TestSDD(common.HttpCase):
)
self.partner_agrolait.company_id = self.main_company.id
self.partner_c2c.company_id = self.main_company.id
+
self.env.ref(
"l10n_generic_coa.configurable_chart_template"
).try_loading_for_current_company()
+
self.account_revenue = self.account_model.search(
[
(
@@ -175,7 +175,7 @@ class TestSDD(common.HttpCase):
0,
)
self.assertEqual(agrolait_pay_line1.communication_type, "normal")
- self.assertEqual(agrolait_pay_line1.communication, invoice1.number)
+ self.assertEqual(agrolait_pay_line1.communication, invoice1.name)
payment_order.draft2open()
self.assertEqual(payment_order.state, "open")
self.assertEqual(payment_order.sepa, True)
@@ -193,7 +193,7 @@ class TestSDD(common.HttpCase):
0,
)
self.assertEqual(agrolait_bank_line.communication_type, "normal")
- self.assertEqual(agrolait_bank_line.communication, invoice1.number)
+ self.assertEqual(agrolait_bank_line.communication, invoice1.name)
self.assertEqual(agrolait_bank_line.mandate_id, invoice1.mandate_id)
self.assertEqual(
agrolait_bank_line.partner_bank_id, invoice1.mandate_id.partner_bank_id
@@ -202,7 +202,7 @@ class TestSDD(common.HttpCase):
self.assertEqual(payment_order.state, "generated")
self.assertEqual(action["res_model"], "ir.attachment")
attachment = self.attachment_model.browse(action["res_id"])
- self.assertEqual(attachment.datas_fname[-4:], ".xml")
+ self.assertEqual(attachment.name[-4:], ".xml")
xml_file = base64.b64decode(attachment.datas)
xml_root = etree.fromstring(xml_file)
namespaces = xml_root.nsmap
@@ -224,32 +224,34 @@ class TestSDD(common.HttpCase):
payment_order.generated2uploaded()
self.assertEqual(payment_order.state, "uploaded")
for inv in [invoice1, invoice2]:
- self.assertEqual(inv.state, "paid")
+ self.assertEqual(inv.invoice_payment_state, "paid")
self.assertEqual(self.mandate2.recurrent_sequence_type, "recurring")
return
def create_invoice(self, partner_id, mandate, price_unit, type="out_invoice"):
+ invoice_vals = [
+ (
+ 0,
+ 0,
+ {
+ "name": "Great service",
+ "quantity": 1,
+ "account_id": self.account_revenue.id,
+ "price_unit": price_unit,
+ },
+ )
+ ]
invoice = self.invoice_model.create(
{
"partner_id": partner_id,
"reference_type": "none",
"currency_id": self.env.ref("base.EUR").id,
- "name": "test",
- "account_id": self.account_receivable.id,
"type": type,
- "date_invoice": time.strftime("%Y-%m-%d"),
+ "date": fields.Date.today(),
"payment_mode_id": self.payment_mode.id,
"mandate_id": mandate.id,
+ "invoice_line_ids": invoice_vals,
}
)
- self.invoice_line_model.create(
- {
- "invoice_id": invoice.id,
- "price_unit": price_unit,
- "quantity": 1,
- "name": "Great service",
- "account_id": self.account_revenue.id,
- }
- )
- invoice.action_invoice_open()
+ invoice.post()
return invoice