Skip to content

Commit

Permalink
[15.0][MIG] l10n_account_banking_ach_direct_debit: Migrate to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkwelltwd committed Jul 17, 2023
1 parent 9159e2d commit 884fa5f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion account_banking_ach_direct_debit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Account Banking ACH Direct Debit",
"summary": "Create ACH files for Direct Debit",
"version": "14.0.1.0.0",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"author": "Thinkwell Designs, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-usa",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class AccountBankingMandate(models.Model):
)
scheme = fields.Selection(
[("CORE", "Basic (CORE)"), ("B2B", "Enterprise (B2B)")],
string="Scheme",
default="CORE",
tracking=True,
)
Expand All @@ -49,8 +48,8 @@ def _check_recurring_type(self):
for mandate in self:
if mandate.type == "recurrent" and not mandate.recurrent_sequence_type:
raise exceptions.ValidationError(
_("The recurrent mandate '%s' must have a sequence type.")
% mandate.unique_mandate_reference
_("The recurrent mandate '%(mandate)s' must have a sequence type.")
% {"mandate": mandate.unique_mandate_reference}
)

@api.depends("unique_mandate_reference", "recurrent_sequence_type")
Expand Down Expand Up @@ -108,8 +107,9 @@ def _achdd_mandate_set_state_to_expired(self):
logger.info(
_(
"The following ACH Mandate IDs have been set to "
"expired: %s" % expired_mandates.ids
"expired: %(mandate)s"
)
% {"mandate": expired_mandates.ids}
)
else:
logger.info(_("0 ACH Mandates had to be set to Expired"))
Expand Down
22 changes: 11 additions & 11 deletions account_banking_ach_direct_debit/models/account_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ def generated2uploaded(self):
mandate = self.env["account.banking.mandate"]
for order in self:
to_expire_mandates = first_mandates = all_mandates = mandate
for bank_line in order.bank_line_ids:
if bank_line.mandate_id in all_mandates:
for payment_line in order.payment_line_ids:
if payment_line.mandate_id in all_mandates:
continue
all_mandates += bank_line.mandate_id
if bank_line.mandate_id.type == "oneoff":
to_expire_mandates += bank_line.mandate_id
elif bank_line.mandate_id.type == "recurrent":
seq_type = bank_line.mandate_id.recurrent_sequence_type
all_mandates += payment_line.mandate_id
if payment_line.mandate_id.type == "oneoff":
to_expire_mandates += payment_line.mandate_id
elif payment_line.mandate_id.type == "recurrent":
seq_type = payment_line.mandate_id.recurrent_sequence_type
if seq_type == "final":
to_expire_mandates += bank_line.mandate_id
to_expire_mandates += payment_line.mandate_id
elif seq_type == "first":
first_mandates += bank_line.mandate_id
first_mandates += payment_line.mandate_id
all_mandates.write({"last_debit_date": order.date_generated})
to_expire_mandates.write({"state": "expired"})
first_mandates.write({"recurrent_sequence_type": "recurring"})
Expand All @@ -51,8 +51,8 @@ def generated2uploaded(self):
"Automatically switched from <b>First</b> to "
"<b>Recurring</b> when the debit order "
"<a href=# data-oe-model=account.payment.order "
"data-oe-id=%d>%s</a> has been marked as uploaded."
"data-oe-id=%(order_id)d>%(name)s</a> has been marked as uploaded."
)
% (order.id, order.name)
% {"order_id": order.id, "name": order.name}
)
return res
17 changes: 8 additions & 9 deletions account_banking_ach_direct_debit/post_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@


def update_bank_journals(cr, registry):
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
journals = env["account.journal"].search([("type", "=", "bank")])
ach_dd = env.ref(
"account_banking_ach_direct_debit.ach_direct_debit",
raise_if_not_found=False,
)
if ach_dd:
journals.write({"inbound_payment_method_ids": [(4, ach_dd.id)]})
env = api.Environment(cr, SUPERUSER_ID, {})
journals = env["account.journal"].search([("type", "=", "bank")])
ach_dd = env.ref(
"account_banking_ach_direct_debit.ach_direct_debit",
raise_if_not_found=False,
)
if ach_dd:
journals.write({"inbound_payment_method_line_ids": [(4, ach_dd.id)]})
return
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# generated from manifests external_dependencies
carta-ach
python-stdnum
6 changes: 6 additions & 0 deletions setup/account_banking_ach_direct_debit/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 884fa5f

Please sign in to comment.