Skip to content

[14.0][FIX] l10n_br_account_payment_order safe guard mig #3785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
# @author Magno Costa <magno.costa@akretion.com.br>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from openupgradelib import openupgrade

_logger = logging.getLogger(__name__)


def unifying_cnab_codes(env):
# Codigo de Instrução do Movimento
Expand Down Expand Up @@ -104,8 +108,8 @@ def unifying_cnab_codes(env):

# Relação payment_method_ids x return_move_code
payment_method_id_colunm = (
"l10n_br_cnab_mov_instruction_code_id"
) # nome tava errado
"l10n_br_cnab_mov_instruction_code_id" # nome tava errado
)
return_move_code_id_colunm = "payment_method_id"
env.cr.execute(
f"""
Expand All @@ -117,17 +121,24 @@ def unifying_cnab_codes(env):
payment_method_ids = [
payment_method_id[0] for payment_method_id in env.cr.fetchall()
]
env["l10n_br_cnab.code"].create(
{
"name": row[1],
"code": row[2],
"code_type": "return_move_code",
"bank_ids": [(6, 0, bank_ids)],
"payment_method_ids": [(6, 0, payment_method_ids)],
}
)
try:
env["l10n_br_cnab.code"].create(
{
"name": row[1],
"code": row[2],
"code_type": "return_move_code",
"bank_ids": [(6, 0, bank_ids)],
"payment_method_ids": [(6, 0, payment_method_ids)],
}
)
except Exception as e:
_logger.warning(f"Could not create CNAB code {e}")

# Codigo da Carteira
if not openupgrade.table_exists(env.cr, "l10n_br_cnab_boleto_wallet_code"):
_logger.warning("No table l10n_br_cnab_boleto_wallet_code; exiting... ")
return

env.cr.execute(
"""
SELECT lcmic.id, lcmic.name, lcmic.code, lcmic.bank_id, lcmic.payment_method_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
# @author Magno Costa <magno.costa@akretion.com.br>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from openupgradelib import openupgrade

_logger = logging.getLogger(__name__)


def update_payment_mode_inbound(env):
"""Atualiza o Modo de Pagamento"""
Expand Down Expand Up @@ -110,45 +114,48 @@ def update_payment_mode_inbound(env):
cnab_config.liq_return_move_code_ids = [(6, 0, liq_code_ids)]

# Codigos ainda Char
cnab_config.write(
{
"invoice_print": row[13],
"instructions": row[14],
"cnab_company_bank_code": row[15],
"convention_code": row[16],
"condition_issuing_paper": row[17],
"communication_2": row[18],
"boleto_wallet": row[19],
"boleto_modality": row[20],
"boleto_variation": row[21],
"boleto_accept": row[22],
"boleto_species": row[23],
"boleto_protest_code": row[24],
"boleto_days_protest": row[25],
"generate_own_number": row[26],
"own_number_sequence_id": row[27],
"cnab_sequence_id": row[28],
"boleto_interest_code": row[29],
"boleto_interest_perc": row[30],
"boleto_fee_code": row[31],
"boleto_fee_perc": row[32],
"boleto_discount_perc": row[33],
"boleto_byte_idt": row[34],
"boleto_post": row[35],
}
)
try:
cnab_config.write(
{
"invoice_print": row[13],
"instructions": row[14],
"cnab_company_bank_code": row[15],
"convention_code": row[16],
"condition_issuing_paper": row[17],
"communication_2": row[18],
"boleto_wallet": row[19],
"boleto_modality": row[20],
"boleto_variation": row[21],
"boleto_accept": row[22],
"boleto_species": row[23],
"boleto_protest_code": row[24],
"boleto_days_protest": row[25],
"generate_own_number": row[26],
"own_number_sequence_id": row[27],
"cnab_sequence_id": row[28],
"boleto_interest_code": row[29],
"boleto_interest_perc": row[30],
"boleto_fee_code": row[31],
"boleto_fee_perc": row[32],
"boleto_discount_perc": row[33],
"boleto_byte_idt": row[34],
"boleto_post": row[35],
}
)

# Contas Contabeis
account_fields = {
36: "interest_fee_account_id",
37: "discount_account_id",
38: "rebate_account_id",
39: "tariff_charge_account_id",
40: "not_payment_account_id",
}
for index, field in account_fields.items():
if row[index]:
setattr(cnab_config, field, row[index])
# Contas Contabeis
account_fields = {
36: "interest_fee_account_id",
37: "discount_account_id",
38: "rebate_account_id",
39: "tariff_charge_account_id",
40: "not_payment_account_id",
}
for index, field in account_fields.items():
if row[index]:
setattr(cnab_config, field, row[index])
except Exception as e:
_logger.warning(f"Could not write CNAB config: {e}")


def update_payment_mode_outbound(env):
Expand Down