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 Jun 21, 2023
1 parent 5e4a4e2 commit 165508c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion account_banking_ach_base/i18n/account_banking_ach_base.pot
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ msgstr ""
#: code:addons/account_banking_ach_base/models/account_payment_order.py:0
#, python-format
msgid ""
"Missing ACH Direct Debit mandate on the bank payment line with partner "
"Missing ACH Direct Debit mandate on the bank line with partner "
"'%(partner)s' (reference '%(ref)s')."
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions account_banking_ach_base/models/account_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def validate_mandates(self, line):
raise UserError(
_(
"Missing ACH Direct Debit mandate on the "
"bank payment line with partner '%(partner)s' "
"payment line with partner '%(partner)s' "
"(reference '%(ref)s')."
)
% {"partner": line.partner_id.name, "ref": line.name}
Expand Down Expand Up @@ -135,7 +135,7 @@ def generate_ach_file(self):
file_mod=file_mod,
)
entries = []
for line in self.bank_line_ids:
for line in self.payment_line_ids:
if inbound_payment:
self.validate_mandates(line)
self.validate_banking(line)
Expand Down
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 in order.payment_line_ids:
if payment.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.mandate_id
if payment.mandate_id.type == "oneoff":
to_expire_mandates += payment.mandate_id
elif payment.mandate_id.type == "recurrent":
seq_type = payment.mandate_id.recurrent_sequence_type
if seq_type == "final":
to_expire_mandates += bank_line.mandate_id
to_expire_mandates += payment.mandate_id
elif seq_type == "first":
first_mandates += bank_line.mandate_id
first_mandates += payment.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

0 comments on commit 165508c

Please sign in to comment.