Skip to content
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

[14.0][REF] l10n_br_account_payment_brcobranca: Resolvendo erros PEP8 validados em versões recentes #3287

Merged
merged 2 commits into from
Aug 16, 2024
Merged
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
2 changes: 2 additions & 0 deletions l10n_br_account_payment_brcobranca/constants/br_cobranca.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from odoo.exceptions import UserError
from odoo.tools import config

TIMEOUT = 300 # seconds

DICT_BRCOBRANCA_CNAB_TYPE = {
"240": "cnab240",
"400": "cnab400",
Expand Down
9 changes: 7 additions & 2 deletions l10n_br_account_payment_brcobranca/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from odoo import _, models
from odoo.exceptions import UserError

from ..constants.br_cobranca import get_brcobranca_api_url
from ..constants.br_cobranca import TIMEOUT, get_brcobranca_api_url

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -71,7 +71,12 @@
brcobranca_service_url,
self.name,
)
res = requests.post(brcobranca_service_url, data={"type": "pdf"}, files=files)
res = requests.post(

Check warning on line 74 in l10n_br_account_payment_brcobranca/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account_payment_brcobranca/models/account_move.py#L74

Added line #L74 was not covered by tests
brcobranca_service_url,
data={"type": "pdf"},
files=files,
timeout=TIMEOUT,
)

if str(res.status_code)[0] == "2":
pdf_string = res.content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,16 @@ def _prepare_bank_line_santander(self, payment_mode_id, linhas_pagamentos):
def prepare_bank_payment_line(self, bank_name_brcobranca):
payment_mode_id = self.order_id.payment_mode_id
linhas_pagamentos = self._prepare_boleto_line_vals()
try:

# Casos onde o Banco além dos principais campos possui campos
# específicos, dos casos por enquanto mapeados, se estiver vendo
# um caso que está faltando por favor considere fazer um
# PR para ajudar
if hasattr(self, f"_prepare_bank_line_{bank_name_brcobranca.name}"):
bank_method = getattr(
self, f"_prepare_bank_line_{bank_name_brcobranca.name}"
)
if bank_method:
bank_method(payment_mode_id, linhas_pagamentos)
except Exception:
_logger.warning(
f"Error executing method _prepare_bank_line_{bank_name_brcobranca.name}."
"Check the bank name and provided parameters.",
exc_info=True,
)
bank_method(payment_mode_id, linhas_pagamentos)

# Cada Banco pode possuir seus Codigos de Instrução
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from ..constants.br_cobranca import (
DICT_BRCOBRANCA_CNAB_TYPE,
TIMEOUT,
get_brcobranca_api_url,
get_brcobranca_bank,
)
Expand Down Expand Up @@ -146,16 +147,13 @@ def generate_payment_file(self):
"sequencial_remessa": self.file_number,
}

try:
# Casos onde o Banco além dos principais campos possui campos
# específicos, dos casos por enquanto mapeados, se estiver vendo
# um caso que está faltando por favor considere fazer um
# PR para ajudar
if hasattr(self, f"_prepare_remessa_{bank_brcobranca.name}"):
bank_method = getattr(self, f"_prepare_remessa_{bank_brcobranca.name}")
if bank_method:
bank_method(remessa_values, cnab_type)
except Exception:
_logger.warning(
f"Error executing method _prepare_remessa_{bank_brcobranca.name}."
"Check the bank name and provided parameters.",
exc_info=True,
)
bank_method(remessa_values, cnab_type)

remessa = self._get_brcobranca_remessa(
bank_brcobranca, remessa_values, cnab_type
Expand Down Expand Up @@ -185,6 +183,7 @@ def _get_brcobranca_remessa(self, bank_brcobranca, remessa_values, cnab_type):
"bank": bank_brcobranca.name,
},
files=files,
timeout=TIMEOUT,
)

if cnab_type == "240" and "R01" in res.text[242:254]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from odoo.addons.account_move_base_import.parser.file_parser import FileParser

from ..constants.br_cobranca import get_brcobranca_api_url
from ..constants.br_cobranca import TIMEOUT, get_brcobranca_api_url

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -91,6 +91,7 @@ def _get_brcobranca_retorno(self, files):
"bank": bank_name_brcobranca,
},
files=files,
timeout=TIMEOUT,
)

if res.status_code != 201:
Expand Down
Loading