[MIG] account_banking_sepa_direct_debit: Migration to 13.0

This commit is contained in:
Marçal Isern
2020-03-27 07:49:53 +01:00
parent 82a42bd0e2
commit eee740788b
13 changed files with 42 additions and 49 deletions

View File

@@ -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 <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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_banking_sepa_direct_debit%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_banking_sepa_direct_debit%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -122,6 +122,7 @@ Contributors
* Sandy Carter
* Antonio Espinosa <antonioea@antiun.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>
* Marçal Isern <marsal.isern@qubiq.es>
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 <https://github.com/OCA/bank-payment/tree/12.0/account_banking_sepa_direct_debit>`_ project on GitHub.
This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/13.0/account_banking_sepa_direct_debit>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -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",

View File

@@ -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(

View File

@@ -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

View File

@@ -1,7 +1,7 @@
# Copyright 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# 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 [

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -6,3 +6,4 @@
* Sandy Carter
* Antonio Espinosa <antonioea@antiun.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>
* Marçal Isern <marsal.isern@qubiq.es>

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" 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" href="https://github.com/OCA/bank-payment/tree/12.0/account_banking_sepa_direct_debit"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-payment-12-0/bank-payment-12-0-account_banking_sepa_direct_debit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/173/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" 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" href="https://github.com/OCA/bank-payment/tree/13.0/account_banking_sepa_direct_debit"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-payment-13-0/bank-payment-13-0-account_banking_sepa_direct_debit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/173/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Create SEPA files for Direct Debit</p>
<p>Module to export direct debit payment orders in SEPA XML file format.</p>
<p>SEPA PAIN (PAyment INitiation) is the new european standard for
@@ -444,7 +444,7 @@ you created during the configuration step.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-payment/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/bank-payment/issues/new?body=module:%20account_banking_sepa_direct_debit%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/bank-payment/issues/new?body=module:%20account_banking_sepa_direct_debit%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -467,6 +467,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Sandy Carter</li>
<li>Antonio Espinosa &lt;<a class="reference external" href="mailto:antonioea&#64;antiun.com">antonioea&#64;antiun.com</a>&gt;</li>
<li>Sergio Teruel &lt;<a class="reference external" href="mailto:sergio.teruel&#64;tecnativa.com">sergio.teruel&#64;tecnativa.com</a>&gt;</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>
</ul>
</div>
<div class="section" id="maintainers">
@@ -476,7 +477,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-payment/tree/12.0/account_banking_sepa_direct_debit">OCA/bank-payment</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-payment/tree/13.0/account_banking_sepa_direct_debit">OCA/bank-payment</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -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()

View File

@@ -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