[MIG] account_banking_sepa_direct_debit: Migration to 17.0

This commit is contained in:
JasminSForgeFlow
2024-04-03 11:32:11 +05:30
parent 1e64ef801c
commit 5b3d11fb30
9 changed files with 26 additions and 45 deletions

View File

@@ -7,7 +7,7 @@
{
"name": "Account Banking SEPA Direct Debit",
"summary": "Create SEPA files for Direct Debit",
"version": "16.0.1.2.0",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Akretion, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/bank-payment",

View File

@@ -34,10 +34,10 @@
</p>
</div>
</field>
<field name="report_template" ref="report_sepa_direct_debit_mandate" />
<field
name="report_name"
>{{ (object.unique_mandate_reference or 'SEPA Mandate').replace('/','_') }}</field>
name="report_template_ids"
eval="[(4, ref('account_banking_sepa_direct_debit.report_sepa_direct_debit_mandate'))]"
/>
<field name="lang">{{ object.partner_id.lang }}</field>
<field name="auto_delete" eval="True" />
</record>

View File

@@ -1,11 +0,0 @@
# Copyright 2023 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
sct_method = env.ref("account_banking_sepa_direct_debit.sepa_direct_debit")
sct_method.write({"warn_not_sepa": True})

View File

@@ -107,7 +107,8 @@ class AccountBankingMandate(models.Model):
for mandate in expired_mandates:
mandate.message_post(
body=_(
"Mandate automatically set to expired after %d months without use."
"Mandate automatically set to"
" expired after %d months without use."
)
% NUMBER_OF_UNUSED_MONTHS_BEFORE_EXPIRY
)
@@ -125,7 +126,8 @@ class AccountBankingMandate(models.Model):
return action
def action_mandate_send(self):
"""Opens a wizard to compose an email, with relevant mail template loaded by default"""
"""Opens a wizard to compose an email,
with relevant mail template loaded by default"""
self.ensure_one()
template_id = self.env["ir.model.data"]._xmlid_to_res_id(
"account_banking_sepa_direct_debit.email_template_sepa_mandate",
@@ -133,7 +135,7 @@ class AccountBankingMandate(models.Model):
)
ctx = {
"default_model": "account.banking.mandate",
"default_res_id": self.id,
"default_res_ids": self.ids,
"default_use_template": bool(template_id),
"default_template_id": template_id,
"default_composition_mode": "comment",

View File

@@ -11,7 +11,7 @@ class AccountPaymentLine(models.Model):
def draft2open_payment_line_check(self):
res = super().draft2open_payment_line_check()
sepa_dd_lines = self.filtered(
lambda l: l.order_id.payment_method_id.code == "sepa_direct_debit"
lambda line: line.order_id.payment_method_id.code == "sepa_direct_debit"
)
sepa_dd_lines._check_sepa_direct_debit_ready()
return res

View File

@@ -1,5 +1,6 @@
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import json
from odoo import models
@@ -10,7 +11,7 @@ class MailComposeMessage(models.TransientModel):
def _action_send_mail(self, auto_commit=False):
for wizard in self:
if self.env.context.get("is_sent"):
self.env[wizard.model].sudo().browse(wizard.res_id).is_sent = True
return super(MailComposeMessage, self)._action_send_mail(
auto_commit=auto_commit
)
self.env[wizard.model].sudo().browse(
json.loads(wizard.res_ids)
).is_sent = True
return super()._action_send_mail(auto_commit=auto_commit)

View File

@@ -40,9 +40,7 @@ class TestMandate(TransactionCase):
.browse(email_ctx.get("default_template_id"))
.copy({"auto_delete": False})
)
self.mandate.with_context(**email_ctx).message_post_with_template(
mail_template.id
)
self.mandate.with_context(**email_ctx).message_post_with_source(mail_template)
mail_message = self.mandate.message_ids[0]
self.assertEqual(
self.mandate.partner_id, mail_message.sudo().mail_ids.recipient_ids

View File

@@ -17,7 +17,7 @@
name="action_mandate_send"
type="object"
string="Send by Email"
states="draft"
invisible="state != 'draft'"
class="btn-primary"
/>
<button name="print_report" type="object" string="Print" />
@@ -25,19 +25,17 @@
<field name="partner_id" position="after">
<field
name="scheme"
attrs="{'invisible': [('format', '!=', 'sepa')],
'required': [('format', '=', 'sepa')]}"
invisible="format != 'sepa'"
required="format == 'sepa'"
/>
<field
name="recurrent_sequence_type"
attrs="{'invisible': ['|', ('type', '=', 'oneoff'), ('format', '!=', 'sepa')],
'required': [('type', '=', 'recurrent')]}"
invisible="type == 'oneoff' or format != 'sepa'"
required="type == 'recurrent'"
/>
</field>
<field name="type" position="attributes">
<attribute
name="attrs"
>{'required': [('format', '=', 'sepa')]}</attribute>
<attribute name="required">format == 'sepa'</attribute>
</field>
</field>

View File

@@ -9,17 +9,10 @@
ref="account_banking_pain_base.view_account_config_settings"
/>
<field name="arch" type="xml">
<xpath expr="//div[@id='pain']/div/div/div" position="inside">
<div class="row mt16">
<label
for="sepa_creditor_identifier"
class="col-md-3 o_light_label"
/>
<field
name="sepa_creditor_identifier"
placeholder="Write the ICS of your company"
/>
</div>
<xpath expr="//block[@id='pain']" position="inside">
<setting>
<field name="sepa_creditor_identifier" />
</setting>
</xpath>
</field>
</record>