diff --git a/.copier-answers.yml b/.copier-answers.yml
index 1ef37e539602..67c739bde40b 100644
--- a/.copier-answers.yml
+++ b/.copier-answers.yml
@@ -1,6 +1,7 @@
# Do NOT update manually; changes here will be overwritten by Copier
-_commit: v1.21.1
+_commit: v1.24
_src_path: gh:oca/oca-addons-repo-template
+additional_ruff_rules: []
ci: GitHub
convert_readme_fragments_to_markdown: false
generate_requirements_txt: true
@@ -26,5 +27,5 @@ repo_name: Odoo Brazilian Localization / Localização brasileira do Odoo
repo_slug: l10n-brazil
repo_website: https://github.com/OCA/l10n-brazil
use_pyproject_toml: false
-use_ruff: false
+use_ruff: true
diff --git a/.gitignore b/.gitignore
index 0090721f5d24..2b045db39953 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,15 @@ var/
*.egg
*.eggs
+# Debian packages
+*.deb
+
+# Redhat packages
+*.rpm
+
+# MacOS packages
+*.dmg
+
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 6df0e4eb7ea3..19036fd1f3b1 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -27,7 +27,7 @@ exclude: |
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
default_language_version:
- python: python3
+ python: python3.11
node: "14.13.0"
repos:
- repo: local
@@ -45,7 +45,7 @@ repos:
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
- rev: 9a170331575a265c092ee6b24b845ec508e8ef75
+ rev: d5fab7ee87fceee858a3d01048c78a548974d935
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
@@ -64,21 +64,6 @@ repos:
hooks:
- id: oca-checks-odoo-module
- id: oca-checks-po
- - repo: https://github.com/myint/autoflake
- rev: v1.4
- hooks:
- - id: autoflake
- args:
- - --expand-star-imports
- - --ignore-init-module-imports
- - --in-place
- - --remove-all-unused-imports
- - --remove-duplicate-keys
- - --remove-unused-variables
- - repo: https://github.com/psf/black
- rev: 22.3.0
- hooks:
- - id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.1.2
hooks:
@@ -125,14 +110,6 @@ repos:
hooks:
- id: pyupgrade
args: ["--keep-percent-format"]
- - repo: https://github.com/PyCQA/isort
- rev: 5.12.0
- hooks:
- - id: isort
- name: isort except __init__.py
- args:
- - --settings=.
- exclude: /__init__\.py$
- repo: https://github.com/acsone/setuptools-odoo
rev: 3.1.8
hooks:
@@ -143,12 +120,12 @@ repos:
- requirements.txt
- --header
- "# generated from manifests external_dependencies"
- - repo: https://github.com/PyCQA/flake8
- rev: 3.8.3
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ rev: v0.1.3
hooks:
- - id: flake8
- name: flake8
- additional_dependencies: ["flake8-bugbear==20.1.4"]
+ - id: ruff
+ args: [--fix, --exit-non-zero-on-fix]
+ - id: ruff-format
- repo: https://github.com/OCA/pylint-odoo
rev: 7.0.2
hooks:
diff --git a/.ruff.toml b/.ruff.toml
new file mode 100644
index 000000000000..ee1e6acb147b
--- /dev/null
+++ b/.ruff.toml
@@ -0,0 +1,30 @@
+
+target-version = "py39"
+
+fix = true
+
+[lint]
+extend-select = [
+ "B",
+ "C90",
+ "E501", # line too long (default 88)
+ "I", # isort
+]
+exclude = ["setup/*"]
+
+[format]
+exclude = ["setup/*"]
+
+[per-file-ignores]
+"__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py
+"__manifest__.py" = ["B018"] # useless expression
+
+[isort]
+section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"]
+
+[isort.sections]
+"odoo" = ["odoo"]
+"odoo-addons" = ["odoo.addons"]
+
+[mccabe]
+max-complexity = 16
diff --git a/.t2d.yml b/.t2d.yml
deleted file mode 100644
index 5e8e3a666b33..000000000000
--- a/.t2d.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-language: python
-cache:
- directories:
- - $HOME/.cache/pip
- - $HOME/.cache/pre-commit
-
-python:
- - "3.6"
-
-addons:
- postgresql: "9.6"
- apt:
- packages:
- - expect-dev # provides unbuffer utility
-
-stages:
- - test
-
-jobs:
- include:
- - stage: test
- env:
- - TESTS=1 ODOO_REPO="odoo/odoo" MAKEPOT="1"
- - stage: test
- env:
- - TESTS=1 ODOO_REPO="OCA/OCB"
-env:
- global:
- - VERSION="14.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0"
- - MQT_DEP=PIP
-
-install:
- - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git
- ${HOME}/maintainer-quality-tools
- - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- - travis_install_nightly
-
-script:
- - travis_run_tests
-
-after_success:
- - travis_after_tests_success
diff --git a/l10n_br_account/models/account_incoterms.py b/l10n_br_account/models/account_incoterms.py
index b87610d50191..17a68599aa58 100644
--- a/l10n_br_account/models/account_incoterms.py
+++ b/l10n_br_account/models/account_incoterms.py
@@ -22,5 +22,5 @@ def name_get(self):
# name completo
if len(record.name) > 150:
name = record.name[:150] + " ..."
- result.append((record.id, "%s - %s" % (record.code, name)))
+ result.append((record.id, f"{record.code} - {name}"))
return result
diff --git a/l10n_br_account/models/account_move.py b/l10n_br_account/models/account_move.py
index 8b2391e77173..5909c4823b69 100644
--- a/l10n_br_account/models/account_move.py
+++ b/l10n_br_account/models/account_move.py
@@ -121,7 +121,8 @@ def _check_fiscal_document_type(self):
if rec.document_type_id and not rec.fiscal_document_id:
raise UserError(
_(
- "You cannot set a document type when the move has no Fiscal Document!"
+ "You cannot set a document type when the move has no Fiscal "
+ "Document!"
)
)
@@ -242,7 +243,8 @@ def fields_view_get(
if invoice_view["fields"].get("line_ids"):
# it is required to inject the fiscal fields in the
- # "accounting lines" view to avoid loosing fiscal values from the form.
+ # "accounting lines" view to avoid loosing fiscal values from the
+ # form.
sub_form_view = invoice_view["fields"]["line_ids"]["views"]["tree"][
"arch"
]
diff --git a/l10n_br_account/models/account_move_line.py b/l10n_br_account/models/account_move_line.py
index 78de34d91950..fa3a53028203 100644
--- a/l10n_br_account/models/account_move_line.py
+++ b/l10n_br_account/models/account_move_line.py
@@ -247,7 +247,8 @@ def create(self, vals_list):
# Initialize the inverted index list with the same length as the original list
inverted_index = [0] * len(original_indexes)
- # Iterate over the original_indexes list and fill the inverted_index list accordingly
+ # Iterate over the original_indexes list and fill the inverted_index list
+ # accordingly
for i, val in enumerate(original_indexes):
inverted_index[val] = i
@@ -257,8 +258,8 @@ def create(self, vals_list):
sorted_result |= result[idx]
for line in sorted_result:
- # Forces the recalculation of price_total and price_subtotal fields which are
- # recalculated by super
+ # Forces the recalculation of price_total and price_subtotal fields which
+ # are recalculated by super
if line.move_id.company_id.country_id.code == "BR":
line.update(line._get_price_total_and_subtotal())
diff --git a/l10n_br_account/models/account_tax.py b/l10n_br_account/models/account_tax.py
index 599200edf851..90aa2a1e3149 100644
--- a/l10n_br_account/models/account_tax.py
+++ b/l10n_br_account/models/account_tax.py
@@ -137,7 +137,9 @@ def compute_all(
account_taxes_by_domain.update({tax.id: tax_domain})
for account_tax in taxes_results["taxes"]:
- tax = self.filtered(lambda t: t.id == account_tax.get("id"))
+ tax = self.filtered(
+ lambda t, account_tax=account_tax: t.id == account_tax.get("id")
+ )
fiscal_tax = fiscal_taxes_results["taxes"].get(
account_taxes_by_domain.get(tax.id)
)
diff --git a/l10n_br_account/models/fiscal_document.py b/l10n_br_account/models/fiscal_document.py
index 9b5a376160cf..f5e5dbc0f24d 100644
--- a/l10n_br_account/models/fiscal_document.py
+++ b/l10n_br_account/models/fiscal_document.py
@@ -123,10 +123,10 @@ def unlink(self):
@api.model_create_multi
def create(self, vals_list):
"""
- It's not allowed to create a fiscal document line without a document_type_id anyway.
- But instead of letting Odoo crash in this case we simply avoid creating the
- record. This makes it possible to create an account.move without
- a fiscal_document_id despite the _inherits system:
+ It's not allowed to create a fiscal document line without a document_type_id
+ anyway. But instead of letting Odoo crash in this case we simply avoid creating
+ the record. This makes it possible to create an account.move without a
+ fiscal_document_id despite the _inherits system:
Odoo will write NULL as the value in this case.
"""
if self._context.get("create_from_move"):
@@ -158,14 +158,14 @@ def cancel_move_ids(self):
def _document_cancel(self, justificative):
result = super()._document_cancel(justificative)
- msg = "Cancelamento: {}".format(justificative)
+ msg = f"Cancelamento: {justificative}"
self.cancel_move_ids()
self.message_post(body=msg)
return result
def _document_correction(self, justificative):
result = super()._document_correction(justificative)
- msg = "Carta de correção: {}".format(justificative)
+ msg = f"Carta de correção: {justificative}"
self.message_post(body=msg)
return result
diff --git a/l10n_br_account/tests/common.py b/l10n_br_account/tests/common.py
index b0677f9c0d7d..9297d04d717d 100644
--- a/l10n_br_account/tests/common.py
+++ b/l10n_br_account/tests/common.py
@@ -289,7 +289,8 @@ def init_invoice(
document_number=None,
):
"""
- We could not override the super one because we need to inject extra BR fiscal fields.
+ We could not override the super one because we need to inject extra BR fiscal
+ fields.
"""
products = [] if products is None else products
amounts = [] if amounts is None else amounts
@@ -364,11 +365,8 @@ def line_log(cls, lines, index):
Utility method to help debugging
"""
lines = cls.sort_lines(lines.sorted())
- log = "LINE %s %s %s %s %s" % (
- index,
- lines[index].name,
- lines[index].debit,
- lines[index].credit,
- lines[index].account_id.name,
+ log = (
+ f"LINE {index} {lines[index].name} {lines[index].debit}"
+ f" {lines[index].credit} {lines[index].account_id.name}"
)
return log
diff --git a/l10n_br_account/tests/test_account_move_lc.py b/l10n_br_account/tests/test_account_move_lc.py
index 17bc3c47d66e..db3715f7ce09 100644
--- a/l10n_br_account/tests/test_account_move_lc.py
+++ b/l10n_br_account/tests/test_account_move_lc.py
@@ -124,7 +124,7 @@ def setup_company_data(cls, company_name, chart_template=None, **kwargs):
icms_regulation_id=cls.env.ref("l10n_br_fiscal.tax_icms_regulation").id,
cnae_main_id=cls.env.ref("l10n_br_fiscal.cnae_3101200").id,
document_type_id=cls.env.ref("l10n_br_fiscal.document_55").id,
- **kwargs
+ **kwargs,
)
res["company"].partner_id.state_id = cls.env.ref("base.state_br_sp").id
res["company"].partner_id.cnpj_cpf = cnpj
diff --git a/l10n_br_account/tests/test_account_move_sn.py b/l10n_br_account/tests/test_account_move_sn.py
index 923be3e2b421..9a886852ce82 100644
--- a/l10n_br_account/tests/test_account_move_sn.py
+++ b/l10n_br_account/tests/test_account_move_sn.py
@@ -71,7 +71,7 @@ def setup_company_data(cls, company_name, chart_template=None, **kwargs):
cnae_main_id=cls.env.ref("l10n_br_fiscal.cnae_3101200").id,
document_type_id=cls.env.ref("l10n_br_fiscal.document_55").id,
annual_revenue=815000.0,
- **kwargs
+ **kwargs,
)
chart_template.load_fiscal_taxes()
return res
diff --git a/l10n_br_account/tests/test_document_date.py b/l10n_br_account/tests/test_document_date.py
index dd30110f19af..429ec220f912 100644
--- a/l10n_br_account/tests/test_document_date.py
+++ b/l10n_br_account/tests/test_document_date.py
@@ -92,7 +92,8 @@ def test_document_date(self):
self.move_id.issuer = DOCUMENT_ISSUER_PARTNER
user_tz = timezone(self.env.user.tz or "UTC")
original_date = datetime.combine(datetime.now().date(), time.min)
- # Convert the original_date to the user's timezone and remove the time for comparison
+ # Convert the original_date to the user's timezone and remove the time for
+ # comparison
original_date_in_user_tz = (
user_tz.localize(original_date).astimezone(UTC).replace(tzinfo=None)
)
@@ -123,7 +124,8 @@ def test_date_in_out(self):
self.move_id.issuer = DOCUMENT_ISSUER_PARTNER
user_tz = timezone(self.env.user.tz or "UTC")
original_date = datetime.combine(datetime.now().date(), time.min)
- # Convert the original_date to the user's timezone and remove the time for comparison
+ # Convert the original_date to the user's timezone and remove the time for
+ # comparison
original_date_in_user_tz = (
user_tz.localize(original_date).astimezone(UTC).replace(tzinfo=None)
)
diff --git a/l10n_br_account/tests/test_multi_localizations_invoice.py b/l10n_br_account/tests/test_multi_localizations_invoice.py
index 7e04e456f62c..84c3c76fd78c 100644
--- a/l10n_br_account/tests/test_multi_localizations_invoice.py
+++ b/l10n_br_account/tests/test_multi_localizations_invoice.py
@@ -8,7 +8,7 @@
_logger = logging.getLogger(__name__)
-# flake8: noqa: B950 - line too long
+# ruff: noqa: E501 - line too long
def addTest(self, test):
"""
This monkey patch is required to avoid triggering all the tests from
@@ -116,13 +116,13 @@ def test_force_out_invoice_line_onchange_cash_rounding_1(self):
def test_force_out_invoice_line_onchange_currency_1(self):
return super().test_out_invoice_line_onchange_currency_1()
- # def test_force_out_invoice_line_tax_fixed_price_include_free_product(self):
- # FIXME
- # return super().test_out_invoice_line_tax_fixed_price_include_free_product()
+ # def test_force_out_invoice_line_tax_fixed_price_include_free_product(self):
+ # FIXME
+ # return super().test_out_invoice_line_tax_fixed_price_include_free_product()
- # def test_force_out_invoice_line_taxes_fixed_price_include_free_product(self):
- # FIXME
- # return super().test_out_invoice_line_taxes_fixed_price_include_free_product()
+ # def test_force_out_invoice_line_taxes_fixed_price_include_free_product(self):
+ # FIXME
+ # return super().test_out_invoice_line_taxes_fixed_price_include_free_product()
def test_force_out_invoice_create_refund(self):
return super().test_out_invoice_create_refund()
diff --git a/l10n_br_account_due_list/models/account_move.py b/l10n_br_account_due_list/models/account_move.py
index 9be32f6ed784..789665a4b01e 100644
--- a/l10n_br_account_due_list/models/account_move.py
+++ b/l10n_br_account_due_list/models/account_move.py
@@ -26,7 +26,7 @@ class AccountInvoice(models.Model):
def _compute_financial(self):
for move in self:
lines = move.line_ids.filtered(
- lambda l: l.account_id.internal_type in ("receivable", "payable")
+ lambda line: line.account_id.internal_type in ("receivable", "payable")
)
move.financial_move_line_ids = lines.sorted()
diff --git a/l10n_br_account_nfe/models/document.py b/l10n_br_account_nfe/models/document.py
index 89de0a6aab79..2e5a70ca15b7 100644
--- a/l10n_br_account_nfe/models/document.py
+++ b/l10n_br_account_nfe/models/document.py
@@ -152,8 +152,8 @@ def _check_fiscal_payment_mode(self):
if not rec.move_ids.payment_mode_id.fiscal_payment_mode:
raise UserError(
_(
- "Payment Mode %(mode)s should have "
- "a Fiscal Payment Mode filled to be used in the Fiscal Document!",
+ "Payment Mode %(mode)s should have a Fiscal Payment Mode"
+ " filled to be used in the Fiscal Document!",
mode=rec.move_ids.payment_mode_id.name,
)
)
diff --git a/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py b/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py
index 219658d01042..0a144e5919c2 100644
--- a/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py
+++ b/l10n_br_account_nfe/tests/test_nfe_generate_tags_cobr_dup_pag.py
@@ -207,7 +207,8 @@ def test_invoice_without_payment_mode(self):
invoice.action_post()
self.assertFalse(
invoice.nfe40_dup,
- "Error field nfe40_dup should not filled when Fiscal Operation are Bonificação.",
+ "Error field nfe40_dup should not filled when Fiscal Operation are "
+ "Bonificação.",
)
for detPag in invoice.nfe40_detPag:
self.assertEqual(
diff --git a/l10n_br_account_payment_brcobranca/models/account_journal.py b/l10n_br_account_payment_brcobranca/models/account_journal.py
index d2faebaadb52..0de07f9ff879 100644
--- a/l10n_br_account_payment_brcobranca/models/account_journal.py
+++ b/l10n_br_account_payment_brcobranca/models/account_journal.py
@@ -229,14 +229,17 @@ def _get_moves(self, parser, result_row_list):
raise
except Exception as e:
error_type, error_value, trbk = sys.exc_info()
- st = "Error: %s\nDescription: %s\nTraceback:" % (
- error_type.__name__,
- error_value,
+ st = (
+ f"Error: {error_type.__name__}\n"
+ f"Description: {error_value}\nTraceback:"
)
st += "".join(traceback.format_tb(trbk, 30))
raise ValidationError(
- _("Statement import error " "The statement cannot be created: %s")
- % st
+ _(
+ "Statement import error "
+ "The statement cannot be created: %(st)s",
+ st=st,
+ )
) from e
return moves
diff --git a/l10n_br_account_payment_brcobranca/models/account_move_line.py b/l10n_br_account_payment_brcobranca/models/account_move_line.py
index 2b44b8a45d75..067bbabcf6ff 100644
--- a/l10n_br_account_payment_brcobranca/models/account_move_line.py
+++ b/l10n_br_account_payment_brcobranca/models/account_move_line.py
@@ -101,16 +101,16 @@ def send_payment(self):
move_line.debit
* ((move_line.payment_mode_id.boleto_interest_perc / 100) / 30),
)
- instrucao_juros = (
- "APÓS VENCIMENTO COBRAR PERCENTUAL"
- + " DE %s %% AO MÊS ( R$ %s AO DIA )"
- % (
- (
- "%.2f" % move_line.payment_mode_id.boleto_interest_perc
- ).replace(".", ","),
- ("%.2f" % valor_juros).replace(".", ","),
+ percentual_formatado = (
+ f"{move_line.payment_mode_id.boleto_interest_perc:.2f}".replace(
+ ".", ","
)
)
+ juros_formatado = f"{valor_juros:.2f}".replace(".", ",")
+ instrucao_juros = (
+ f"APÓS VENCIMENTO COBRAR PERCENTUAL DE {percentual_formatado}%"
+ f" AO MÊS (R${juros_formatado} AO DIA)"
+ )
boleto_cnab_api_data.update(
{
"instrucao3": instrucao_juros,
@@ -122,15 +122,13 @@ def send_payment(self):
valor_multa = move_line.currency_id.round(
move_line.debit * (move_line.payment_mode_id.boleto_fee_perc / 100),
)
+ percentual_formatado = (
+ f"{move_line.payment_mode_id.boleto_fee_perc:.2f}".replace(".", ",")
+ )
+ multa_formatado = f"{valor_multa:.2f}".replace(".", ",")
instrucao_multa = (
- "APÓS VENCIMENTO COBRAR MULTA"
- + " DE %s %% ( R$ %s )"
- % (
- ("%.2f" % move_line.payment_mode_id.boleto_fee_perc).replace(
- ".", ","
- ),
- ("%.2f" % valor_multa).replace(".", ","),
- )
+ f"APÓS VENCIMENTO COBRAR MULTA DE {percentual_formatado}%"
+ f" (R${multa_formatado})"
)
boleto_cnab_api_data.update(
{
@@ -143,14 +141,15 @@ def send_payment(self):
valor_desconto = move_line.currency_id.round(
move_line.debit * (move_line.boleto_discount_perc / 100),
)
+ percentual_formatado = f"{move_line.boleto_discount_perc:.2f}".replace(
+ ".", ","
+ )
+ desconto_formatado = f"{valor_desconto:.2f}".replace(".", ",")
+ vencimento_formatado = move_line.date_maturity.strftime("%d/%m/%Y")
instrucao_desconto_vencimento = (
- "CONCEDER DESCONTO DE" + " %s %% "
- "ATÉ O VENCIMENTO EM %s ( R$ %s )"
- % (
- ("%.2f" % move_line.boleto_discount_perc).replace(".", ","),
- move_line.date_maturity.strftime("%d/%m/%Y"),
- ("%.2f" % valor_desconto).replace(".", ","),
- )
+ f"CONCEDER DESCONTO DE {percentual_formatado}% "
+ f"ATÉ O VENCIMENTO EM {vencimento_formatado} "
+ f"(R${desconto_formatado})"
)
boleto_cnab_api_data.update(
{
diff --git a/l10n_br_account_payment_order/migrations/14.0.3.0.0/post-migration.py b/l10n_br_account_payment_order/migrations/14.0.3.0.0/post-migration.py
index b0e90c7a800f..9ed37ac1730e 100644
--- a/l10n_br_account_payment_order/migrations/14.0.3.0.0/post-migration.py
+++ b/l10n_br_account_payment_order/migrations/14.0.3.0.0/post-migration.py
@@ -36,7 +36,8 @@ def delete_payments_created_from_payment_orders(env):
openupgrade.logged_query(
env.cr,
"""
- DELETE FROM account_payment WHERE payment_order_id IS NOT NULL AND payment_method_id IN
+ DELETE FROM account_payment
+ WHERE payment_order_id IS NOT NULL AND payment_method_id IN
(SELECT id FROM account_payment_method WHERE code IN ('240', '400', '500'));
""",
)
diff --git a/l10n_br_account_payment_order/migrations/14.0.4.0.0/pre-migration.py b/l10n_br_account_payment_order/migrations/14.0.4.0.0/pre-migration.py
index 90b837d05491..cf05d30b7c56 100644
--- a/l10n_br_account_payment_order/migrations/14.0.4.0.0/pre-migration.py
+++ b/l10n_br_account_payment_order/migrations/14.0.4.0.0/pre-migration.py
@@ -14,7 +14,6 @@
@openupgrade.migrate(use_env=True)
def migrate(env, version):
-
# Apagando o objeto bank.payment.line
openupgrade.logged_query(
env.cr,
diff --git a/l10n_br_account_payment_order/models/account_move.py b/l10n_br_account_payment_order/models/account_move.py
index ba533e65dbc7..a1eb6ca91832 100644
--- a/l10n_br_account_payment_order/models/account_move.py
+++ b/l10n_br_account_payment_order/models/account_move.py
@@ -56,9 +56,7 @@ def _target_new_tab(self, attachment_id):
if attachment_id:
return {
"type": "ir.actions.act_url",
- "url": "/web/content/{id}/{nome}".format(
- id=attachment_id.id, nome=attachment_id.name
- ),
+ "url": f"/web/content/{attachment_id.id}/{attachment_id.name}",
"target": "new",
}
diff --git a/l10n_br_account_payment_order/models/account_payment_order.py b/l10n_br_account_payment_order/models/account_payment_order.py
index c186d0d0626c..82ad5720b944 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -227,18 +227,11 @@ def generate_payment_file(self):
def get_file_name(self, cnab_type):
context_today = fields.Date.context_today(self)
+ date = context_today.strftime("%d%m")
+ file_number = self.file_number
if cnab_type == "240":
- return "CB%s%s.REM" % (
- context_today.strftime("%d%m"),
- str(self.file_number),
- )
+ return f"CB{date}{file_number}.REM"
elif cnab_type == "400":
- return "CB%s%02d.REM" % (
- context_today.strftime("%d%m"),
- self.file_number or 1,
- )
+ return f"CB{date}{file_number:02d}.REM"
elif cnab_type == "500":
- return "PG%s%s.REM" % (
- context_today.strftime("%d%m"),
- str(self.file_number),
- )
+ return f"PG{date}{file_number}.REM"
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_change_methods.py b/l10n_br_account_payment_order/models/l10n_br_cnab_change_methods.py
index bceab4ee01dd..a52ec46a7ba9 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_change_methods.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_change_methods.py
@@ -161,8 +161,8 @@ def _msg_error_cnab_missing(self, payment_mode_name, missing):
"""
raise UserError(
_(
- "Payment Mode %(payment_mode_name)s don't has %(missing)s for making CNAB"
- "change, check if should have.",
+ "Payment Mode %(payment_mode_name)s don't has %(missing)s for making "
+ "CNAB change, check if should have.",
payment_mode_name=payment_mode_name,
missing=missing,
)
diff --git a/l10n_br_account_payment_order/models/l10n_br_cnab_data_abstract.py b/l10n_br_account_payment_order/models/l10n_br_cnab_data_abstract.py
index 6f63e03f6b3e..cc0aa9ec2e61 100644
--- a/l10n_br_account_payment_order/models/l10n_br_cnab_data_abstract.py
+++ b/l10n_br_account_payment_order/models/l10n_br_cnab_data_abstract.py
@@ -23,7 +23,7 @@ class L10nBrCNABDataAbstract(models.AbstractModel):
def name_get(self):
result = []
for record in self:
- result.append((record.id, "%s - %s" % (record.code, record.name)))
+ result.append((record.id, f"{record.code} - {record.name}"))
return result
@api.constrains("code")
diff --git a/l10n_br_account_withholding/models/account_move.py b/l10n_br_account_withholding/models/account_move.py
index 68918e32b4fa..fec0f58175fd 100644
--- a/l10n_br_account_withholding/models/account_move.py
+++ b/l10n_br_account_withholding/models/account_move.py
@@ -8,7 +8,6 @@
class AccountMove(models.Model):
-
_inherit = "account.move"
wh_invoice_count = fields.Integer(
diff --git a/l10n_br_account_withholding/models/account_move_line.py b/l10n_br_account_withholding/models/account_move_line.py
index 50b82d4884f8..c1a302f2bbc5 100644
--- a/l10n_br_account_withholding/models/account_move_line.py
+++ b/l10n_br_account_withholding/models/account_move_line.py
@@ -10,7 +10,6 @@
class AccountMoveLine(models.Model):
-
_inherit = "account.move.line"
wh_move_line_id = fields.Many2one(
diff --git a/l10n_br_account_withholding/models/l10n_br_fiscal_tax_group.py b/l10n_br_account_withholding/models/l10n_br_fiscal_tax_group.py
index 0173cf407ed1..83d02bcedd77 100644
--- a/l10n_br_account_withholding/models/l10n_br_fiscal_tax_group.py
+++ b/l10n_br_account_withholding/models/l10n_br_fiscal_tax_group.py
@@ -5,7 +5,6 @@
class FiscalTaxGroup(models.Model):
-
_inherit = "l10n_br_fiscal.tax.group"
journal_id = fields.Many2one(
diff --git a/l10n_br_account_withholding/tests/test_account_wh_invoice.py b/l10n_br_account_withholding/tests/test_account_wh_invoice.py
index c26b0841ecf5..5c69d4ac0b99 100644
--- a/l10n_br_account_withholding/tests/test_account_wh_invoice.py
+++ b/l10n_br_account_withholding/tests/test_account_wh_invoice.py
@@ -74,7 +74,7 @@ def setup_company_data(cls, company_name, chart_template=None, **kwargs):
icms_regulation_id=cls.env.ref("l10n_br_fiscal.tax_icms_regulation").id,
cnae_main_id=cls.env.ref("l10n_br_fiscal.cnae_3101200").id,
document_type_id=cls.env.ref("l10n_br_fiscal.document_55").id,
- **kwargs
+ **kwargs,
)
res["company"].partner_id.state_id = cls.env.ref("base.state_br_sp").id
chart_template.load_fiscal_taxes()
diff --git a/l10n_br_base/models/res_partner_bank.py b/l10n_br_base/models/res_partner_bank.py
index c44b339b970a..e641849a16d8 100644
--- a/l10n_br_base/models/res_partner_bank.py
+++ b/l10n_br_base/models/res_partner_bank.py
@@ -107,8 +107,8 @@ def _check_transc_acc_type(self):
if not rec.bra_number or not rec.acc_number_dig:
raise UserError(
_(
- "A Checking Account or Saving Account transactional account "
- "must contain the branch number and the account verification "
- "digit."
+ "A Checking Account or Saving Account transactional account"
+ " must contain the branch number and the account"
+ " verification digit."
)
)
diff --git a/l10n_br_base/tests/test_valid_createid.py b/l10n_br_base/tests/test_valid_createid.py
index 5b4a79bba896..a340b3e2f9de 100644
--- a/l10n_br_base/tests/test_valid_createid.py
+++ b/l10n_br_base/tests/test_valid_createid.py
@@ -136,9 +136,7 @@ def test_comp_valid(self):
.create(self.company_valid)
)
except Exception:
- assert (
- company
- ), "Error when using .create() even with valid \
+ assert company, "Error when using .create() even with valid \
and Inscricao Estadual"
def test_comp_invalid_cnpj(self):
@@ -168,9 +166,7 @@ def test_part_valid(self):
.create(self.partner_valid)
)
except Exception:
- assert (
- partner
- ), "Error when using .create() even with valid CPF \
+ assert partner, "Error when using .create() even with valid CPF \
and Inscricao Estadual"
def test_part_invalid_cpf(self):
diff --git a/l10n_br_base/tools.py b/l10n_br_base/tools.py
index 2f11d8345c34..bb971880eca7 100644
--- a/l10n_br_base/tools.py
+++ b/l10n_br_base/tools.py
@@ -22,25 +22,27 @@ def check_ie(env, inscr_est, state, country):
:return:
"""
if env and inscr_est and state and country:
- if country == env.ref("base.br"):
- disable_ie_validation = env["ir.config_parameter"].sudo().get_param(
- "l10n_br_base.disable_ie_validation", default=False
- ) or env.context.get("disable_ie_validation")
-
- if not disable_ie_validation:
- # TODO: em aberto debate sobre:
- # Se no caso da empresa ser 'isenta' do IE o campo
- # deve estar vazio ou pode ter algum valor como abaixo
- if inscr_est not in ("isento", "isenta", "ISENTO", "ISENTA"):
+ if not country == env.ref("base.br"):
+ return # skip
+ disable_ie_validation = env["ir.config_parameter"].sudo().get_param(
+ "l10n_br_base.disable_ie_validation", default=False
+ ) or env.context.get("disable_ie_validation")
- if not ie.validar(state.code.lower(), inscr_est):
- raise ValidationError(
- _(
- "Estadual Inscription %(inscr)s Invalid for State %(state)s!",
- inscr=inscr_est,
- state=state.name,
- )
- )
+ if disable_ie_validation:
+ return # skip
+ # TODO: em aberto debate sobre:
+ # Se no caso da empresa ser 'isenta' do IE o campo
+ # deve estar vazio ou pode ter algum valor como abaixo
+ if inscr_est in ("isento", "isenta", "ISENTO", "ISENTA"):
+ return # skip
+ if not ie.validar(state.code.lower(), inscr_est):
+ raise ValidationError(
+ _(
+ "Estadual Inscription %(inscr)s Invalid for State %(state)s!",
+ inscr=inscr_est,
+ state=state.name,
+ )
+ )
def check_cnpj_cpf(env, cnpj_cpf_value, country):
diff --git a/l10n_br_cnab_structure/models/account_payment_line.py b/l10n_br_cnab_structure/models/account_payment_line.py
index 65b178f298e6..e00b0de69997 100644
--- a/l10n_br_cnab_structure/models/account_payment_line.py
+++ b/l10n_br_cnab_structure/models/account_payment_line.py
@@ -23,7 +23,8 @@ class AccountPaymentLine(models.Model):
cnab_beneficiary_name = fields.Char(
compute="_compute_cnab_beneficiary_name",
- help="Name of the beneficiary (Nome do Favorecido) that will be informed in the CNAB.",
+ help="Name of the beneficiary (Nome do Favorecido) that will be informed"
+ " in the CNAB.",
)
cnab_pix_transfer_type_id = fields.Many2one(
@@ -85,7 +86,8 @@ def _compute_cnab_payment_way_id(self):
mode = bline.order_id.payment_mode_id
cnab_structure = bline.order_id.cnab_structure_id
result = mode.cnab_payment_way_ids.filtered(
- lambda a: a.cnab_structure_id == cnab_structure
+ lambda a, cnab_structure=cnab_structure: a.cnab_structure_id
+ == cnab_structure
)
if not result:
raise UserError(
diff --git a/l10n_br_cnab_structure/models/cnab_batch.py b/l10n_br_cnab_structure/models/cnab_batch.py
index 7e9e72f7b26f..64e68a329626 100644
--- a/l10n_br_cnab_structure/models/cnab_batch.py
+++ b/l10n_br_cnab_structure/models/cnab_batch.py
@@ -121,21 +121,24 @@ def check_batch(self):
if not segment_lines:
raise UserError(
_(
- f"Batch {self.name}: Every Batch need to have at least one segment line!"
+ f"Batch {self.name}: Every Batch need to have at least one segment"
+ " line!"
)
)
if len(header_line) != 1:
raise UserError(
_(
- f"Batch {self.name}: One batch need to have one and only one header line!"
+ f"Batch {self.name}: One batch need to have one and only one"
+ " header line!"
)
)
if len(trailer_line) != 1:
raise UserError(
_(
- f"Batch {self.name}: One batch need to have one and only one trailer line!"
+ f"Batch {self.name}: One batch need to have one and only one"
+ " trailer line!"
)
)
diff --git a/l10n_br_cnab_structure/models/cnab_line.py b/l10n_br_cnab_structure/models/cnab_line.py
index b387adf120e2..f75a66350704 100644
--- a/l10n_br_cnab_structure/models/cnab_line.py
+++ b/l10n_br_cnab_structure/models/cnab_line.py
@@ -35,7 +35,8 @@ class CNABLine(models.Model):
content_source_model_id = fields.Many2one(
comodel_name="ir.model",
string="Content Source",
- help="Related model that will provide the origin of the contents of CNAB files.",
+ help="Related model that will provide the origin of the contents of CNAB"
+ "files.",
compute="_compute_content_source_model_id",
states={"draft": [("readonly", False)]},
)
@@ -248,7 +249,8 @@ def check_line(self):
if self.batch_id and self.batch_id.cnab_structure_id != self.cnab_structure_id:
raise UserError(
_(
- f"{self.name}: line cnab structure is different of batch cnab structure."
+ f"{self.name}: line cnab structure is different of batch cnab"
+ " structure."
)
)
diff --git a/l10n_br_cnab_structure/models/cnab_line_field.py b/l10n_br_cnab_structure/models/cnab_line_field.py
index d48f6adb57c9..ac8219ba5c01 100644
--- a/l10n_br_cnab_structure/models/cnab_line_field.py
+++ b/l10n_br_cnab_structure/models/cnab_line_field.py
@@ -85,7 +85,8 @@ class CNABField(models.Model):
comodel_name="ir.model", related="cnab_line_id.content_source_model_id"
)
content_source_field = fields.Char(
- help="Inform the field with the origin of the content, expressed with dot notation.",
+ help="Inform the field with the origin of the content, expressed with"
+ " dot notation.",
readonly=True,
states={"draft": [("readonly", False)]},
)
@@ -99,17 +100,18 @@ class CNABField(models.Model):
sending_dynamic_content = fields.Char(
help="Expression in Python to define the final value of the content,"
- "you can use the following predefined words: \n\n"
- "'content' returns the value of the mapped content source field. \n"
- "'time' class to handle date. \n"
- "'seq_batch' returns the batch sequence. \n"
- "'seq_record_detail' returns the sequence for detail record in the batch. \n"
- "'payment_way_code' return the batch payment way \n"
- "'patment_type_code' return the batch payment type \n"
- "'qty_batches' returns the number of batches \n"
- "'qty_records' returns the number of records \n"
+ "you can use the following predefined words:\n\n"
+ "'content' returns the value of the mapped content source field.\n"
+ "'time' class to handle date.\n"
+ "'seq_batch' returns the batch sequence.\n"
+ "'seq_record_detail' returns the sequence for detail record in the batch.\n"
+ "'payment_way_code' return the batch payment way\n"
+ "'patment_type_code' return the batch payment type\n"
+ "'qty_batches' returns the number of batches\n"
+ "'qty_records' returns the number of records\n"
"'batch_detail_lines' returns a list of batch detail records."
- "'segment_code' returns the code of the segment defined in the header of the line.",
+ "'segment_code' returns the code of the segment defined in the header"
+ " of the line.",
readonly=True,
states={"draft": [("readonly", False)]},
)
@@ -119,7 +121,8 @@ class CNABField(models.Model):
)
content_dest_field = fields.Char(
string="Content Destination Field",
- help="Inform the field with the origin of the content, expressed with dot notation.",
+ help="Inform the field with the origin of the content, expressed with"
+ " dot notation.",
readonly=True,
states={"draft": [("readonly", False)]},
)
@@ -266,7 +269,7 @@ def check_field(self):
if self.start_pos > self.end_pos:
raise UserError(
_(
- f"{self.name} in {self.cnab_line_id}: Start position is greater than end"
- " position."
+ f"{self.name} in {self.cnab_line_id}: Start position is greater"
+ " than end position."
)
)
diff --git a/l10n_br_cnab_structure/models/cnab_structure.py b/l10n_br_cnab_structure/models/cnab_structure.py
index 0f2115c1a114..803ae088ae79 100644
--- a/l10n_br_cnab_structure/models/cnab_structure.py
+++ b/l10n_br_cnab_structure/models/cnab_structure.py
@@ -62,7 +62,8 @@ class CNABStructure(models.Model):
content_source_model_id = fields.Many2one(
comodel_name="ir.model",
string="Content Source",
- help="Related model that will provide the origin of the contents of CNAB files.",
+ help="Related model that will provide the origin of the contents of CNAB"
+ " files.",
compute="_compute_content_source_model_id",
)
@@ -103,41 +104,43 @@ class CNABStructure(models.Model):
)
conf_payment_way_start_pos = fields.Integer(
- string="Payment Way start position in Header Batch Records."
+ help="Payment Way start position in Header Batch Records."
" Only for Header Batch Records.",
readonly=True,
states={"draft": [("readonly", False)]},
)
conf_payment_way_end_pos = fields.Integer(
- string="Payment Way last position in Header Batch Records."
+ help="Payment Way last position in Header Batch Records."
" Only for Header Batch Records.",
readonly=True,
states={"draft": [("readonly", False)]},
)
conf_detail_start_pos = fields.Integer(
- string="Position of sequencial identification of Detail Records."
+ help="Position of sequencial identification of Detail Records."
" Only for detail records.",
readonly=True,
states={"draft": [("readonly", False)]},
)
conf_detail_end_pos = fields.Integer(
- string="Last position of sequencial identification of Detail Records."
+ help="Last position of sequencial identification of Detail Records."
" Only for detail records.",
readonly=True,
states={"draft": [("readonly", False)]},
)
conf_segment_start_pos = fields.Integer(
- string="Start position of segment of an detail record. Only for detail records.",
+ help="Start position of segment of an detail record. Only for detail"
+ " records.",
readonly=True,
states={"draft": [("readonly", False)]},
)
conf_segment_end_pos = fields.Integer(
- string="Last position of segment of an detail record. Only for detail records.",
+ help="Last position of segment of an detail record. Only for detail"
+ " records.",
readonly=True,
states={"draft": [("readonly", False)]},
)
@@ -408,7 +411,8 @@ def check_structure(self):
if len(trailer_line) != 1:
raise UserError(
_(
- f"{self.name}: Structures need to have one and only one trailer line!"
+ f"{self.name}: Structures need to have one and only one trailer"
+ " line!"
)
)
diff --git a/l10n_br_cnab_structure/models/l10n_br_cnab_event.py b/l10n_br_cnab_structure/models/l10n_br_cnab_event.py
index 60fc60f01f3a..1bbe90dfc135 100644
--- a/l10n_br_cnab_structure/models/l10n_br_cnab_event.py
+++ b/l10n_br_cnab_structure/models/l10n_br_cnab_event.py
@@ -93,8 +93,8 @@ def create(self, vals):
"""Override Create Method"""
event = super().create(vals)
if not event.cnab_return_log_id.cnab_structure_id:
- # if there is no cnab_structure_id it is because the return file is not being
- # processed by this module, so there is nothing to do here.
+ # if there is no cnab_structure_id it is because the return file is not
+ # being processed by this module, so there is nothing to do here.
return event
event.load_description_occurrences()
event.load_bank_payment_line()
@@ -202,7 +202,8 @@ def load_description_occurrences(self):
def _get_liq_move_vals(self):
return {
"name": f"CNAB Return {self.cnab_return_log_id.bank_id.short_name} - "
- f"{self.cnab_return_log_id.bank_account_id.acc_number} - REF: {self.your_number}",
+ f"{self.cnab_return_log_id.bank_account_id.acc_number} - "
+ f"REF: {self.your_number}",
"ref": self.your_number,
"is_cnab": True,
"journal_id": self.journal_id.id,
@@ -223,7 +224,8 @@ def _get_reconciliation_items(self, move_id):
move_lines = self.move_line_ids.sorted(key=lambda line: line.date_maturity)
for index, move_line in enumerate(move_lines):
line_balance = abs(move_line.balance)
- # the total value of counterpart move lines must be equal to balance in return event
+ # the total value of counterpart move lines must be equal to balance in
+ # return event
if index != len(self.move_line_ids) - 1:
if balance > line_balance:
value = line_balance
diff --git a/l10n_br_cnab_structure/wizard/cnab_import_wizard.py b/l10n_br_cnab_structure/wizard/cnab_import_wizard.py
index eab491f9fe23..c54ac92c7b90 100644
--- a/l10n_br_cnab_structure/wizard/cnab_import_wizard.py
+++ b/l10n_br_cnab_structure/wizard/cnab_import_wizard.py
@@ -193,7 +193,8 @@ def _get_unique_batch_list(self, lines):
batch_list = []
for line in lines:
batch = self._get_content(line, "batch")
- # Ignore batches from header and trailer of file, they will always be 0000 and 9999.
+ # Ignore batches from header and trailer of file,
+ # they will always be 0000 and 9999.
# If there is an exception, it must be handled.
if batch not in ["0000", "9999"]:
batch_list.append(batch)
@@ -211,7 +212,7 @@ def _get_segments(self, segment_lines, batch_template):
for s in segment_lines:
segment_code = self._get_content(s, "segment")
line_template = batch_template.line_ids.filtered(
- lambda line: line.type == "segment"
+ lambda line, segment_code=segment_code: line.type == "segment"
and line.segment_code == segment_code
)
segment = {"raw_line": s, "line_template": line_template}
diff --git a/l10n_br_cnab_structure/wizard/cnab_preview_wizard.py b/l10n_br_cnab_structure/wizard/cnab_preview_wizard.py
index 28a60788d0a0..02b1a0c0ec55 100644
--- a/l10n_br_cnab_structure/wizard/cnab_preview_wizard.py
+++ b/l10n_br_cnab_structure/wizard/cnab_preview_wizard.py
@@ -60,7 +60,7 @@ def load_file(self):
return {
"name": "CNAB",
"type": "ir.actions.act_url",
- "url": f"/web/content/?model=cnab.preview.wizard&id={self.id}&field=cnab_file"
- "&filename_field=cnab_file_name&download=true",
+ "url": f"/web/content/?model=cnab.preview.wizard&id={self.id}"
+ "&field=cnab_file&filename_field=cnab_file_name&download=true",
"target": "self",
}
diff --git a/l10n_br_contract/models/contract_contract.py b/l10n_br_contract/models/contract_contract.py
index 937efcc2c6e9..6eaa0e10788b 100644
--- a/l10n_br_contract/models/contract_contract.py
+++ b/l10n_br_contract/models/contract_contract.py
@@ -123,7 +123,7 @@ def _prepare_recurring_invoices_values(self, date_ref=False):
for invoice_val in super_inv_vals:
# Identify how many Document Types exist
for inv_line in invoice_val.get("invoice_line_ids"):
- if type(inv_line[2]) is list:
+ if isinstance(inv_line[2], list):
continue
operation_line_id = self.env["l10n_br_fiscal.operation.line"].browse(
diff --git a/l10n_br_currency_rate_update/tests/test_currency_rate_update_bcb.py b/l10n_br_currency_rate_update/tests/test_currency_rate_update_bcb.py
index 9b67f07969fb..1641ab143c13 100644
--- a/l10n_br_currency_rate_update/tests/test_currency_rate_update_bcb.py
+++ b/l10n_br_currency_rate_update/tests/test_currency_rate_update_bcb.py
@@ -20,8 +20,7 @@ def _not_every_day_test(method, self, modulo=7, remaining=1):
return method(self)
else:
return lambda: _logger.info(
- "Skipping test today because datetime.now().day %% %s != %s"
- % (modulo, remaining)
+ f"Skipping test today because datetime.now().day % {modulo} != {remaining}"
)
diff --git a/l10n_br_delivery/tests/test_delivery_inverse_amount.py b/l10n_br_delivery/tests/test_delivery_inverse_amount.py
index a7cbaa66de05..7113ed839e2b 100644
--- a/l10n_br_delivery/tests/test_delivery_inverse_amount.py
+++ b/l10n_br_delivery/tests/test_delivery_inverse_amount.py
@@ -367,7 +367,7 @@ def test_not_cost_ratio_by_lines(self):
)
for line in self.sale_demo.order_line:
other_line = self.sale_demo.order_line.filtered(
- lambda o_l: o_l.id != line.id
+ lambda o_l, line=line: o_l.id != line.id
)
self.assertNotEqual(
line.freight_value,
@@ -403,7 +403,7 @@ def test_not_cost_ratio_by_lines(self):
self.assertEqual(invoice.state, "posted", "Invoice should be in state Posted")
for line in invoice.invoice_line_ids:
other_line = invoice.invoice_line_ids.filtered(
- lambda o_l: o_l.id != line.id
+ lambda o_l, line=line: o_l.id != line.id
)
self.assertNotEqual(
line.freight_value,
@@ -426,7 +426,7 @@ def test_not_cost_ratio_by_lines(self):
for line in fiscal_document_id.fiscal_line_ids:
other_line = fiscal_document_id.fiscal_line_ids.filtered(
- lambda o_l: o_l.id != line.id
+ lambda o_l, line=line: o_l.id != line.id
)
self.assertNotEqual(
line.freight_value,
diff --git a/l10n_br_fiscal/models/comment.py b/l10n_br_fiscal/models/comment.py
index f066feb85f09..4443200d7ac4 100644
--- a/l10n_br_fiscal/models/comment.py
+++ b/l10n_br_fiscal/models/comment.py
@@ -89,16 +89,16 @@ def _name_search(
def name_get(self):
def truncate_name(name):
if len(name) > 60:
- name = "{}...".format(name[:60])
+ name = f"{name[:60]}..."
return name
- return [(r.id, "{}".format(truncate_name(r.name))) for r in self]
+ return [(r.id, f"{truncate_name(r.name)}") for r in self]
# format_amount function for fiscal observation
# This way we can format numbers in currency template on fiscal observation
# msg We'll call this function when setting the variables env below
def format_amount(self, env, amount, currency):
- fmt = "%.{}f".format(currency.decimal_places)
+ fmt = f"%.{currency.decimal_places}f"
lang = env.ref("base.lang_pt_BR")
formatted_amount = (
@@ -113,7 +113,7 @@ def format_amount(self, env, amount, currency):
else:
post = "\N{NO-BREAK SPACE}" + "{}".format(currency.symbol or "")
- return "{pre}{0}{post}".format(formatted_amount, pre=pre, post=post)
+ return f"{pre}{formatted_amount}{post}"
def compute_message(self, vals, manual_comment=None):
if not self.ids and not manual_comment:
diff --git a/l10n_br_fiscal/models/data_abstract.py b/l10n_br_fiscal/models/data_abstract.py
index 144e6550b904..fc301ae5cd4c 100644
--- a/l10n_br_fiscal/models/data_abstract.py
+++ b/l10n_br_fiscal/models/data_abstract.py
@@ -94,10 +94,10 @@ def _name_search(
def name_get(self):
def truncate_name(name):
if len(name) > 60:
- name = "{}...".format(name[:60])
+ name = f"{name[:60]}..."
return name
if self._context.get("show_code_only"):
- return [(r.id, "{}".format(r.code)) for r in self]
+ return [(r.id, f"{r.code}") for r in self]
- return [(r.id, "{} - {}".format(r.code, truncate_name(r.name))) for r in self]
+ return [(r.id, f"{r.code} - {truncate_name(r.name)}") for r in self]
diff --git a/l10n_br_fiscal/models/data_ncm_nbs_abstract.py b/l10n_br_fiscal/models/data_ncm_nbs_abstract.py
index 821b8dc5db98..94c558403648 100644
--- a/l10n_br_fiscal/models/data_ncm_nbs_abstract.py
+++ b/l10n_br_fiscal/models/data_ncm_nbs_abstract.py
@@ -158,9 +158,7 @@ def _scheduled_update(self):
SELECT {0}_id
FROM {0}_max_date
WHERE max < %(create_date)s
- """.format(
- object_name.lower()
- )
+ """.format(object_name.lower())
query_params = {"create_date": data_max.strftime("%Y-%m-%d")}
diff --git a/l10n_br_fiscal/models/document_fiscal_line_mixin_methods.py b/l10n_br_fiscal/models/document_fiscal_line_mixin_methods.py
index 368be12add34..47720e6c7a78 100644
--- a/l10n_br_fiscal/models/document_fiscal_line_mixin_methods.py
+++ b/l10n_br_fiscal/models/document_fiscal_line_mixin_methods.py
@@ -223,7 +223,8 @@ def _compute_allow_csll_irpj(self):
for line in self:
# Determine if 'CSLL' and 'IRPJ' taxes may apply:
# 1. When providing services (tax_icms_or_issqn == "issqn")
- # 2. When supplying products to public entities (partner_is_public_entity is True)
+ # 2. When supplying products to public entities (partner_is_public_entity
+ # is True)
if line.tax_icms_or_issqn == "issqn" or line.partner_is_public_entity:
line.allow_csll_irpj = True # Tax charges may apply
else:
@@ -240,7 +241,7 @@ def _prepare_br_fiscal_dict(self, default=False):
vals.pop("id", None)
if default: # in case you want to use new rather than write later
- return {"default_%s" % (k,): vals[k] for k in vals.keys()}
+ return {f"default_{k}": vals[k] for k in vals.keys()}
return vals
def _get_all_tax_id_fields(self):
@@ -291,7 +292,7 @@ def _update_fiscal_tax_ids(self, taxes):
for line in self:
taxes_groups = line.fiscal_tax_ids.mapped("tax_domain")
fiscal_taxes = line.fiscal_tax_ids.filtered(
- lambda ft: ft.tax_domain not in taxes_groups
+ lambda ft, taxes_groups=taxes_groups: ft.tax_domain not in taxes_groups
)
line.fiscal_tax_ids = fiscal_taxes + taxes
diff --git a/l10n_br_fiscal/models/document_fiscal_mixin_fields.py b/l10n_br_fiscal/models/document_fiscal_mixin_fields.py
index f8f791335b96..6821d2450adc 100644
--- a/l10n_br_fiscal/models/document_fiscal_mixin_fields.py
+++ b/l10n_br_fiscal/models/document_fiscal_mixin_fields.py
@@ -29,9 +29,9 @@ def _operation_domain(self):
domain = (
"[('state', '=', 'approved'),"
"'|',"
- "('company_id', '=', %s),"
+ f"('company_id', '=', {self.env.company.id}),"
"('company_id', '=', False),"
- ) % (self.env.company.id,)
+ )
return domain
fiscal_operation_id = fields.Many2one(
diff --git a/l10n_br_fiscal/models/document_fiscal_mixin_methods.py b/l10n_br_fiscal/models/document_fiscal_mixin_methods.py
index 210dbeb66763..cae500ba1a0f 100644
--- a/l10n_br_fiscal/models/document_fiscal_mixin_methods.py
+++ b/l10n_br_fiscal/models/document_fiscal_mixin_methods.py
@@ -21,7 +21,7 @@ def _prepare_br_fiscal_dict(self, default=False):
vals.pop("id", None)
if default: # in case you want to use new rather than write later
- return {"default_%s" % (k,): vals[k] for k in vals.keys()}
+ return {f"default_{k}": vals[k] for k in vals.keys()}
return vals
def _get_amount_lines(self):
@@ -121,11 +121,12 @@ def _inverse_amount_freight(self):
line.freight_value = amount_freight_value * (
line.freight_value / amount_freight_old
)
- record._get_product_amount_lines()[
- -1
- ].freight_value = amount_freight_value - sum(
- line.freight_value
- for line in record._get_product_amount_lines()[:-1]
+ record._get_product_amount_lines()[-1].freight_value = (
+ amount_freight_value
+ - sum(
+ line.freight_value
+ for line in record._get_product_amount_lines()[:-1]
+ )
)
else:
amount_total = sum(
@@ -136,11 +137,12 @@ def _inverse_amount_freight(self):
line.freight_value = amount_freight_value * (
line.price_gross / amount_total
)
- record._get_product_amount_lines()[
- -1
- ].freight_value = amount_freight_value - sum(
- line.freight_value
- for line in record._get_product_amount_lines()[:-1]
+ record._get_product_amount_lines()[-1].freight_value = (
+ amount_freight_value
+ - sum(
+ line.freight_value
+ for line in record._get_product_amount_lines()[:-1]
+ )
)
for line in record._get_product_amount_lines():
line._onchange_fiscal_taxes()
@@ -169,11 +171,12 @@ def _inverse_amount_insurance(self):
line.insurance_value = amount_insurance_value * (
line.insurance_value / amount_insurance_old
)
- record._get_product_amount_lines()[
- -1
- ].insurance_value = amount_insurance_value - sum(
- line.insurance_value
- for line in record._get_product_amount_lines()[:-1]
+ record._get_product_amount_lines()[-1].insurance_value = (
+ amount_insurance_value
+ - sum(
+ line.insurance_value
+ for line in record._get_product_amount_lines()[:-1]
+ )
)
else:
amount_total = sum(
@@ -184,11 +187,12 @@ def _inverse_amount_insurance(self):
line.insurance_value = amount_insurance_value * (
line.price_gross / amount_total
)
- record._get_product_amount_lines()[
- -1
- ].insurance_value = amount_insurance_value - sum(
- line.insurance_value
- for line in record._get_product_amount_lines()[:-1]
+ record._get_product_amount_lines()[-1].insurance_value = (
+ amount_insurance_value
+ - sum(
+ line.insurance_value
+ for line in record._get_product_amount_lines()[:-1]
+ )
)
for line in record._get_product_amount_lines():
line._onchange_fiscal_taxes()
@@ -217,11 +221,12 @@ def _inverse_amount_other(self):
line.other_value = amount_other_value * (
line.other_value / amount_other_old
)
- record._get_product_amount_lines()[
- -1
- ].other_value = amount_other_value - sum(
- line.other_value
- for line in record._get_product_amount_lines()[:-1]
+ record._get_product_amount_lines()[-1].other_value = (
+ amount_other_value
+ - sum(
+ line.other_value
+ for line in record._get_product_amount_lines()[:-1]
+ )
)
else:
amount_total = sum(
@@ -232,11 +237,12 @@ def _inverse_amount_other(self):
line.other_value = amount_other_value * (
line.price_gross / amount_total
)
- record._get_product_amount_lines()[
- -1
- ].other_value = amount_other_value - sum(
- line.other_value
- for line in record._get_product_amount_lines()[:-1]
+ record._get_product_amount_lines()[-1].other_value = (
+ amount_other_value
+ - sum(
+ line.other_value
+ for line in record._get_product_amount_lines()[:-1]
+ )
)
for line in record._get_product_amount_lines():
line._onchange_fiscal_taxes()
diff --git a/l10n_br_fiscal/models/document_move_mixin.py b/l10n_br_fiscal/models/document_move_mixin.py
index c71b721ee6f1..3b2daed1ef51 100644
--- a/l10n_br_fiscal/models/document_move_mixin.py
+++ b/l10n_br_fiscal/models/document_move_mixin.py
@@ -251,7 +251,9 @@ def _onchange_fiscal_operation_id(self):
{
"source_document_id": self.id,
"subsequent_operation_id": subsequent_id.id,
- "fiscal_operation_id": subsequent_id.subsequent_operation_id.id,
+ "fiscal_operation_id": (
+ subsequent_id.subsequent_operation_id.id
+ ),
},
)
)
diff --git a/l10n_br_fiscal/models/document_serie.py b/l10n_br_fiscal/models/document_serie.py
index 769b61f775fb..6b6db294d709 100644
--- a/l10n_br_fiscal/models/document_serie.py
+++ b/l10n_br_fiscal/models/document_serie.py
@@ -79,7 +79,7 @@ def create(self, vals_list):
return super().create(vals_list)
def name_get(self):
- return [(r.id, "{}".format(r.name)) for r in self]
+ return [(r.id, f"{r.name}") for r in self]
def _is_invalid_number(self, document_number):
self.ensure_one()
diff --git a/l10n_br_fiscal/models/product_template.py b/l10n_br_fiscal/models/product_template.py
index b34b972bda59..1214a494aeaf 100644
--- a/l10n_br_fiscal/models/product_template.py
+++ b/l10n_br_fiscal/models/product_template.py
@@ -26,8 +26,8 @@ def _get_default_ncm_id(self):
# demo products of type 'product' (this type is added to product.template
# in the stock module).
# For some reason when running the tests, some inverse method fields then fail when
- # reading 'product' value for the product type. It seems it is because l10n_br_fiscal
- # doesn't depend on stock. But we don't want such a dependency.
+ # reading 'product' value for the product type. It seems it is because
+ # l10n_br_fiscal doesn't depend on stock. But we don't want such a dependency.
# So a workaround to avoid the bug we add the 'product' value to the selection.
type = fields.Selection(
selection_add=[("product", "Storable Product")],
diff --git a/l10n_br_fiscal/models/subsequent_document.py b/l10n_br_fiscal/models/subsequent_document.py
index 58b7c6dd3515..9b93b03d351a 100644
--- a/l10n_br_fiscal/models/subsequent_document.py
+++ b/l10n_br_fiscal/models/subsequent_document.py
@@ -3,7 +3,6 @@
# License AGPL-3 or later (http://www.gnu.org/licenses/agpl)
#
-from __future__ import division, print_function, unicode_literals
from odoo import api, fields, models
diff --git a/l10n_br_fiscal/models/subsequent_operation.py b/l10n_br_fiscal/models/subsequent_operation.py
index c4864d6a1f6d..4e3835f9232e 100644
--- a/l10n_br_fiscal/models/subsequent_operation.py
+++ b/l10n_br_fiscal/models/subsequent_operation.py
@@ -2,8 +2,6 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-from __future__ import division, print_function, unicode_literals
-
from odoo import fields, models
from ..constants.fiscal import SITUACAO_EDOC
diff --git a/l10n_br_fiscal/models/tax_definition.py b/l10n_br_fiscal/models/tax_definition.py
index 0fdb67d49314..b73a5c3cc595 100644
--- a/l10n_br_fiscal/models/tax_definition.py
+++ b/l10n_br_fiscal/models/tax_definition.py
@@ -20,11 +20,7 @@ class TaxDefinition(models.Model):
_description = "Tax Definition"
def _get_complete_name(self):
- return "{tax_group}-{tax}-{cst_code}".format(
- tax_group=self.tax_group_id.name,
- tax=self.tax_id.name,
- cst_code=self.cst_code,
- )
+ return f"{self.tax_group_id.name}-{self.tax_id.name}-{self.cst_code}"
@api.depends("tax_group_id", "tax_id", "cst_code")
def _compute_display_name(self):
diff --git a/l10n_br_fiscal/tests/test_fiscal_document_generic.py b/l10n_br_fiscal/tests/test_fiscal_document_generic.py
index 74022f97227c..281ecbd945f4 100644
--- a/l10n_br_fiscal/tests/test_fiscal_document_generic.py
+++ b/l10n_br_fiscal/tests/test_fiscal_document_generic.py
@@ -1053,7 +1053,7 @@ def test_nfe_comments(self):
additional_data = self.nfe_not_taxpayer.fiscal_line_ids[0].additional_data
self.assertEqual(
additional_data,
- "manual comment test - Valor Aprox. dos Tributos: R$ 0,00"
+ "manual comment test - Valor Aprox. dos Tributos: R$ 0,00",
# TODO FIXME changed 0.00 to 0,00 to get tests pass on v13, but not
# correct
)
diff --git a/l10n_br_fiscal/tests/test_ibpt.py b/l10n_br_fiscal/tests/test_ibpt.py
index e9c75b8f16da..67c4ccba1b95 100644
--- a/l10n_br_fiscal/tests/test_ibpt.py
+++ b/l10n_br_fiscal/tests/test_ibpt.py
@@ -25,8 +25,7 @@ def _not_every_day_test(method, self, modulo=7, remaining=0):
return method(self)
else:
return lambda: _logger.info(
- "Skipping test today because datetime.now().day %% %s != %s"
- % (modulo, remaining)
+ f"Skipping test today because datetime.now().day % {modulo} != {remaining}"
)
diff --git a/l10n_br_fiscal/tools.py b/l10n_br_fiscal/tools.py
index 18a36395cade..0065af3e646c 100644
--- a/l10n_br_fiscal/tools.py
+++ b/l10n_br_fiscal/tools.py
@@ -72,13 +72,13 @@ def build_edoc_path(
try:
os.makedirs(caminho, exist_ok=True)
except Exception as e:
- _logger.error("Falha de permissão ao acessar diretorio do e-doc {}".format(e))
+ _logger.error(f"Falha de permissão ao acessar diretorio do e-doc {e}")
return caminho
def remove_non_ascii_characters(value):
result = ""
- if value and type(value) is str:
+ if value and isinstance(value, str):
result = (
normalize("NFKD", value)
.encode("ASCII", "ignore")
diff --git a/l10n_br_fiscal_closing/models/closing.py b/l10n_br_fiscal_closing/models/closing.py
index cad1308b7375..b21bbdf58463 100644
--- a/l10n_br_fiscal_closing/models/closing.py
+++ b/l10n_br_fiscal_closing/models/closing.py
@@ -61,7 +61,7 @@ class FiscalClosing(models.Model):
def _compute_name(self):
for record in self:
if record.export_type == "period":
- record.name = "{}/{}".format(record.month, record.year)
+ record.name = f"{record.month}/{record.year}"
record.file_name = "{}-{}.{}".format(record.month, record.year, "zip")
else:
now = fields.Datetime.now().strftime("%d/%m/%Y")
diff --git a/l10n_br_fiscal_dfe/tests/test_dfe.py b/l10n_br_fiscal_dfe/tests/test_dfe.py
index 6c5e27351455..b5ee7442be1c 100644
--- a/l10n_br_fiscal_dfe/tests/test_dfe.py
+++ b/l10n_br_fiscal_dfe/tests/test_dfe.py
@@ -12,15 +12,14 @@
from ..tools import utils
-# flake8: noqa: B950
-response_sucesso_multiplos = """11.4.0138Documento(s) localizado(s)2022-04-04T11:54:49-03:00000000000000201000000000000201H4sIAAAAAAAEAIVS22qDQBD9FfFdd9Z7ZLKQphosqQ3mQuibMZto8RJcifn8rjG9PZUdZg7DOWeGYbHlIg65cqvKWvg3cZyqedddfEL6vtd7U2/aMzEAKNm/LtdZzqtU/SYX/5O1ohZdWmdcVa68FWkzVakO8PD4o780bZeWp0JkaakX9Uk/tKQ+cZVhlssVmUkNoPLZnjcAGKBtDwVMzzIodak3AIO6HpJRg/N49cL+apDcm3iLm4qz99lKWSSzMJrPlEAJnqPNWyJRlATLCMnIwShgUkqpNLEAHBOJ7OAxD6qCGWCARkEDZwPg30MDU2YkIwG7SxwyiuRe8SqTN3H1iXQZMB6L8y4t2W73sXdtJ+6TUDhGveaLbc9DsXyyt1NpNZLkzIRnh675PZZOfMP2LfNn7IOD9aptOkaHy5meDS44FnWRjG3M1kU3HEmu9gWRjP+BfQI6BY33GAIAAA==H4sIAAAAAAAAA51WzXKjRhC+5ykoX1MWMyAssTWeiozQhpSFKEu7dwxjmwQYLUJYldfJOS+QY/bF0t0DWF5nt7JRqejub3q6p3/mR9QPKml0ZnWqOaT6+mI6YezCOlVlfbi+eGrb/Tvbfn5+nux106blQ3HI0nJS1A+T+8aGuRdSxCv1Xfog4JTXDqP8+gJQ13MY457v+VOXewz5mQeUs/7HHXblzGYzfsXRVK6kyD6spOsJG6nI4pUcNAACSdRpu9nLj6rOU2EbQVQ6lx7MQSoOqimU5MI2jKhhFkhIRP4UVoV0mMMuGYf/jjvvGIP/j4zDV9hGAfS2aRHW7bdVex3R7o0LohDFUh1alHtOZOtjvXoPUTHOPQfiMDLMi6q9mYgMyOD8YADiRLb8iCISGF1U99LBQWTEQwEhUaA9B6XIV0WdluR74BFNGnWQjEBixR56BAMFbGAFVBBbR25yra2bJj0UpbUJFlbHp8IeBjEo8KSqAuIK4uQX+bq6wiZQnGJdKbkLt7vQurS2RbUv1cGK06zQsChhm3FxWqWQwG+o0biAYqsmJJ+n28dG3h1TK0mPpbaWRXoANQRF3WjpzaFPkKGkv045TMbvojxWn/+sCw3zCIVG2ybCxn4LwkTyOXcwGggFJJElKdaEeXOwQrw4ETEpAiMGfNC1kg53obl9/wqakQBhn609CiW0v+vOwT53XWEDIIK7HdYLCSiTXk5dQ4mc86nv+jMfszv3X2c3Xl2GVriOdtFyAdRarG+iMIZMLkPr5816c7t5vwgWG0wsjH5c3G7urFW0DRa3Y/5pcaZJx8Ru0+qoSmutm4M6Ty3HXUmpPQX7EnbG339ZKezCBhwEuv71WLfa4h7EQuPidJMWDajfNFr/VhY14D0y1MZjLpu/qs328x/aVPYrxWFTb3bFrv5XcTyPc3c6mzvQrK/LYzIAuyMKx707Cli26RWbOj6cQq47NWVTVVqUMisLVbeK/zQwk0xXcDZiJXEcTgkykavWqqNWVdcXeNDBnstx8UjCy2Cz5rjJE4OGi1hiwd7vohhQFCEoHAvS+6IGS89F+2QtNRQIA6RZcbCW/pS5LjUuSiJYbRLpcQbdT6w4BrqSH+JoKWxixSf88gmjOSSI7kNN4HTCxh/sfoOKjpzRIIAv6901xf0XayZIHIn0Pg30icjo1YDgwMBv/JpxqMZOD3VBjs4t8A4nhj600FJRsN6a7zbmjEuhm+IRzzeiIthutjE0Cu40YsU+aFQOjDOZka9BFh0yxpBkExc66xyB6r/4sHuvSYR5qD9J3/cxfOAQjHfoeCc9F73i/u5Bm2Yk0ZY+m2PbGMWp3yt2NwH4phQAJ/aoyvqUkQCl6CEsBAL2aMkmOdisonik/8FHP2F0MxjozgYwFz1snxu2R3QsCHQ+Xo26xTsI80Rl+8JpRwnsAZNMIrDxdH2OG0B0qyAZYGTRHsQyWqS4XgASQe8FMUIP3sEKz3GU/7XHu1WjWjXqkgB+1OPoCFjRwSKzASEegonGKCIUkxc56YGl6nR5hhr5bYG/UocOK6AH1AiiwwdJHwK+SeyxAHZfkbZJ64N5Opl4fHo+9bHZw/A+faTTK0GKz4f0cXhIIEI4biqj0OF3TB0i9jDX3hsLD4u8yHpmBc9JLZc6O1YKLw+8/YpcW/DYfGet0yazlqrS6G1U7oUiMxw9e2z6wnnQvnmIkiOoYUsv0iiHO8xx+NxxvKnD5t7F21dV9oTWvufhChue5ogaHckvXMCVSbDItm0Ko5gaw8KNp9ui03JxbOGQ+j2FyLV1PGgrTy242/Hy7TUoVmPG7uMErn/ryx/+AZs2W+n2CwAA"""
+response_sucesso_multiplos = """11.4.0138Documento(s) localizado(s)2022-04-04T11:54:49-03:00000000000000201000000000000201H4sIAAAAAAAEAIVS22qDQBD9FfFdd9Z7ZLKQphosqQ3mQuibMZto8RJcifn8rjG9PZUdZg7DOWeGYbHlIg65cqvKWvg3cZyqedddfEL6vtd7U2/aMzEAKNm/LtdZzqtU/SYX/5O1ohZdWmdcVa68FWkzVakO8PD4o780bZeWp0JkaakX9Uk/tKQ+cZVhlssVmUkNoPLZnjcAGKBtDwVMzzIodak3AIO6HpJRg/N49cL+apDcm3iLm4qz99lKWSSzMJrPlEAJnqPNWyJRlATLCMnIwShgUkqpNLEAHBOJ7OAxD6qCGWCARkEDZwPg30MDU2YkIwG7SxwyiuRe8SqTN3H1iXQZMB6L8y4t2W73sXdtJ+6TUDhGveaLbc9DsXyyt1NpNZLkzIRnh675PZZOfMP2LfNn7IOD9aptOkaHy5meDS44FnWRjG3M1kU3HEmu9gWRjP+BfQI6BY33GAIAAA==H4sIAAAAAAAAA51WzXKjRhC+5ykoX1MWMyAssTWeiozQhpSFKEu7dwxjmwQYLUJYldfJOS+QY/bF0t0DWF5nt7JRqejub3q6p3/mR9QPKml0ZnWqOaT6+mI6YezCOlVlfbi+eGrb/Tvbfn5+nux106blQ3HI0nJS1A+T+8aGuRdSxCv1Xfog4JTXDqP8+gJQ13MY457v+VOXewz5mQeUs/7HHXblzGYzfsXRVK6kyD6spOsJG6nI4pUcNAACSdRpu9nLj6rOU2EbQVQ6lx7MQSoOqimU5MI2jKhhFkhIRP4UVoV0mMMuGYf/jjvvGIP/j4zDV9hGAfS2aRHW7bdVex3R7o0LohDFUh1alHtOZOtjvXoPUTHOPQfiMDLMi6q9mYgMyOD8YADiRLb8iCISGF1U99LBQWTEQwEhUaA9B6XIV0WdluR74BFNGnWQjEBixR56BAMFbGAFVBBbR25yra2bJj0UpbUJFlbHp8IeBjEo8KSqAuIK4uQX+bq6wiZQnGJdKbkLt7vQurS2RbUv1cGK06zQsChhm3FxWqWQwG+o0biAYqsmJJ+n28dG3h1TK0mPpbaWRXoANQRF3WjpzaFPkKGkv045TMbvojxWn/+sCw3zCIVG2ybCxn4LwkTyOXcwGggFJJElKdaEeXOwQrw4ETEpAiMGfNC1kg53obl9/wqakQBhn609CiW0v+vOwT53XWEDIIK7HdYLCSiTXk5dQ4mc86nv+jMfszv3X2c3Xl2GVriOdtFyAdRarG+iMIZMLkPr5816c7t5vwgWG0wsjH5c3G7urFW0DRa3Y/5pcaZJx8Ru0+qoSmutm4M6Ty3HXUmpPQX7EnbG339ZKezCBhwEuv71WLfa4h7EQuPidJMWDajfNFr/VhY14D0y1MZjLpu/qs328x/aVPYrxWFTb3bFrv5XcTyPc3c6mzvQrK/LYzIAuyMKx707Cli26RWbOj6cQq47NWVTVVqUMisLVbeK/zQwk0xXcDZiJXEcTgkykavWqqNWVdcXeNDBnstx8UjCy2Cz5rjJE4OGi1hiwd7vohhQFCEoHAvS+6IGS89F+2QtNRQIA6RZcbCW/pS5LjUuSiJYbRLpcQbdT6w4BrqSH+JoKWxixSf88gmjOSSI7kNN4HTCxh/sfoOKjpzRIIAv6901xf0XayZIHIn0Pg30icjo1YDgwMBv/JpxqMZOD3VBjs4t8A4nhj600FJRsN6a7zbmjEuhm+IRzzeiIthutjE0Cu40YsU+aFQOjDOZka9BFh0yxpBkExc66xyB6r/4sHuvSYR5qD9J3/cxfOAQjHfoeCc9F73i/u5Bm2Yk0ZY+m2PbGMWp3yt2NwH4phQAJ/aoyvqUkQCl6CEsBAL2aMkmOdisonik/8FHP2F0MxjozgYwFz1snxu2R3QsCHQ+Xo26xTsI80Rl+8JpRwnsAZNMIrDxdH2OG0B0qyAZYGTRHsQyWqS4XgASQe8FMUIP3sEKz3GU/7XHu1WjWjXqkgB+1OPoCFjRwSKzASEegonGKCIUkxc56YGl6nR5hhr5bYG/UocOK6AH1AiiwwdJHwK+SeyxAHZfkbZJ64N5Opl4fHo+9bHZw/A+faTTK0GKz4f0cXhIIEI4biqj0OF3TB0i9jDX3hsLD4u8yHpmBc9JLZc6O1YKLw+8/YpcW/DYfGet0yazlqrS6G1U7oUiMxw9e2z6wnnQvnmIkiOoYUsv0iiHO8xx+NxxvKnD5t7F21dV9oTWvufhChue5ogaHckvXMCVSbDItm0Ko5gaw8KNp9ui03JxbOGQ+j2FyLV1PGgrTy242/Hy7TUoVmPG7uMErn/ryx/+AZs2W+n2CwAA""" # noqa: E501
-response_sucesso_individual = """11.4.0138Documento(s) localizado(s)2022-04-04T11:54:49-03:00000000000000201000000000000201H4sIAAAAAAAAA51WzXKjRhC+5ykoX1MWMyAssTWeiozQhpSFKEu7dwxjmwQYLUJYldfJOS+QY/bF0t0DWF5nt7JRqejub3q6p3/mR9QPKml0ZnWqOaT6+mI6YezCOlVlfbi+eGrb/Tvbfn5+nux106blQ3HI0nJS1A+T+8aGuRdSxCv1Xfog4JTXDqP8+gJQ13MY457v+VOXewz5mQeUs/7HHXblzGYzfsXRVK6kyD6spOsJG6nI4pUcNAACSdRpu9nLj6rOU2EbQVQ6lx7MQSoOqimU5MI2jKhhFkhIRP4UVoV0mMMuGYf/jjvvGIP/j4zDV9hGAfS2aRHW7bdVex3R7o0LohDFUh1alHtOZOtjvXoPUTHOPQfiMDLMi6q9mYgMyOD8YADiRLb8iCISGF1U99LBQWTEQwEhUaA9B6XIV0WdluR74BFNGnWQjEBixR56BAMFbGAFVBBbR25yra2bJj0UpbUJFlbHp8IeBjEo8KSqAuIK4uQX+bq6wiZQnGJdKbkLt7vQurS2RbUv1cGK06zQsChhm3FxWqWQwG+o0biAYqsmJJ+n28dG3h1TK0mPpbaWRXoANQRF3WjpzaFPkKGkv045TMbvojxWn/+sCw3zCIVG2ybCxn4LwkTyOXcwGggFJJElKdaEeXOwQrw4ETEpAiMGfNC1kg53obl9/wqakQBhn609CiW0v+vOwT53XWEDIIK7HdYLCSiTXk5dQ4mc86nv+jMfszv3X2c3Xl2GVriOdtFyAdRarG+iMIZMLkPr5816c7t5vwgWG0wsjH5c3G7urFW0DRa3Y/5pcaZJx8Ru0+qoSmutm4M6Ty3HXUmpPQX7EnbG339ZKezCBhwEuv71WLfa4h7EQuPidJMWDajfNFr/VhY14D0y1MZjLpu/qs328x/aVPYrxWFTb3bFrv5XcTyPc3c6mzvQrK/LYzIAuyMKx707Cli26RWbOj6cQq47NWVTVVqUMisLVbeK/zQwk0xXcDZiJXEcTgkykavWqqNWVdcXeNDBnstx8UjCy2Cz5rjJE4OGi1hiwd7vohhQFCEoHAvS+6IGS89F+2QtNRQIA6RZcbCW/pS5LjUuSiJYbRLpcQbdT6w4BrqSH+JoKWxixSf88gmjOSSI7kNN4HTCxh/sfoOKjpzRIIAv6901xf0XayZIHIn0Pg30icjo1YDgwMBv/JpxqMZOD3VBjs4t8A4nhj600FJRsN6a7zbmjEuhm+IRzzeiIthutjE0Cu40YsU+aFQOjDOZka9BFh0yxpBkExc66xyB6r/4sHuvSYR5qD9J3/cxfOAQjHfoeCc9F73i/u5Bm2Yk0ZY+m2PbGMWp3yt2NwH4phQAJ/aoyvqUkQCl6CEsBAL2aMkmOdisonik/8FHP2F0MxjozgYwFz1snxu2R3QsCHQ+Xo26xTsI80Rl+8JpRwnsAZNMIrDxdH2OG0B0qyAZYGTRHsQyWqS4XgASQe8FMUIP3sEKz3GU/7XHu1WjWjXqkgB+1OPoCFjRwSKzASEegonGKCIUkxc56YGl6nR5hhr5bYG/UocOK6AH1AiiwwdJHwK+SeyxAHZfkbZJ64N5Opl4fHo+9bHZw/A+faTTK0GKz4f0cXhIIEI4biqj0OF3TB0i9jDX3hsLD4u8yHpmBc9JLZc6O1YKLw+8/YpcW/DYfGet0yazlqrS6G1U7oUiMxw9e2z6wnnQvnmIkiOoYUsv0iiHO8xx+NxxvKnD5t7F21dV9oTWvufhChue5ogaHckvXMCVSbDItm0Ko5gaw8KNp9ui03JxbOGQ+j2FyLV1PGgrTy242/Hy7TUoVmPG7uMErn/ryx/+AZs2W+n2CwAA"""
+response_sucesso_individual = """11.4.0138Documento(s) localizado(s)2022-04-04T11:54:49-03:00000000000000201000000000000201H4sIAAAAAAAAA51WzXKjRhC+5ykoX1MWMyAssTWeiozQhpSFKEu7dwxjmwQYLUJYldfJOS+QY/bF0t0DWF5nt7JRqejub3q6p3/mR9QPKml0ZnWqOaT6+mI6YezCOlVlfbi+eGrb/Tvbfn5+nux106blQ3HI0nJS1A+T+8aGuRdSxCv1Xfog4JTXDqP8+gJQ13MY457v+VOXewz5mQeUs/7HHXblzGYzfsXRVK6kyD6spOsJG6nI4pUcNAACSdRpu9nLj6rOU2EbQVQ6lx7MQSoOqimU5MI2jKhhFkhIRP4UVoV0mMMuGYf/jjvvGIP/j4zDV9hGAfS2aRHW7bdVex3R7o0LohDFUh1alHtOZOtjvXoPUTHOPQfiMDLMi6q9mYgMyOD8YADiRLb8iCISGF1U99LBQWTEQwEhUaA9B6XIV0WdluR74BFNGnWQjEBixR56BAMFbGAFVBBbR25yra2bJj0UpbUJFlbHp8IeBjEo8KSqAuIK4uQX+bq6wiZQnGJdKbkLt7vQurS2RbUv1cGK06zQsChhm3FxWqWQwG+o0biAYqsmJJ+n28dG3h1TK0mPpbaWRXoANQRF3WjpzaFPkKGkv045TMbvojxWn/+sCw3zCIVG2ybCxn4LwkTyOXcwGggFJJElKdaEeXOwQrw4ETEpAiMGfNC1kg53obl9/wqakQBhn609CiW0v+vOwT53XWEDIIK7HdYLCSiTXk5dQ4mc86nv+jMfszv3X2c3Xl2GVriOdtFyAdRarG+iMIZMLkPr5816c7t5vwgWG0wsjH5c3G7urFW0DRa3Y/5pcaZJx8Ru0+qoSmutm4M6Ty3HXUmpPQX7EnbG339ZKezCBhwEuv71WLfa4h7EQuPidJMWDajfNFr/VhY14D0y1MZjLpu/qs328x/aVPYrxWFTb3bFrv5XcTyPc3c6mzvQrK/LYzIAuyMKx707Cli26RWbOj6cQq47NWVTVVqUMisLVbeK/zQwk0xXcDZiJXEcTgkykavWqqNWVdcXeNDBnstx8UjCy2Cz5rjJE4OGi1hiwd7vohhQFCEoHAvS+6IGS89F+2QtNRQIA6RZcbCW/pS5LjUuSiJYbRLpcQbdT6w4BrqSH+JoKWxixSf88gmjOSSI7kNN4HTCxh/sfoOKjpzRIIAv6901xf0XayZIHIn0Pg30icjo1YDgwMBv/JpxqMZOD3VBjs4t8A4nhj600FJRsN6a7zbmjEuhm+IRzzeiIthutjE0Cu40YsU+aFQOjDOZka9BFh0yxpBkExc66xyB6r/4sHuvSYR5qD9J3/cxfOAQjHfoeCc9F73i/u5Bm2Yk0ZY+m2PbGMWp3yt2NwH4phQAJ/aoyvqUkQCl6CEsBAL2aMkmOdisonik/8FHP2F0MxjozgYwFz1snxu2R3QsCHQ+Xo26xTsI80Rl+8JpRwnsAZNMIrDxdH2OG0B0qyAZYGTRHsQyWqS4XgASQe8FMUIP3sEKz3GU/7XHu1WjWjXqkgB+1OPoCFjRwSKzASEegonGKCIUkxc56YGl6nR5hhr5bYG/UocOK6AH1AiiwwdJHwK+SeyxAHZfkbZJ64N5Opl4fHo+9bHZw/A+faTTK0GKz4f0cXhIIEI4biqj0OF3TB0i9jDX3hsLD4u8yHpmBc9JLZc6O1YKLw+8/YpcW/DYfGet0yazlqrS6G1U7oUiMxw9e2z6wnnQvnmIkiOoYUsv0iiHO8xx+NxxvKnD5t7F21dV9oTWvufhChue5ogaHckvXMCVSbDItm0Ko5gaw8KNp9ui03JxbOGQ+j2FyLV1PGgrTy242/Hy7TUoVmPG7uMErn/ryx/+AZs2W+n2CwAA""" # noqa: E501
-response_rejeicao = """21.4.0589Rejeicao: Numero do NSU informado superior ao maior NSU da base de dados doAmbiente Nacional2022-04-04T11:54:49-03:00000000000000000000000000000000"""
+response_rejeicao = """21.4.0589Rejeicao: Numero do NSU informado superior ao maior NSU da base de dados doAmbiente Nacional2022-04-04T11:54:49-03:00000000000000000000000000000000""" # noqa: E501
-class FakeRetorno(object):
+class FakeRetorno:
def __init__(self, text, status_code=200):
self.text = text
self.content = text.encode("utf-8")
@@ -83,7 +82,7 @@ def setUpClass(cls):
DocumentoElectronicoAdapter, "_post", side_effect=mocked_post_success_multiple
)
def test_search_dfe_success(self, _mock_post):
- self.assertEqual(self.dfe_id.display_name, f"Empresa Lucro Presumido - NSU: 0")
+ self.assertEqual(self.dfe_id.display_name, "Empresa Lucro Presumido - NSU: 0")
self.dfe_id.search_documents()
self.assertEqual(self.dfe_id.last_nsu, utils.format_nsu("201"))
diff --git a/l10n_br_fiscal_dfe/tools/utils.py b/l10n_br_fiscal_dfe/tools/utils.py
index e099bcd5a3ed..4bca122078de 100644
--- a/l10n_br_fiscal_dfe/tools/utils.py
+++ b/l10n_br_fiscal_dfe/tools/utils.py
@@ -15,13 +15,7 @@ def mask_cnpj(cnpj):
if len(val) != 14:
return cnpj
- return "%s.%s.%s/%s-%s" % (
- val[0:2],
- val[2:5],
- val[5:8],
- val[8:12],
- val[12:14],
- )
+ return f"{val[0:2]}.{val[2:5]}.{val[5:8]}/{val[8:12]}-{val[12:14]}"
def format_nsu(nsu):
diff --git a/l10n_br_fiscal_edi/models/document.py b/l10n_br_fiscal_edi/models/document.py
index fd0329dab1e0..d10e74231db9 100644
--- a/l10n_br_fiscal_edi/models/document.py
+++ b/l10n_br_fiscal_edi/models/document.py
@@ -249,9 +249,7 @@ def _target_new_tab(self, attachment_id):
if attachment_id:
return {
"type": "ir.actions.act_url",
- "url": "/web/content/{id}/{nome}".format(
- id=attachment_id.id, nome=attachment_id.name
- ),
+ "url": f"/web/content/{attachment_id.id}/{attachment_id.name}",
"target": "new",
}
@@ -289,6 +287,7 @@ def _check_issuer(self):
if not record.issuer:
raise ValidationError(
_(
- "The field 'Issuer' is required for brazilian electronic documents!"
+ "The field 'Issuer' is required for brazilian electronic "
+ "documents!"
)
)
diff --git a/l10n_br_fiscal_edi/models/document_event.py b/l10n_br_fiscal_edi/models/document_event.py
index 9d5b907ae04f..a75086b5d4fa 100644
--- a/l10n_br_fiscal_edi/models/document_event.py
+++ b/l10n_br_fiscal_edi/models/document_event.py
@@ -242,7 +242,7 @@ def _save_event_2disk(self, arquivo, file_name):
if not os.path.exists(save_dir):
os.makedirs(save_dir)
f = open(file_path, "w")
- except IOError as e:
+ except OSError as e:
raise UserError(
_("Erro!"),
_(
diff --git a/l10n_br_fiscal_edi/tests/test_fiscal_document_generic.py b/l10n_br_fiscal_edi/tests/test_fiscal_document_generic.py
index 27f561d258c7..9f2c6bbc9b38 100644
--- a/l10n_br_fiscal_edi/tests/test_fiscal_document_generic.py
+++ b/l10n_br_fiscal_edi/tests/test_fiscal_document_generic.py
@@ -1076,7 +1076,7 @@ def test_nfe_comments(self):
additional_data = self.nfe_not_taxpayer.fiscal_line_ids[0].additional_data
self.assertEqual(
additional_data,
- "manual comment test - Valor Aprox. dos Tributos: R$ 0,00"
+ "manual comment test - Valor Aprox. dos Tributos: R$ 0,00",
# TODO FIXME changed 0.00 to 0,00 to get tests pass on v13, but not
# correct
)
diff --git a/l10n_br_fiscal_edi/wizards/document_import_wizard_mixin.py b/l10n_br_fiscal_edi/wizards/document_import_wizard_mixin.py
index a7839b4637e6..d3968cec8669 100644
--- a/l10n_br_fiscal_edi/wizards/document_import_wizard_mixin.py
+++ b/l10n_br_fiscal_edi/wizards/document_import_wizard_mixin.py
@@ -114,7 +114,7 @@ def _parse_file_data(self, file_data):
try:
binding = XmlParser().from_bytes(base64.b64decode(file_data))
except Exception as e:
- raise UserError(_("Invalid file: %s" % e))
+ raise UserError(_("Invalid file: %s" % e)) from e
return binding
@api.model
diff --git a/l10n_br_hr/models/data_abstract.py b/l10n_br_hr/models/data_abstract.py
index 7fad0f50e083..f4f7a194f184 100644
--- a/l10n_br_hr/models/data_abstract.py
+++ b/l10n_br_hr/models/data_abstract.py
@@ -15,7 +15,7 @@ class DataAbstract(models.AbstractModel):
name = fields.Text(required=True, index=True)
def name_get(self):
- return [(r.id, "{} - {}".format(r.code, r.name)) for r in self]
+ return [(r.id, f"{r.code} - {r.name}") for r in self]
@api.model
def _name_search(
diff --git a/l10n_br_hr_expense_invoice/models/hr_expense.py b/l10n_br_hr_expense_invoice/models/hr_expense.py
index dd91ec050ea8..ce0e5f10d3f8 100644
--- a/l10n_br_hr_expense_invoice/models/hr_expense.py
+++ b/l10n_br_hr_expense_invoice/models/hr_expense.py
@@ -5,7 +5,6 @@
class HrExpense(models.Model):
-
_inherit = ["hr.expense"]
fiscal_operation_id = fields.Many2one(
diff --git a/l10n_br_hr_expense_invoice/models/res_company.py b/l10n_br_hr_expense_invoice/models/res_company.py
index 63025e355132..0be5164f6752 100644
--- a/l10n_br_hr_expense_invoice/models/res_company.py
+++ b/l10n_br_hr_expense_invoice/models/res_company.py
@@ -5,7 +5,6 @@
class ResCompany(models.Model):
-
_inherit = "res.company"
expense_invoice_fiscal_operation_id = fields.Many2one(
diff --git a/l10n_br_hr_expense_invoice/tests/test_l10n_br_hr_expense_invoice.py b/l10n_br_hr_expense_invoice/tests/test_l10n_br_hr_expense_invoice.py
index f688399e2d73..2a3db869165c 100644
--- a/l10n_br_hr_expense_invoice/tests/test_l10n_br_hr_expense_invoice.py
+++ b/l10n_br_hr_expense_invoice/tests/test_l10n_br_hr_expense_invoice.py
@@ -56,10 +56,10 @@ def test_created_invoices(self):
len(invoices), 2, "The number of created invoices is not as expected."
)
invoice_1 = self.sheet_id.expense_line_ids.filtered(
- lambda l: l.name == "expense_1"
+ lambda line: line.name == "expense_1"
).invoice_id
invoice_2 = self.sheet_id.expense_line_ids.filtered(
- lambda l: l.name == "expense_2"
+ lambda line: line.name == "expense_2"
).invoice_id
self.assertFalse(
invoice_1.fiscal_operation_id,
diff --git a/l10n_br_ie_search/tests/test_sefaz.py b/l10n_br_ie_search/tests/test_sefaz.py
index e4976751b004..bddca7a901b9 100644
--- a/l10n_br_ie_search/tests/test_sefaz.py
+++ b/l10n_br_ie_search/tests/test_sefaz.py
@@ -15,7 +15,7 @@
from odoo.tools.misc import format_date
-class FakeRetorno(object):
+class FakeRetorno:
__slots__ = "text", "ok"
diff --git a/l10n_br_ie_search/tests/test_sintegra.py b/l10n_br_ie_search/tests/test_sintegra.py
index d54f426e33c1..f3b1efa6a699 100644
--- a/l10n_br_ie_search/tests/test_sintegra.py
+++ b/l10n_br_ie_search/tests/test_sintegra.py
@@ -12,7 +12,7 @@
_logger = logging.getLogger(__name__)
-class FakeRetorno(object):
+class FakeRetorno:
__slots__ = "text", "status_code"
def json(self):
diff --git a/l10n_br_nfe/hooks.py b/l10n_br_nfe/hooks.py
index 716fc84961b5..50dc00f09d14 100644
--- a/l10n_br_nfe/hooks.py
+++ b/l10n_br_nfe/hooks.py
@@ -46,4 +46,4 @@ def post_init_hook(cr, registry):
)
_logger.info(nfe.nfe40_emit.nfe40_CNPJ)
except ValidationError:
- _logger.info("NF-e already %s imported by hooks" % (document_number,))
+ _logger.info(f"NF-e already {document_number} imported by hooks")
diff --git a/l10n_br_nfe/models/document.py b/l10n_br_nfe/models/document.py
index 0505c8f215bb..050db04b2b9b 100644
--- a/l10n_br_nfe/models/document.py
+++ b/l10n_br_nfe/models/document.py
@@ -15,7 +15,8 @@
from lxml import etree
from nfelib.nfe.bindings.v4_0.leiaute_nfe_v4_00 import TnfeProc
from nfelib.nfe.bindings.v4_0.nfe_v4_00 import Nfe
-from nfelib.nfe.ws.edoc_legacy import NFCeAdapter as edoc_nfce, NFeAdapter as edoc_nfe
+from nfelib.nfe.ws.edoc_legacy import NFCeAdapter as edoc_nfce
+from nfelib.nfe.ws.edoc_legacy import NFeAdapter as edoc_nfe
from requests import Session
from xsdata.formats.dataclass.parsers import XmlParser
from xsdata.models.datatype import XmlDateTime
@@ -722,7 +723,7 @@ def _prepare_import_dict(
}
def _build_attr(self, node, fields, vals, path, attr):
- key = "nfe40_%s" % (attr[0],) # TODO schema wise
+ key = f"nfe40_{attr[0]}" # TODO schema wise
value = getattr(node, attr[0])
if key == "nfe40_mod":
@@ -855,7 +856,8 @@ def _check_document_date_key(self):
):
raise ValidationError(
_(
- "The document date does not match the date in the document key."
+ "The document date does not match the date in the document "
+ "key."
)
)
@@ -1053,7 +1055,7 @@ def _exec_after_SITUACAO_EDOC_AUTORIZADA(self, old_state, new_state):
# autorizado, podendo perder dados.
# Se der problema que apareça quando
# o usuário clicar no gerar PDF novamente.
- _logger.error("DANFE Error \n {}".format(e))
+ _logger.error(f"DANFE Error \n {e}")
return super()._exec_after_SITUACAO_EDOC_AUTORIZADA(old_state, new_state)
def _generate_key(self):
@@ -1349,7 +1351,8 @@ def _document_cancel(self, justificative):
if not justificative or len(justificative) < 15:
raise ValidationError(
_(
- "Please enter a justification that is at least 15 characters long."
+ "Please enter a justification that is at least 15 characters "
+ "long."
)
)
result = super()._document_cancel(justificative)
diff --git a/l10n_br_nfe/models/document_line.py b/l10n_br_nfe/models/document_line.py
index 95ef91dc3c05..ca880bf2dbec 100644
--- a/l10n_br_nfe/models/document_line.py
+++ b/l10n_br_nfe/models/document_line.py
@@ -38,7 +38,7 @@
"ICMSSN900",
]
-ICMS_SELECTION = list(map(lambda tag: ("nfe40_%s" % (tag,), tag), ICMS_SUB_TAGS))
+ICMS_SELECTION = list(map(lambda tag: (f"nfe40_{tag}", tag), ICMS_SUB_TAGS))
PIS_SUB_TAGS = [
"PISAliq",
@@ -47,7 +47,7 @@
"PISOutr",
]
-PIS_SELECTION = list(map(lambda tag: ("nfe40_%s" % (tag,), tag), PIS_SUB_TAGS))
+PIS_SELECTION = list(map(lambda tag: (f"nfe40_{tag}", tag), PIS_SUB_TAGS))
COFINS_SUB_TAGS = [
"COFINSAliq",
@@ -56,7 +56,7 @@
"COFINSOutr",
]
-COFINS_SELECTION = list(map(lambda tag: ("nfe40_%s" % (tag,), tag), COFINS_SUB_TAGS))
+COFINS_SELECTION = list(map(lambda tag: (f"nfe40_{tag}", tag), COFINS_SUB_TAGS))
class NFeLine(spec_models.StackedModel):
@@ -1189,27 +1189,21 @@ def map_binding_attr(attr, odoo_attr=None):
# common attributes CST, VBC, p*, v*:
cst = map_binding_attr("CST")
if cst:
- cst_id = self.env.ref(
- "l10n_br_fiscal.cst_%s_%s"
- % (
- kind,
- cst,
- )
- ).id
- odoo_attrs["%s_cst_id" % (kind,)] = cst_id
+ cst_id = self.env.ref(f"l10n_br_fiscal.cst_{kind}_{cst}").id
+ odoo_attrs[f"{kind}_cst_id"] = cst_id
else:
cst_id = None
- map_binding_attr("vBC", "%s_base" % (kind,))
+ map_binding_attr("vBC", f"{kind}_base")
percent = map_binding_attr(
- "p%s" % (kind.upper().replace("ST", ""),), "%s_percent" % (kind,)
+ f"p{kind.upper().replace('ST', '')}", f"{kind}_percent"
)
if kind in ("icms", "icmsufdest"):
map_binding_attr("modBC", "icms_base_type")
icms_percent_red = map_binding_attr("pRedBC", "icms_reduction")
else:
- map_binding_attr("modBC", "%s_base_type" % (kind,))
+ map_binding_attr("modBC", f"{kind}_base_type")
icms_percent_red = None
if "ICMSSN" in key:
@@ -1220,15 +1214,13 @@ def map_binding_attr(attr, odoo_attr=None):
tax_group_kind = "icms"
else:
tax_group_kind = kind
- tax_group_id = self.env.ref(
- "l10n_br_fiscal.tax_group_%s" % (tax_group_kind,)
- ).id
+ tax_group_id = self.env.ref(f"l10n_br_fiscal.tax_group_{tax_group_kind}").id
tax_domain = [("tax_group_id", "=", tax_group_id)]
if percent:
tax_domain.append(("percent_amount", "=", percent))
tax_domain_with_cst = None
if cst_id:
- cst_kind = "cst_%s_id" % (self.env.context.get("edoc_type", "in"),)
+ cst_kind = "cst_{}_id".format(self.env.context.get("edoc_type", "in"))
tax_domain_with_cst = tax_domain + [(cst_kind, "=", cst_id)]
fiscal_tax_id = None
@@ -1256,24 +1248,24 @@ def map_binding_attr(attr, odoo_attr=None):
)
if fiscal_tax_id:
- odoo_attrs["%s_tax_id" % (kind,)] = fiscal_tax_id.id
+ odoo_attrs[f"{kind}_tax_id"] = fiscal_tax_id.id
if not odoo_attrs.get("fiscal_tax_ids"):
odoo_attrs["fiscal_tax_ids"] = []
odoo_attrs["fiscal_tax_ids"].append(fiscal_tax_id.id)
- elif not odoo_attrs.get("%s_tax_id" % (kind,)):
- nt_tax_ref = "l10n_br_fiscal.tax_%s_nt" % (kind,)
+ elif not odoo_attrs.get(f"{kind}_tax_id"):
+ nt_tax_ref = f"l10n_br_fiscal.tax_{kind}_nt"
nt_tax = self.env.ref(nt_tax_ref, raise_if_not_found=False)
if nt_tax: # NOTE, can it be isento or something else?
- odoo_attrs["%s_tax_id" % (kind,)] = nt_tax.id
+ odoo_attrs[f"{kind}_tax_id"] = nt_tax.id
- map_binding_attr("v%s" % (kind.upper(),), "%s_value" % (kind,))
+ map_binding_attr(f"v{kind.upper()}", f"{kind}_value")
if kind in ("icms", "icmsufdest"):
map_binding_attr("orig", "icms_origin")
mot_des_icms = map_binding_attr("motDesICMS")
if mot_des_icms:
odoo_attrs["icms_relief_id"] = self.env.ref(
- "l10n_br_fiscal.icms_relief_%s" % (mot_des_icms,)
+ f"l10n_br_fiscal.icms_relief_{mot_des_icms}"
).id
map_binding_attr("vICMSDeson", "icms_relief_value")
map_binding_attr("vICMSSubstituto", "icms_substitute")
@@ -1314,7 +1306,7 @@ def map_binding_attr(attr, odoo_attr=None):
csosn = map_binding_attr("CSOSN")
if csosn:
odoo_attrs["icms_cst_id"] = self.env.ref(
- "l10n_br_fiscal.cst_icmssn_%s" % (csosn,)
+ f"l10n_br_fiscal.cst_icmssn_{csosn}"
).id
map_binding_attr("pCredSN", "icmssn_percent")
map_binding_attr("vCredICMSSN", "icmssn_credit_value")
diff --git a/l10n_br_nfe/models/invalidate_number.py b/l10n_br_nfe/models/invalidate_number.py
index 2aef652f3634..e4f55023a759 100644
--- a/l10n_br_nfe/models/invalidate_number.py
+++ b/l10n_br_nfe/models/invalidate_number.py
@@ -5,7 +5,8 @@
from erpbrasil.base.misc import punctuation_rm
from erpbrasil.transmissao import TransmissaoSOAP
-from nfelib.nfe.ws.edoc_legacy import NFCeAdapter as edoc_nfce, NFeAdapter as edoc_nfe
+from nfelib.nfe.ws.edoc_legacy import NFCeAdapter as edoc_nfce
+from nfelib.nfe.ws.edoc_legacy import NFeAdapter as edoc_nfe
from requests import Session
from odoo import fields, models
diff --git a/l10n_br_nfe/models/mde.py b/l10n_br_nfe/models/mde.py
index 58236a5bfaf6..ccf637ac73d7 100644
--- a/l10n_br_nfe/models/mde.py
+++ b/l10n_br_nfe/models/mde.py
@@ -112,9 +112,7 @@ def name_get(self):
return [
(
rec.id,
- "NFº: {} ({}): {}".format(
- rec.number, rec.cnpj_cpf, rec.company_id.legal_name
- ),
+ f"NFº: {rec.number} ({rec.cnpj_cpf}): {rec.company_id.legal_name}",
)
for rec in self
]
@@ -244,8 +242,9 @@ def action_download_xml(self):
def download_attachment(self, attachment_id):
return {
"type": "ir.actions.act_url",
- "url": "/web/content/{id}/{nome}?download=true".format(
- id=attachment_id.id, nome=attachment_id.name
+ "url": (
+ f"/web/content/{attachment_id.id}"
+ f"/{attachment_id.name}?download=true"
),
"target": "self",
}
diff --git a/l10n_br_nfe/tests/test_nfe_import_wizard.py b/l10n_br_nfe/tests/test_nfe_import_wizard.py
index c84e43ea9c20..febb7b1fe463 100644
--- a/l10n_br_nfe/tests/test_nfe_import_wizard.py
+++ b/l10n_br_nfe/tests/test_nfe_import_wizard.py
@@ -13,7 +13,7 @@
class NFeImportWizardTest(SavepointCase):
def setUp(self):
- super(NFeImportWizardTest, self).setUp()
+ super().setUp()
def test_xml_path(filename):
return os.path.join(
diff --git a/l10n_br_nfe/tests/test_nfe_mde.py b/l10n_br_nfe/tests/test_nfe_mde.py
index 822873c651a5..af852ca3dae0 100644
--- a/l10n_br_nfe/tests/test_nfe_mde.py
+++ b/l10n_br_nfe/tests/test_nfe_mde.py
@@ -15,19 +15,18 @@
from ..models.mde import MDe
-# flake8: noqa: B950
-response_confirmacao_operacao = """2SVRS2023052515551352SVRS202305251555135Teste Confirmação da Operação.31201010588201000105550010038421171838422178210200Confirmacao de Operacao registrada1815830540001292023-07-10T10:00:00-03:00"""
+response_confirmacao_operacao = """2SVRS2023052515551352SVRS202305251555135Teste Confirmação da Operação.31201010588201000105550010038421171838422178210200Confirmacao de Operacao registrada1815830540001292023-07-10T10:00:00-03:00""" # noqa: E501
-response_confirmacao_operacao_rejeicao = """2SVRS2023052515554942SVRS202305251555494Rejeição: Chave de Acesso inexistente31201010588201000105550010038421171838422178210200Confirmacao de Operacao registrada1815830540001292023-07-10T10:00:00-03:00"""
+response_confirmacao_operacao_rejeicao = """2SVRS2023052515554942SVRS202305251555494Rejeição: Chave de Acesso inexistente31201010588201000105550010038421171838422178210200Confirmacao de Operacao registrada1815830540001292023-07-10T10:00:00-03:00""" # noqa: E501
-response_ciencia_operacao = """2SVRS2023052515551352SVRS202305251555135Teste Ciência da Operação.31201010588201000105550010038421171838422178210210Ciencia da Operacao registrada1815830540001292023-07-10T10:00:00-03:00"""
+response_ciencia_operacao = """2SVRS2023052515551352SVRS202305251555135Teste Ciência da Operação.31201010588201000105550010038421171838422178210210Ciencia da Operacao registrada1815830540001292023-07-10T10:00:00-03:00""" # noqa: E501
-response_desconhecimento_operacao = """2SVRS2023052515551352SVRS202305251555135Teste Desconhecimento da Operação.31201010588201000105550010038421171838422178210220Desconhecimento da Operacao registrada1815830540001292023-07-10T10:00:00-03:00"""
+response_desconhecimento_operacao = """2SVRS2023052515551352SVRS202305251555135Teste Desconhecimento da Operação.31201010588201000105550010038421171838422178210220Desconhecimento da Operacao registrada1815830540001292023-07-10T10:00:00-03:00""" # noqa: E501
-response_operacao_nao_realizada = """2SVRS2023052515551352SVRS202305251555135Teste Operação não Realizada.31201010588201000105550010038421171838422178210240Operacao nao Realizada registrada1815830540001292023-07-10T10:00:00-03:00"""
+response_operacao_nao_realizada = """2SVRS2023052515551352SVRS202305251555135Teste Operação não Realizada.31201010588201000105550010038421171838422178210240Operacao nao Realizada registrada1815830540001292023-07-10T10:00:00-03:00""" # noqa: E501
-class FakeRetorno(object):
+class FakeRetorno:
def __init__(self, text, status_code=200):
self.text = text
self.content = text.encode("utf-8")
@@ -182,7 +181,7 @@ def test_download_documents(self, _mock_post, _mock_ciencia):
self.assertEqual(attachment_single, self.mde_id.attachment_id)
self.assertTrue(attachment_multiple)
- self.assertEqual(attachment_multiple.name, f"attachments.tar.gz")
+ self.assertEqual(attachment_multiple.name, "attachments.tar.gz")
def get_attachment_from_result(self, result):
_, _, _, att_id, _ = result["url"].split("/")
diff --git a/l10n_br_nfe/tests/test_nfe_serialize.py b/l10n_br_nfe/tests/test_nfe_serialize.py
index 3405163a2255..685df94f2430 100644
--- a/l10n_br_nfe/tests/test_nfe_serialize.py
+++ b/l10n_br_nfe/tests/test_nfe_serialize.py
@@ -77,6 +77,6 @@ def serialize_xml(self, nfe_data):
self.cr.dbname,
nfe.send_file_id.store_fname,
)
- _logger.info("XML file saved at %s" % (output,))
+ _logger.info(f"XML file saved at {output}")
diff = main.diff_files(output, xml_path)
return diff
diff --git a/l10n_br_nfe/tests/test_nfe_serialize_lc.py b/l10n_br_nfe/tests/test_nfe_serialize_lc.py
index 93a80266f8c5..8611784c0b05 100644
--- a/l10n_br_nfe/tests/test_nfe_serialize_lc.py
+++ b/l10n_br_nfe/tests/test_nfe_serialize_lc.py
@@ -24,5 +24,5 @@ def setUp(self):
def test_serialize_xml(self):
for nfe_data in self.nfe_list:
diff = self.serialize_xml(nfe_data)
- _logger.info("Diff with expected XML (if any): %s" % (diff,))
+ _logger.info(f"Diff with expected XML (if any): {diff}")
assert len(diff) == 0
diff --git a/l10n_br_nfe/tests/test_nfe_serialize_sn.py b/l10n_br_nfe/tests/test_nfe_serialize_sn.py
index 425e5f0f6e36..6d7aa0e3ad2d 100644
--- a/l10n_br_nfe/tests/test_nfe_serialize_sn.py
+++ b/l10n_br_nfe/tests/test_nfe_serialize_sn.py
@@ -20,5 +20,5 @@ def setUp(self):
def test_serialize_xml(self):
for nfe_data in self.nfe_list:
diff = self.serialize_xml(nfe_data)
- _logger.info("Diff with expected XML (if any): %s" % (diff,))
+ _logger.info(f"Diff with expected XML (if any): {diff}")
assert len(diff) == 0
diff --git a/l10n_br_nfe/tests/test_nfe_structure.py b/l10n_br_nfe/tests/test_nfe_structure.py
index 7d4945fd2d44..861dcbd8d714 100644
--- a/l10n_br_nfe/tests/test_nfe_structure.py
+++ b/l10n_br_nfe/tests/test_nfe_structure.py
@@ -41,15 +41,17 @@ def get_stacked_tree(cls, klass):
path_items = path.split(".")
indent = " ".join(["" for i in range(0, len(path_items))])
if kind == "stacked":
- line = "\n%s> <%s>" % (indent, path.split(".")[-1])
+ line = "\n{}> <{}>".format(indent, path.split(".")[-1])
elif kind == "one2many":
- line = "\n%s \u2261 <%s> %s" % (
+ line = "\n{} \u2261 <{}> {}".format(
indent,
field_path,
child_concrete or "",
)
elif kind == "many2one":
- line = "\n%s - <%s> %s" % (indent, field_path, child_concrete or "")
+ line = "\n{} - <{}> {}".format(
+ indent, field_path, child_concrete or ""
+ )
tree.write(line.rstrip())
tree_txt = tree.getvalue()
# print(tree_txt)
diff --git a/l10n_br_nfe/wizards/import_document.py b/l10n_br_nfe/wizards/import_document.py
index 463fba2926ac..850927897ae2 100644
--- a/l10n_br_nfe/wizards/import_document.py
+++ b/l10n_br_nfe/wizards/import_document.py
@@ -233,7 +233,7 @@ def _set_fiscal_operation_type(self):
def _attach_original_nfe_xml_to_document(self, edoc):
return self.env["ir.attachment"].create(
{
- "name": "NFe-Importada-{}.xml".format(edoc.document_key),
+ "name": f"NFe-Importada-{edoc.document_key}.xml",
"datas": base64.b64decode(self.file),
"description": "XML NFe - Importada por XML",
"res_model": "l10n_br_fiscal.document",
diff --git a/l10n_br_nfe/wizards/l10n_br_account_nfe_export_invoice.py b/l10n_br_nfe/wizards/l10n_br_account_nfe_export_invoice.py
index 7e3dd7983e8a..84310e44f721 100644
--- a/l10n_br_nfe/wizards/l10n_br_account_nfe_export_invoice.py
+++ b/l10n_br_nfe/wizards/l10n_br_account_nfe_export_invoice.py
@@ -119,7 +119,7 @@ def nfe_export(self):
data.file_type,
)
else:
- name = "nfe{}.{}".format(export_inv_numbers[0], data.file_type)
+ name = f"nfe{export_inv_numbers[0]}.{data.file_type}"
mod_serializer = __import__(
("openerp.addons.l10n_br_account_product" ".sped.nfe.serializer.")
diff --git a/l10n_br_nfse_barueri/models/document.py b/l10n_br_nfse_barueri/models/document.py
index 0d48544b99e0..321ab7f5820f 100644
--- a/l10n_br_nfse_barueri/models/document.py
+++ b/l10n_br_nfse_barueri/models/document.py
@@ -82,7 +82,8 @@ def _serialize_barueri_lote_rps(self):
rps = rps.encode("utf-8")
if not isinstance(rps, bytes):
raise ValueError(
- "O conteúdo fornecido para a codificação base64 não está em formato de bytes."
+ "O conteúdo fornecido para a codificação base64 não está em formato"
+ " de bytes."
)
rps = base64.b64encode(rps)
diff --git a/l10n_br_nfse_focus/models/document.py b/l10n_br_nfse_focus/models/document.py
index 56d14e9deec8..3316f99fa989 100644
--- a/l10n_br_nfse_focus/models/document.py
+++ b/l10n_br_nfse_focus/models/document.py
@@ -56,8 +56,10 @@ def _make_focus_nfse_http_request(self, method, url, token, data=None, params=No
method (str): The HTTP method to use (e.g., 'GET', 'POST').
url (str): The URL to which the request is sent.
token (str): The authentication token for the service.
- data (dict, optional): The payload to send in the request body. Defaults to None.
- params (dict, optional): The URL parameters to append to the URL. Defaults to None.
+ data (dict, optional): The payload to send in the request body.
+ Defaults to None.
+ params (dict, optional): The URL parameters to append to the URL.
+ Defaults to None.
Returns:
requests.Response: The response object from the requests library.
@@ -600,7 +602,8 @@ def _cron_document_status_focus(self):
None.
Returns:
- None. Updates the status of each document based on the NFSe provider's response.
+ None. Updates the status of each document based on the NFSe provider's
+ response.
"""
records = (
self.search([("state", "in", ["enviada"])], limit=25)
diff --git a/l10n_br_nfse_focus/tests/test_l10n_br_nfse_focus.py b/l10n_br_nfse_focus/tests/test_l10n_br_nfse_focus.py
index c721c71dac42..e0346143eeda 100644
--- a/l10n_br_nfse_focus/tests/test_l10n_br_nfse_focus.py
+++ b/l10n_br_nfse_focus/tests/test_l10n_br_nfse_focus.py
@@ -175,7 +175,8 @@ def test_filter_processador_edoc_nfse(self):
self.assertEqual(result, True) # Asserting filter result is True
record.processador_edoc = None # Resetting document processor
- record.document_type_id.code = MODELO_FISCAL_NFE # Setting document type to NFe
+ # Setting document type to NFe
+ record.document_type_id.code = MODELO_FISCAL_NFE
result = filter_processador_edoc_nfse(record) # Applying filter again
@@ -215,7 +216,9 @@ def test_processar_documento(self, mock_post):
@patch("odoo.addons.l10n_br_nfse_focus.models.document.requests.request")
def test_make_focus_nfse_http_request_generic(self, mock_request):
- """Tests generic HTTP request for Focus NFSe operations with mocked responses."""
+ """
+ Tests generic HTTP request for Focus NFSe operations with mocked responses.
+ """
# Configuring mock to simulate different HTTP responses based on the method
mock_request.side_effect = (
lambda method, url, data, params, auth: mock_response_based_on_method(
@@ -333,7 +336,8 @@ def test_make_focus_nfse_pdf(self):
self.assertEqual(
record.file_report_id.res_model, record._name
) # Asserting model name
- self.assertEqual(record.file_report_id.res_id, record.id) # Asserting record ID
+ # Asserting record ID
+ self.assertEqual(record.file_report_id.res_id, record.id)
self.assertEqual(
record.file_report_id.mimetype, "application/pdf"
) # Asserting MIME type
@@ -350,7 +354,8 @@ def test_make_focus_nfse_pdf(self):
# Testing with non-filtered conditions
record.processador_edoc = ""
- record.document_type_id.code = MODELO_FISCAL_NFE # Setting document type to NFe
+ # Setting document type to NFe
+ record.document_type_id.code = MODELO_FISCAL_NFE
with open(pdf_path, "rb") as file:
content = file.read() # Reading PDF content again
@@ -360,7 +365,8 @@ def test_make_focus_nfse_pdf(self):
) as mock_super_make_pdf:
record.make_focus_nfse_pdf(content) # Attempting to generate PDF
- mock_super_make_pdf.assert_called_once() # Asserting superclass method called once
+ # Asserting superclass method called once
+ mock_super_make_pdf.assert_called_once()
def test_serialize(self):
"""Tests serialization of document data."""
@@ -436,7 +442,8 @@ def test_document_status(self, mock_query):
)
def test_cancel_document_focus_with_error(self, mock_request):
"""Tests document cancellation with simulated error."""
- # Configuring mock to raise a UserError in response to a simulated HTTP 400 error
+ # Configuring mock to raise a UserError in response to a simulated
+ # HTTP 400 error
mock_request.side_effect = UserError(
"Error communicating with NFSe service: 400 Bad Request"
)
@@ -530,7 +537,8 @@ def test_eletronic_document_send(self, mock_process_focus_nfse_document):
"after processing with status 500",
)
- # Checking if the processing method was called three times, once for each test scenario
+ # Checking if the processing method was called three times,
+ # once for each test scenario
self.assertEqual(
mock_process_focus_nfse_document.call_count,
3,
@@ -549,7 +557,8 @@ def test_cron_document_status_focus(self):
"odoo.addons.l10n_br_nfse_focus.models.document.Document.filtered"
) as mock_filtered:
with patch(
- "odoo.addons.l10n_br_nfse_focus.models.document.Document._document_status"
+ "odoo.addons.l10n_br_nfse_focus.models.document."
+ "Document._document_status"
) as mock_document_status:
mock_search.return_value = record # Mocking search return
mock_filtered.return_value = record # Mocking filtered return
@@ -560,7 +569,8 @@ def test_cron_document_status_focus(self):
mock_search.assert_called_once_with(
[("state", "in", ["enviada"])], limit=25
) # Asserting search criteria
- mock_document_status.assert_called_once() # Asserting document status check
+ # Asserting document status check
+ mock_document_status.assert_called_once()
@patch(
"odoo.addons.l10n_br_nfse_focus.models.document.Document.cancel_document_focus"
@@ -574,7 +584,8 @@ def test_exec_before_SITUACAO_EDOC_CANCELADA(self, mock_cancel_document_focus):
result = record._exec_before_SITUACAO_EDOC_CANCELADA(
SITUACAO_EDOC_EM_DIGITACAO, SITUACAO_EDOC_A_ENVIAR
) # Executing before status change
- mock_cancel_document_focus.assert_called_once() # Asserting cancellation was attempted
+ # Asserting cancellation was attempted
+ mock_cancel_document_focus.assert_called_once()
self.assertEqual(
result, mock_cancel_document_focus.return_value
) # Asserting expected result
diff --git a/l10n_br_pos/models/cfop.py b/l10n_br_pos/models/cfop.py
index ca557b33ccc0..0fbb24282965 100644
--- a/l10n_br_pos/models/cfop.py
+++ b/l10n_br_pos/models/cfop.py
@@ -9,5 +9,5 @@ class CFOP(models.Model):
is_pos = fields.Boolean(
string="Allowed at the POS",
- help="""Check this selection so that the CFOP can be used at the Point of Sale.""",
+ help="Check this selection so that the CFOP can be used at the Point of Sale.",
)
diff --git a/l10n_br_pos/models/pos_config.py b/l10n_br_pos/models/pos_config.py
index f8b2b21e955d..1f58a50e199a 100644
--- a/l10n_br_pos/models/pos_config.py
+++ b/l10n_br_pos/models/pos_config.py
@@ -27,7 +27,7 @@ def _compute_allowed_tax(self):
if record.cfop_ids and record.out_pos_fiscal_operation_id:
record.out_pos_fiscal_operation_line_ids = (
record.out_pos_fiscal_operation_id.line_ids.filtered(
- lambda x: x.cfop_internal_id in record.cfop_ids
+ lambda x, record=record: x.cfop_internal_id in record.cfop_ids
)
)
else:
@@ -66,7 +66,8 @@ def _compute_allowed_tax(self):
anonymous_simplified_limit = fields.Float(
digits="Account",
- help="Over this amount is not legally posible to create a Anonymous NFC-E / CF-e",
+ help="Over this amount is not legally posible to create a Anonymous "
+ "NFC-E / CF-e",
default=10000,
)
diff --git a/l10n_br_pos_cfe/static/src/js/ChromeWidgets/ProxyStatus.js b/l10n_br_pos_cfe/static/src/js/ChromeWidgets/ProxyStatus.js
index c0aa22b314fc..7a349c4f7a34 100644
--- a/l10n_br_pos_cfe/static/src/js/ChromeWidgets/ProxyStatus.js
+++ b/l10n_br_pos_cfe/static/src/js/ChromeWidgets/ProxyStatus.js
@@ -9,7 +9,7 @@ odoo.define("l10n_br_pos_cfe.ProxyStatus", function (require) {
var Registries = require("point_of_sale.Registries");
var ProxyStatus = require("point_of_sale.ProxyStatus");
- const CFeProxyStatus = (ProxyStatus_status = ProxyStatus) =>
+ const CustomCFeProxyStatus = (ProxyStatus_status = ProxyStatus) =>
class CFeProxyStatus extends ProxyStatus_status {
_setStatus(newStatus) {
super._setStatus(newStatus);
@@ -31,5 +31,5 @@ odoo.define("l10n_br_pos_cfe.ProxyStatus", function (require) {
}
}
};
- Registries.Component.extend(ProxyStatus, CFeProxyStatus);
+ Registries.Component.extend(ProxyStatus, CustomCFeProxyStatus);
});
diff --git a/l10n_br_purchase/reports/purchase_report.py b/l10n_br_purchase/reports/purchase_report.py
index dd941dc756c4..f70a830bc5f5 100644
--- a/l10n_br_purchase/reports/purchase_report.py
+++ b/l10n_br_purchase/reports/purchase_report.py
@@ -103,8 +103,8 @@ def _select(self):
, SUM(l.freight_value) as freight_value
, SUM(l.insurance_value) as insurance_value
, SUM(l.other_value) as other_value
- , SUM(l.price_unit / COALESCE(NULLIF(po.currency_rate, 0), 1.0) * l.product_qty
- )::decimal(16,2)
+ , SUM(l.price_unit / COALESCE(NULLIF(po.currency_rate, 0), 1.0)
+ * l.product_qty )::decimal(16,2)
+ SUM(CASE WHEN l.ipi_value IS NULL THEN
0.00 ELSE l.ipi_value END)
+ SUM(CASE WHEN l.icmsst_value IS NULL THEN
diff --git a/l10n_br_purchase/tests/test_l10n_br_purchase.py b/l10n_br_purchase/tests/test_l10n_br_purchase.py
index fddd5f00ef3f..ad0e63d26cfc 100644
--- a/l10n_br_purchase/tests/test_l10n_br_purchase.py
+++ b/l10n_br_purchase/tests/test_l10n_br_purchase.py
@@ -262,17 +262,20 @@ def _invoice_purchase_order(self, order):
self.assertEqual(
order.amount_freight_value,
invoice.amount_freight_value,
- "Error field Amount Freight in Invoice are different from Purchase Order.",
+ "Error field Amount Freight in Invoice are different from "
+ "Purchase Order.",
)
self.assertEqual(
order.amount_insurance_value,
invoice.amount_insurance_value,
- "Error field Amount Insurance in Invoice are different from Purchase Order.",
+ "Error field Amount Insurance in Invoice are different from "
+ "Purchase Order.",
)
self.assertEqual(
order.amount_other_value,
invoice.amount_other_value,
- "Error field Amount Other Values in Invoice are different from Purchase Order.",
+ "Error field Amount Other Values in Invoice are different from "
+ "Purchase Order.",
)
for line in invoice.invoice_line_ids:
@@ -590,7 +593,9 @@ def test_purchase_service_and_products(self):
)
def test_compatible_with_international_case(self):
- """Test of compatible with international case, create Invoice but not for Brazil."""
+ """
+ Test of compatible with international case, create Invoice but not for Brazil.
+ """
po_international = self.env.ref("purchase.purchase_order_1")
self._run_purchase_order_onchanges(po_international)
for line in po_international.order_line:
diff --git a/l10n_br_purchase_stock/tests/test_l10n_br_purchase_stock.py b/l10n_br_purchase_stock/tests/test_l10n_br_purchase_stock.py
index fce9ffbb07ea..ac3e2a4a2ba4 100644
--- a/l10n_br_purchase_stock/tests/test_l10n_br_purchase_stock.py
+++ b/l10n_br_purchase_stock/tests/test_l10n_br_purchase_stock.py
@@ -183,7 +183,8 @@ def test_purchase_order_lucro_presumido(self):
# self.assertEqual(inv_line.price_unit,
# inv_line.purchase_line_id.price_unit)
# AssertionError: 82.53 != 100.0
- # self.assertEqual(inv_line.price_unit, inv_line.purchase_line_id.price_unit)
+ # self.assertEqual(inv_line.price_unit,
+ # inv_line.purchase_line_id.price_unit)
# Valida presença dos campos principais para o mapeamento Fiscal
self.assertTrue(inv_line.fiscal_operation_id, "Missing Fiscal Operation.")
self.assertTrue(
diff --git a/l10n_br_repair/models/repair_order.py b/l10n_br_repair/models/repair_order.py
index 845f959f3184..e041fcf89d6f 100644
--- a/l10n_br_repair/models/repair_order.py
+++ b/l10n_br_repair/models/repair_order.py
@@ -138,11 +138,7 @@ def _compute_get_invoiced(self):
"move_id"
).filtered(
lambda r: r.move_type in ["out_invoice", "out_refund"]
- ) + order.fees_lines.mapped(
- "invoice_line_id"
- ).mapped(
- "move_id"
- ).filtered(
+ ) + order.fees_lines.mapped("invoice_line_id").mapped("move_id").filtered(
lambda r: r.move_type in ["out_invoice", "out_refund"]
)
# Search for invoices which have been
@@ -158,7 +154,7 @@ def _compute_get_invoiced(self):
)
invoice_ids |= refunds.filtered(
- lambda r: order.name
+ lambda r, order=order: order.name
in [
invoice_origin.strip()
for invoice_origin in r.invoice_origin.split(",")
diff --git a/l10n_br_resource/wizards/workalendar_holiday_import_wizard.py b/l10n_br_resource/wizards/workalendar_holiday_import_wizard.py
index b18ea5f24f2a..e84edf01e894 100644
--- a/l10n_br_resource/wizards/workalendar_holiday_import_wizard.py
+++ b/l10n_br_resource/wizards/workalendar_holiday_import_wizard.py
@@ -65,7 +65,7 @@ def get_calendar_for_country(self):
calendar = self.env["resource.calendar"].create(
{
"name": "Calendar " + country.name,
- "country_id": country.id
+ "country_id": country.id,
# '':u'N',
}
)
diff --git a/l10n_br_sale/models/sale_order.py b/l10n_br_sale/models/sale_order.py
index 5fa1b5c89604..d1eab916767f 100644
--- a/l10n_br_sale/models/sale_order.py
+++ b/l10n_br_sale/models/sale_order.py
@@ -151,7 +151,6 @@ def _onchange_fiscal_operation_id(self):
return result
def _get_invoiceable_lines(self, final=False):
-
lines = super()._get_invoiceable_lines(final=final)
if not self.fiscal_operation_id:
# O caso Brasil se caracteriza por ter a Operação Fiscal
diff --git a/l10n_br_sale/tests/test_l10n_br_sale.py b/l10n_br_sale/tests/test_l10n_br_sale.py
index 2644026709e2..38317ccf7579 100644
--- a/l10n_br_sale/tests/test_l10n_br_sale.py
+++ b/l10n_br_sale/tests/test_l10n_br_sale.py
@@ -290,7 +290,7 @@ def test_l10n_br_sale_products(self):
self.assertEqual(
line.cfop_id.code,
cfop.code,
- "Error to mapping CFOP {} for {}.".format(cfop.code, cfop.name),
+ f"Error to mapping CFOP {cfop.code} for {cfop.name}.",
)
if line.company_id.tax_framework in TAX_FRAMEWORK_SIMPLES_ALL:
@@ -616,7 +616,9 @@ def test_fields_freight_insurance_other_costs(self):
)
def test_compatible_with_international_case(self):
- """Test of compatible with international case, create Invoice but not for Brazil."""
+ """
+ Test of compatible with international case, create Invoice but not for Brazil.
+ """
so_international = self.env.ref("sale.sale_order_2")
self._run_sale_order_onchanges(so_international)
for line in so_international.order_line:
diff --git a/l10n_br_stock/hooks.py b/l10n_br_stock/hooks.py
index fb5c11bd31d4..418037f9cd02 100644
--- a/l10n_br_stock/hooks.py
+++ b/l10n_br_stock/hooks.py
@@ -16,64 +16,62 @@ def set_stock_warehouse_external_ids(env, company_external_id):
data_list = [
{
- "xml_id": "l10n_br_stock.wh_{}".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}",
"record": warehouse,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_loc_stock_id".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_loc_stock_id",
"record": warehouse.lot_stock_id,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_view_location".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_view_location",
"record": warehouse.view_location_id,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_input_location".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_input_location",
"record": warehouse.wh_input_stock_loc_id,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_quality_control_location".format(
- external_id
- ),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_quality_control_location",
"record": warehouse.wh_qc_stock_loc_id,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_pack_location".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_pack_location",
"record": warehouse.wh_pack_stock_loc_id,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_output_location".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_output_location",
"record": warehouse.wh_pack_stock_loc_id,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_picking_type_in".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_picking_type_in",
"record": warehouse.in_type_id,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_picking_type_internal".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_picking_type_internal",
"record": warehouse.int_type_id,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_pick_type_internal".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_pick_type_internal",
"record": warehouse.pick_type_id,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_pack_type_internal".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_pack_type_internal",
"record": warehouse.pack_type_id,
"noupdate": True,
},
{
- "xml_id": "l10n_br_stock.wh_{}_picking_type_out".format(external_id),
+ "xml_id": f"l10n_br_stock.wh_{external_id}_picking_type_out",
"record": warehouse.out_type_id,
"noupdate": True,
},
diff --git a/l10n_br_stock_account/models/stock_picking_type.py b/l10n_br_stock_account/models/stock_picking_type.py
index c4fe666d10a3..9ffe0f04fb39 100644
--- a/l10n_br_stock_account/models/stock_picking_type.py
+++ b/l10n_br_stock_account/models/stock_picking_type.py
@@ -22,5 +22,6 @@ class StockPickingType(models.Model):
],
default="none",
string="Pré generate Fiscal Document Number",
- help="Check this box if you want to generate fiscal document for this operation.",
+ help="Check this box if you want to generate fiscal document for this "
+ "operation.",
)
diff --git a/l10n_br_stock_account/tests/test_invoicing_picking.py b/l10n_br_stock_account/tests/test_invoicing_picking.py
index 2bdf4fe484b3..1ccc53676d96 100644
--- a/l10n_br_stock_account/tests/test_invoicing_picking.py
+++ b/l10n_br_stock_account/tests/test_invoicing_picking.py
@@ -141,7 +141,7 @@ def test_picking_invoicing_by_product2(self):
self.assertEqual(inv_line.quantity, 4)
# Price Unit e Fiscal Price devem ser positivos
price_unit_mv_line = picking.move_lines.filtered(
- lambda mv: mv.product_id == inv_line.product_id
+ lambda mv, inv_line=inv_line: mv.product_id == inv_line.product_id
).mapped("price_unit")[0]
self.assertEqual(
inv_line.price_unit,
@@ -157,7 +157,8 @@ def test_picking_invoicing_by_product2(self):
# isso não acontece no caso da empresa de Lucro Presumido
# ou quando é feito o teste apenas instalando os modulos
# l10n_br_account e em seguida o l10n_br_stock_account
- # self.assertTrue(inv_line.tax_ids, "Error to map Sale Tax in invoice.line.")
+ # self.assertTrue(inv_line.tax_ids,
+ # "Error to map Sale Tax in invoice.line.")
# Now test behaviour if the invoice is delete
invoice.unlink()
@@ -319,7 +320,7 @@ def test_invoicing_picking_lucro_presumido(self):
assert line.ind_final, "Error field ind_final in Invoice Line not None"
# Verifica se o campo tax_ids da Fatura esta igual ao da Separação
mv_line = picking.move_lines.filtered(
- lambda ln: ln.product_id == line.product_id
+ lambda ln, line=line: ln.product_id == line.product_id
and ln.fiscal_operation_id == line.fiscal_operation_id
)
self.assertEqual(
@@ -467,7 +468,9 @@ def test_fields_freight_insurance_other_costs(self):
)
def test_compatible_with_international_case(self):
- """Test of compatible with international case, create Invoice but not for Brazil."""
+ """
+ Test of compatible with international case, create Invoice but not for Brazil.
+ """
picking = self.env.ref("stock_picking_invoicing.stock_picking_invoicing_2")
self._run_fiscal_onchanges(picking)
# Force product availability
diff --git a/l10n_br_stock_account/wizards/stock_invoice_onshipping.py b/l10n_br_stock_account/wizards/stock_invoice_onshipping.py
index 769d06002879..c82566949c9e 100644
--- a/l10n_br_stock_account/wizards/stock_invoice_onshipping.py
+++ b/l10n_br_stock_account/wizards/stock_invoice_onshipping.py
@@ -60,7 +60,8 @@ def _get_journal(self):
raise UserError(
_(
"Invalid Journal! There is not journal defined"
- " for this company: %(company)s in fiscal operation: %(operation)s!",
+ " for this company: %(company)s in fiscal operation:"
+ " %(operation)s!",
company=picking.company_id.name,
operation=picking.fiscal_operation_id.name,
)
diff --git a/l10n_br_stock_account_report/wizards/l10n_br_p7_model_inventory_report_wizard.py b/l10n_br_stock_account_report/wizards/l10n_br_p7_model_inventory_report_wizard.py
index 5c413c0c4c0d..4e8164781d78 100644
--- a/l10n_br_stock_account_report/wizards/l10n_br_p7_model_inventory_report_wizard.py
+++ b/l10n_br_stock_account_report/wizards/l10n_br_p7_model_inventory_report_wizard.py
@@ -228,7 +228,7 @@ def lines(self):
tmp_total_value_ncm = round(product_inventory_value, account_precision)
# A validação abaixo é necessária p/
# não preencher a primeira linha
- if type(tmp_ncm_controler) is not bool:
+ if not isinstance(tmp_ncm_controler, bool):
tmp_ncm_controler_line = True
result_lines.append(
diff --git a/l10n_br_website_sale/controllers/main.py b/l10n_br_website_sale/controllers/main.py
index 84242bdd0b18..384b0c7d1e39 100644
--- a/l10n_br_website_sale/controllers/main.py
+++ b/l10n_br_website_sale/controllers/main.py
@@ -100,7 +100,7 @@ def address(self, **kw):
and res.qcontext["checkout"]["city_id"]
):
state_id = res.qcontext["checkout"]["state_id"]
- if type(state_id) is not str:
+ if not isinstance(state_id, str):
state_id = state_id.id
elif state_id:
state_id = int(state_id)
@@ -135,7 +135,8 @@ def values_postprocess(self, order, mode, values, errors, error_msg):
"vat",
]
- # Update new_values for each expected field if it exists in values and not in errors
+ # Update new_values for each expected field if it exists in values and not in
+ # errors
for field in expected_fields:
if field in values and field not in errors:
new_values[field] = values[field]
diff --git a/l10n_br_zip/models/l10n_br_zip.py b/l10n_br_zip/models/l10n_br_zip.py
index 8dc5d45ddcd9..dd2d18291bf5 100644
--- a/l10n_br_zip/models/l10n_br_zip.py
+++ b/l10n_br_zip/models/l10n_br_zip.py
@@ -60,7 +60,8 @@ def _set_domain(
if not state_id or not city_id or len(street_name or "") == 0:
raise UserError(
_(
- "It is necessary to inform the State, municipality and public place"
+ "It is necessary to inform the State, municipality and public "
+ "place"
)
)
diff --git a/payment_pagseguro/models/payment_transaction.py b/payment_pagseguro/models/payment_transaction.py
index 06b89fa0ba32..74fd90533d8c 100644
--- a/payment_pagseguro/models/payment_transaction.py
+++ b/payment_pagseguro/models/payment_transaction.py
@@ -92,7 +92,7 @@ def pagseguro_s2s_capture_transaction(self):
)
if (
- type(res) is dict
+ isinstance(res, dict)
and res.get("payment_response")
and res.get("payment_response").get("message") == "SUCESSO"
):
@@ -136,7 +136,7 @@ def pagseguro_s2s_void_transaction(self):
)
if (
- type(res) is dict
+ isinstance(res, dict)
and res.get("payment_response")
and res.get("payment_response").get("message") == "SUCESSO"
):
diff --git a/spec_driven_model/hooks.py b/spec_driven_model/hooks.py
index 5fc8ab44249d..2053cfeb714a 100644
--- a/spec_driven_model/hooks.py
+++ b/spec_driven_model/hooks.py
@@ -89,7 +89,7 @@ def register_hook(env, module_name, spec_module, force=False):
Odoo models and we make them concrete automatically with
their _auto_init method that will create their SQL DDL structure.
"""
- load_key = "_%s_loaded" % (spec_module,)
+ load_key = f"_{spec_module}_loaded"
if hasattr(env.registry, load_key) and not force: # already done for registry
return
setattr(env.registry, load_key, True)
@@ -149,7 +149,7 @@ def register_hook(env, module_name, spec_module, force=False):
],
access_data,
)
- hook_key = "_%s_need_hook" % (module_name,)
+ hook_key = f"_{module_name}_need_hook"
if hasattr(env.registry, hook_key) and getattr(env.registry, hook_key):
env.registry.init_models(env.cr, remaining_models, {"module": module_name})
setattr(env.registry, hook_key, False)
diff --git a/spec_driven_model/models/spec_export.py b/spec_driven_model/models/spec_export.py
index 52911fd4ad91..cf0072e4d4eb 100644
--- a/spec_driven_model/models/spec_export.py
+++ b/spec_driven_model/models/spec_export.py
@@ -33,7 +33,7 @@ def _get_spec_classes(self, classes=False):
for c in set(classes):
if c is None:
continue
- if not c.startswith("%s." % (self._schema_name,)):
+ if not c.startswith(f"{self._schema_name}."):
continue
# the following filter to fields to show
# when several XSD class are injected in the same object
@@ -150,7 +150,7 @@ def _export_field(self, xsd_field, class_obj, field_spec, export_value=None):
return self._export_float_monetary(
xsd_field, xsd_type, class_obj, xsd_required, export_value
)
- elif type(self[xsd_field]) is str:
+ elif isinstance(self[xsd_field], str):
return self[xsd_field].strip()
else:
return self[xsd_field]
@@ -188,7 +188,7 @@ def _export_float_monetary(
tdec = "".join(filter(lambda x: x.isdigit(), xsd_type))[-2:]
else:
tdec = ""
- my_format = "%.{}f".format(tdec)
+ my_format = f"%.{tdec}f"
return str(my_format % field_data)
def _export_date(self, field_name):
diff --git a/spec_driven_model/models/spec_import.py b/spec_driven_model/models/spec_import.py
index e1c59e00fbeb..7707e4b5cc10 100644
--- a/spec_driven_model/models/spec_import.py
+++ b/spec_driven_model/models/spec_import.py
@@ -72,11 +72,11 @@ def _build_attr(self, node, fields, vals, path, attr):
value = getattr(node, attr[0])
if value is None or value == []:
return False
- key = "%s%s" % (
+ key = "{}{}".format(
self._field_prefix,
attr[1].metadata.get("name", attr[0]),
)
- child_path = "%s.%s" % (path, key)
+ child_path = f"{path}.{key}"
# Is attr a xsd SimpleType or a ComplexType?
# with xsdata a ComplexType can have a type like:
@@ -118,7 +118,7 @@ def _build_attr(self, node, fields, vals, path, attr):
comodel_name = fields[key].comodel_name
else:
clean_type = binding_type.lower()
- comodel_name = "%s.%s.%s" % (
+ comodel_name = "{}.{}.{}".format(
self._schema_name,
self._schema_version.replace(".", "")[0:2],
clean_type.split(".")[-1],
@@ -207,7 +207,7 @@ def _prepare_import_dict(
fields = model._fields
for k, v in fields.items():
# select schema choices for a friendly UI:
- if k.startswith("%schoice" % (self._field_prefix,)):
+ if k.startswith(f"{self._field_prefix}choice"):
for item in v.selection or []:
if vals.get(item[0]) not in [None, []]:
vals[k] = item[0]
@@ -284,8 +284,8 @@ def match_record(self, rec_dict, parent_dict, model=None):
if match_ids:
if len(match_ids) > 1:
_logger.warning(
- "!! WARNING more than 1 record found!! model: %s, domain: %s"
- % (model, domain)
+ f"!! WARNING more than 1 record found!! model: {model},"
+ f" domain:{domain}"
)
return match_ids[0].id
return False
diff --git a/spec_driven_model/models/spec_mixin.py b/spec_driven_model/models/spec_mixin.py
index 25527b2e3201..8309e7284857 100644
--- a/spec_driven_model/models/spec_mixin.py
+++ b/spec_driven_model/models/spec_mixin.py
@@ -38,10 +38,7 @@ def _auto_fill_access_data(cls, env, module_name: str, access_data: list):
"""
underline_name = cls._name.replace(".", "_")
- model_id = "%s_spec.model_%s" % (
- module_name,
- underline_name,
- )
+ model_id = f"{module_name}_spec.model_{underline_name}"
user_access_name = f"access_{underline_name}_user"
if not env["ir.model.access"].search(
[
@@ -54,7 +51,7 @@ def _auto_fill_access_data(cls, env, module_name: str, access_data: list):
user_access_name,
user_access_name,
model_id,
- "%s.group_user" % (module_name,),
+ f"{module_name}.group_user",
"1",
"0",
"0",
@@ -73,7 +70,7 @@ def _auto_fill_access_data(cls, env, module_name: str, access_data: list):
manager_access_name,
manager_access_name,
model_id,
- "%s.group_manager" % (module_name,),
+ f"{module_name}.group_manager",
"1",
"1",
"1",
diff --git a/spec_driven_model/models/spec_models.py b/spec_driven_model/models/spec_models.py
index 8feec21f2e4c..4aa682bca5c3 100644
--- a/spec_driven_model/models/spec_models.py
+++ b/spec_driven_model/models/spec_models.py
@@ -91,14 +91,14 @@ class as long as generated class inherit from some
cr.execute(
"SELECT name FROM ir_module_module "
- "WHERE name=%s "
+ "WHERE name=%(name)s "
"AND state in ('to install', 'to upgrade', 'to remove')",
- (pool[super_parent]._odoo_module,),
+ {"name": pool[super_parent]._odoo_module},
)
if cr.fetchall():
setattr(
pool,
- "_%s_need_hook" % (pool[super_parent]._odoo_module,),
+ f"_{pool[super_parent]._odoo_module}_need_hook",
True,
)
@@ -192,7 +192,7 @@ def _map_concrete(cls, key, target, quiet=False):
if not hasattr(models.MetaModel, "mixin_mappings"):
models.MetaModel.mixin_mappings = {}
if not quiet:
- _logger.debug("%s ---> %s" % (key, target))
+ _logger.debug(f"{key} ---> {target}")
models.MetaModel.mixin_mappings[key] = target
@classmethod
@@ -207,7 +207,8 @@ def spec_module_classes(cls, spec_module):
Cache the list of spec_module classes to save calls to
slow reflection API.
"""
- spec_module_attr = "_spec_cache_%s" % (spec_module.replace(".", "_"),)
+
+ spec_module_attr = f"_spec_cache_{spec_module.replace('.', '_')}"
if not hasattr(cls, spec_module_attr):
setattr(
cls, spec_module_attr, getmembers(sys.modules[spec_module], isclass)
@@ -265,7 +266,7 @@ class StackedModel(SpecModel):
def _build_model(cls, pool, cr):
# inject all stacked m2o as inherited classes
if cls._stacked:
- _logger.info("building StackedModel %s %s" % (cls._name, cls))
+ _logger.info(f"building StackedModel {cls._name} {cls}")
node = cls._odoo_name_to_class(cls._stacked, cls._spec_module)
env = api.Environment(cr, SUPERUSER_ID, {})
for kind, klass, _path, _field_path, _child_concrete in cls._visit_stack(
@@ -344,7 +345,7 @@ def _visit_stack(cls, env, node, path=None):
):
# then we will STACK the child in the current class
child._stack_path = path
- child_path = "%s.%s" % (path, field_path)
+ child_path = f"{path}.{field_path}"
cls._stacking_points[name] = env[node._name]._fields.get(name)
yield from cls._visit_stack(env, child, child_path)
else:
diff --git a/spec_driven_model/models/spec_view.py b/spec_driven_model/models/spec_view.py
index a3cad41e326d..41714292c4cf 100644
--- a/spec_driven_model/models/spec_view.py
+++ b/spec_driven_model/models/spec_view.py
@@ -79,7 +79,7 @@ def fields_view_get(
if field["type"] in ["one2many", "many2one"]:
field["views"] = {} # no inline views
res["fields"][field_name] = field
- field_nodes = doc.xpath("//field[@name='%s']" % (field_name,))
+ field_nodes = doc.xpath(f"//field[@name='{field_name}']")
for field_node in field_nodes:
setup_modifiers(field_node, field)
@@ -114,7 +114,7 @@ def _build_spec_fragment(self, container=None):
classes = [x._name for x in type(lib_model).mro() if hasattr(x, "_name")]
# _logger.info("#####", lib_model, classes)
for c in set(classes):
- if c is None or not c.startswith("%s." % (self._schema_name,)):
+ if c is None or not c.startswith(f"{self._schema_name}."):
continue
# the following filter to fields to show
# when several XSD class are injected in the same object
@@ -148,7 +148,7 @@ def build_arch(self, lib_node, view_node, fields, depth=0):
# skip automatic m2 fields, non xsd fields
# and display choice selector only where it is used
# (possibly later)
- choice_prefix = "%schoice" % (self._field_prefix,)
+ choice_prefix = f"{self._field_prefix}choice"
if (
"_id" in field_name
or self._field_prefix not in field_name
@@ -164,10 +164,7 @@ def build_arch(self, lib_node, view_node, fields, depth=0):
# should we create a choice block?
if hasattr(field, "choice"):
choice = field.choice
- selector_name = "%s%s" % (
- choice_prefix,
- choice,
- )
+ selector_name = f"{choice_prefix}{choice}"
if choice not in choices:
choices.add(choice)
fields.append(selector_name)
@@ -190,7 +187,7 @@ def build_arch(self, lib_node, view_node, fields, depth=0):
else: # assume dynamically required via attrs
pass
if selector_name is not None:
- invisible = [("%s" % (selector_name,), "!=", field_name)]
+ invisible = [(f"{selector_name}", "!=", field_name)]
attrs = {"invisible": invisible}
else:
attrs = False
@@ -233,7 +230,7 @@ def _build_form_simple_type(
# TODO if inside optionaly visible group, required should optional too
required = False
if required and attrs:
- dyn_required = "[('%s','=','%s')]" % (selector_name, field_name)
+ dyn_required = f"[('{selector_name}','=','{field_name}')]"
attrs["required"] = dyn_required
# TODO the _stack_path assignation doesn't work
@@ -244,12 +241,12 @@ def _build_form_simple_type(
if hasattr(field, "original_comodel_name"):
spec_class = field.original_comodel_name
field_tag = E.field(
- name=field_name, context="{'spec_class': '%s'})" % (spec_class,)
+ name=field_name, context=f"{{'spec_class': {spec_class}}})"
)
else:
field_tag = E.field(name=field_name)
if attrs:
- field_tag.set("attrs", "%s" % (attrs,))
+ field_tag.set("attrs", f"{attrs}")
elif required:
field_tag.set("required", "True")
@@ -292,7 +289,7 @@ def _build_form_complex_type(
if depth == 0:
view_child = E.group(string=child_string)
if attrs:
- view_child.set("attrs", "%s" % (attrs,))
+ view_child.set("attrs", f"{attrs}")
setup_modifiers(view_child)
view_node.append(view_child)
self.build_arch(lib_child, view_child, fields, depth + 1)
@@ -300,7 +297,7 @@ def _build_form_complex_type(
page = E.page(string=child_string)
invisible = False
if attrs:
- page.set("attrs", "%s" % (attrs,))
+ page.set("attrs", f"{attrs}")
setup_modifiers(page)
if not inside_notebook:
# first page
@@ -313,7 +310,7 @@ def _build_form_complex_type(
# in case the notebook has only one page,
# the visibility should be carried by the
# notebook itself
- wrapper_notebook.set("attrs", "{'invisible':%s}" % (invisible,))
+ wrapper_notebook.set("attrs", f"{{'invisible':{invisible}}}")
setup_modifiers(wrapper_notebook)
else:
# cancel notebook dynamic visbility