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 4b0e12c3b4b6..d3f93595f315 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!"
)
)
@@ -174,7 +175,7 @@ def _inject_shadowed_fields(self, vals_list):
for vals in vals_list:
for field in self._shadowed_fields():
if field in vals:
- vals["fiscal_proxy_%s" % (field,)] = vals[field]
+ vals[f"fiscal_proxy_{field}"] = vals[field]
def ensure_one_doc(self):
self.ensure_one()
@@ -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"
]
@@ -508,9 +510,7 @@ def _recompute_payment_terms_lines(self):
# TODO TODO pegar o método do self.fiscal_document_id.with_context(
# fiscal_document_no_company=True
# )._compute_document_name()
- terms_line.name = "{}/{}-{}".format(
- self.document_number, idx + 1, len(terms_lines)
- )
+ terms_line.name = f"{self.document_number}/{idx + 1}-{len(terms_lines)}"
return result
@api.onchange("fiscal_operation_id")
diff --git a/l10n_br_account/models/account_move_line.py b/l10n_br_account/models/account_move_line.py
index 78de34d91950..df18e39be514 100644
--- a/l10n_br_account/models/account_move_line.py
+++ b/l10n_br_account/models/account_move_line.py
@@ -139,7 +139,7 @@ def _inject_shadowed_fields(self, vals_list):
for vals in vals_list:
for field in self._shadowed_fields():
if field in vals:
- vals["fiscal_proxy_%s" % (field,)] = vals[field]
+ vals[f"fiscal_proxy_{field}"] = vals[field]
@api.model_create_multi
def create(self, vals_list):
@@ -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 99bbe11026d1..df61f26eec95 100644
--- a/l10n_br_account/models/account_tax.py
+++ b/l10n_br_account/models/account_tax.py
@@ -139,7 +139,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/document.py b/l10n_br_account/models/document.py
index ab55691e84f5..6a378c7b7514 100644
--- a/l10n_br_account/models/document.py
+++ b/l10n_br_account/models/document.py
@@ -126,10 +126,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"):
@@ -171,14 +171,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 beab652ba78c..94109ff4aa53 100644
--- a/l10n_br_account/tests/common.py
+++ b/l10n_br_account/tests/common.py
@@ -288,7 +288,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 8dc31df6413a..a3f71e91e169 100644
--- a/l10n_br_account/tests/test_account_move_lc.py
+++ b/l10n_br_account/tests/test_account_move_lc.py
@@ -122,7 +122,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_account/tests/test_account_move_sn.py b/l10n_br_account/tests/test_account_move_sn.py
index aced1e6227d1..ab53f3ca39e2 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 74943cadc522..12933edefdde 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 b2962ad246bc..74c906c8e280 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_invoice.py b/l10n_br_account_due_list/models/account_invoice.py
index 7560e744108f..16b8bb2e747a 100644
--- a/l10n_br_account_due_list/models/account_invoice.py
+++ b/l10n_br_account_due_list/models/account_invoice.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")
)
# we added filtered because since odoo/odoo#156729
# sorted doesn't filter new records anymore and this
diff --git a/l10n_br_account_nfe/models/document.py b/l10n_br_account_nfe/models/document.py
index feb7a1ac7b86..57d6a818afb5 100644
--- a/l10n_br_account_nfe/models/document.py
+++ b/l10n_br_account_nfe/models/document.py
@@ -153,8 +153,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 30fc8731822c..10bcbc9ed8a5 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_order/models/account_move.py b/l10n_br_account_payment_order/models/account_move.py
index 89a43bf51678..884bbd0a6af6 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 6b866624123d..ebc259e398d4 100644
--- a/l10n_br_account_payment_order/models/account_payment_order.py
+++ b/l10n_br_account_payment_order/models/account_payment_order.py
@@ -225,18 +225,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_payment_order/tests/test_payment_order_inbound.py b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
index 33880a55f041..526b262b2d3d 100644
--- a/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
+++ b/l10n_br_account_payment_order/tests/test_payment_order_inbound.py
@@ -143,8 +143,8 @@ def test_payment_outside_cnab_payment_order_draft(self):
{
"payment_date": Date.context_today(self.env.user),
"journal_id": self.journal_cash.id,
- "payment_method_line_id": self.journal_cash._get_available_payment_method_lines(
- "inbound"
+ "payment_method_line_id": (
+ self.journal_cash._get_available_payment_method_lines("inbound")
)
.filtered(lambda x: x.code == "manual")
.id,
@@ -177,6 +177,11 @@ def test_payment_outside_cnab_payment_order_open(self):
payment_order.draft2open()
self.assertEqual(payment_order.state, "open")
+ manual_inbound_payment_method_line = (
+ self.journal_cash._get_available_payment_method_lines("inbound").filtered(
+ lambda x: x.code == "manual"
+ )
+ )
ctx = {
"active_model": "account.move",
"active_ids": [self.invoice_unicred.id],
@@ -185,11 +190,7 @@ def test_payment_outside_cnab_payment_order_open(self):
{
"payment_date": Date.context_today(self.env.user),
"journal_id": self.journal_cash.id,
- "payment_method_line_id": self.journal_cash._get_available_payment_method_lines(
- "inbound"
- )
- .filtered(lambda x: x.code == "manual")
- .id,
+ "payment_method_line_id": manual_inbound_payment_method_line.id,
}
)
@@ -244,8 +245,8 @@ def test_payment_by_assign_outstanding_credit(self):
payment = self.env["account.payment"].create(
{
"payment_type": "inbound",
- "payment_method_line_id": self.journal_cash._get_available_payment_method_lines(
- "inbound"
+ "payment_method_line_id": (
+ self.journal_cash._get_available_payment_method_lines("inbound")
)
.filtered(lambda x: x.code == "manual")
.id,
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 a12ed918b232..4419a505c99f 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 da619b5c7480..bbce50657c89 100644
--- a/l10n_br_base/tests/test_valid_createid.py
+++ b/l10n_br_base/tests/test_valid_createid.py
@@ -119,9 +119,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):
@@ -151,9 +149,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 582e6ee40f22..cea2f8d2b375 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
@@ -345,11 +347,11 @@ def _create_rebate_move_lines(self, move_id):
"move_id": move_id.id,
}
if self.cnab_return_log_id.type == "inbound":
- credit_move_line[
- "account_id"
- ] = (
- self.journal_id.company_id.account_journal_payment_credit_account_id.id
+ journal_company_id = self.journal_id.company_id
+ payment_credit_account_id = (
+ journal_company_id.account_journal_payment_credit_account_id
)
+ credit_move_line["account_id"] = payment_credit_account_id.id
debit_move_line[
"account_id"
] = self.journal_id.inbound_rebate_account_id.id
@@ -381,11 +383,9 @@ def _create_discount_move_lines(self, move_id):
"move_id": move_id.id,
}
if self.cnab_return_log_id.type == "inbound":
- credit_move_line[
- "account_id"
- ] = (
- self.journal_id.company_id.account_journal_payment_credit_account_id.id
- )
+ company_id = self.journal_id.company_id
+ account_id = company_id.account_journal_payment_credit_account_id
+ credit_move_line["account_id"] = account_id.id
debit_move_line[
"account_id"
] = self.journal_id.inbound_discount_account_id.id
@@ -424,11 +424,9 @@ def _create_fees_move_lines(self, move_id):
"account_id"
] = self.journal_id.company_id.account_journal_payment_debit_account_id
else:
- credit_move_line[
- "account_id"
- ] = (
- self.journal_id.company_id.account_journal_payment_credit_account_id.id
- )
+ company_id = self.journal_id.company_id
+ account_id = company_id.account_journal_payment_credit_account_id
+ credit_move_line["account_id"] = account_id.id
debit_move_line[
"account_id"
] = self.journal_id.outbound_interest_fee_account_id.id
diff --git a/l10n_br_cnab_structure/wizard/cnab_import_wizard.py b/l10n_br_cnab_structure/wizard/cnab_import_wizard.py
index d1898aff80e4..20288dbd4954 100644
--- a/l10n_br_cnab_structure/wizard/cnab_import_wizard.py
+++ b/l10n_br_cnab_structure/wizard/cnab_import_wizard.py
@@ -195,7 +195,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)
@@ -213,7 +214,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_coa/models/account_chart_template.py b/l10n_br_coa/models/account_chart_template.py
index 8ad38afbd44e..0d4247b2e599 100644
--- a/l10n_br_coa/models/account_chart_template.py
+++ b/l10n_br_coa/models/account_chart_template.py
@@ -43,7 +43,6 @@ def _load_template(
if self.parent_id and self.parent_id == self.env.ref(
"l10n_br_coa.l10n_br_coa_template"
):
-
# for some reason, account_ref keys can be either account ids
# either account records. In order to match them later we ensure
# here keys are ids:
diff --git a/l10n_br_crm/tests/test_crm_lead.py b/l10n_br_crm/tests/test_crm_lead.py
index 36638d4cba61..377913024a3e 100644
--- a/l10n_br_crm/tests/test_crm_lead.py
+++ b/l10n_br_crm/tests/test_crm_lead.py
@@ -9,7 +9,7 @@ class CrmLeadTest(TransactionCase):
"""Test basic operations on Lead"""
def setUp(self):
- super(CrmLeadTest, self).setUp()
+ super().setUp()
# Create lead with simple details
self.crm_lead_company = self.env["crm.lead"].create(
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..a9479efb3554 100644
--- a/l10n_br_fiscal/models/data_ncm_nbs_abstract.py
+++ b/l10n_br_fiscal/models/data_ncm_nbs_abstract.py
@@ -147,20 +147,18 @@ def _scheduled_update(self):
lambda r: r.product_tmpl_qty > 0 and not r.tax_estimate_ids
)
- query = """
- WITH {0}_max_date AS (
+ query = f"""
+ WITH {object_name.lower()}_max_date AS (
SELECT
- {0}_id,
+ {object_name.lower()}_id,
max(create_date)
FROM
l10n_br_fiscal_tax_estimate
- GROUP BY {0}_id)
- SELECT {0}_id
- FROM {0}_max_date
+ GROUP BY {object_name.lower()}_id)
+ SELECT {object_name.lower()}_id
+ FROM {object_name.lower()}_max_date
WHERE max < %(create_date)s
- """.format(
- object_name.lower()
- )
+ """
query_params = {"create_date": data_max.strftime("%Y-%m-%d")}
diff --git a/l10n_br_fiscal/models/document_line_mixin_methods.py b/l10n_br_fiscal/models/document_line_mixin_methods.py
index 6338d4d15ad3..a4a43282dc1a 100644
--- a/l10n_br_fiscal/models/document_line_mixin_methods.py
+++ b/l10n_br_fiscal/models/document_line_mixin_methods.py
@@ -221,7 +221,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:
@@ -238,7 +239,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):
@@ -289,7 +290,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_mixin_fields.py b/l10n_br_fiscal/models/document_mixin_fields.py
index f8f791335b96..6821d2450adc 100644
--- a/l10n_br_fiscal/models/document_mixin_fields.py
+++ b/l10n_br_fiscal/models/document_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_mixin_methods.py b/l10n_br_fiscal/models/document_mixin_methods.py
index bdd2b1d21acf..eec037c42543 100644
--- a/l10n_br_fiscal/models/document_mixin_methods.py
+++ b/l10n_br_fiscal/models/document_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):
@@ -133,11 +133,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(
@@ -148,11 +149,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()
@@ -181,11 +183,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(
@@ -196,11 +199,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()
@@ -229,11 +233,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(
@@ -244,11 +249,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 e9b503ae93e5..a31889147751 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 054837acedb8..c64fe1ce36e1 100644
--- a/l10n_br_fiscal/models/tax_definition.py
+++ b/l10n_br_fiscal/models/tax_definition.py
@@ -21,11 +21,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 f2f6eb360f14..916e1ebce7a6 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 1f016679a1d5..c2b3b46f84af 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 764abdea8f81..0d4d7c7a0a0b 100644
--- a/l10n_br_fiscal_closing/models/closing.py
+++ b/l10n_br_fiscal_closing/models/closing.py
@@ -63,7 +63,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/models/dfe.py b/l10n_br_fiscal_dfe/models/dfe.py
index bd1730abd5de..aac31877126b 100644
--- a/l10n_br_fiscal_dfe/models/dfe.py
+++ b/l10n_br_fiscal_dfe/models/dfe.py
@@ -78,7 +78,8 @@ def validate_distribution_response(self, result):
self.message_post(
body=_(
_(
- "Error validating document distribution: \n\n%(code)s - %(message)s",
+ "Error validating document distribution: \n\n"
+ "%(code)s - %(message)s",
code=code,
message=message,
)
diff --git a/l10n_br_fiscal_dfe/tests/test_dfe.py b/l10n_br_fiscal_dfe/tests/test_dfe.py
index 93069a524317..94e0c7d5c67b 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: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"""
+response_sucesso_multiplos = """11.4.0138Documento(s) localizado(s)2022-04-04T11:54:49-03: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""" # 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 308a33113d35..6e167372425d 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_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_ie_search/tests/test_sefaz.py b/l10n_br_ie_search/tests/test_sefaz.py
index ba47fb14d704..401b1962f96c 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 2331fbf33825..73d6cd55417a 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 549504601e50..b6e8745b0167 100644
--- a/l10n_br_nfe/hooks.py
+++ b/l10n_br_nfe/hooks.py
@@ -41,4 +41,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 7f62f604fa9a..9fdd0248eb33 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
@@ -733,7 +734,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":
@@ -866,7 +867,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."
)
)
@@ -1066,7 +1068,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):
@@ -1362,7 +1364,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 b3d9bf801841..cee17ce69710 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):
@@ -1196,27 +1196,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:
@@ -1227,15 +1221,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
@@ -1263,24 +1255,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")
@@ -1321,7 +1313,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 c10f4bbbfc47..75e7b60cffa5 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(TransactionCase):
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 d8c7db4f1dc0..89374382a008 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 c0011bf661b8..874aca8d86a8 100644
--- a/l10n_br_nfe/tests/test_nfe_serialize.py
+++ b/l10n_br_nfe/tests/test_nfe_serialize.py
@@ -72,6 +72,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 20441ea93694..7fd77b0e8d39 100644
--- a/l10n_br_nfe/tests/test_nfe_structure.py
+++ b/l10n_br_nfe/tests/test_nfe_structure.py
@@ -36,15 +36,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_nfe_spec/tests/test_nfe_import.py b/l10n_br_nfe_spec/tests/test_nfe_import.py
index 69238e0f4702..255735577f03 100644
--- a/l10n_br_nfe_spec/tests/test_nfe_import.py
+++ b/l10n_br_nfe_spec/tests/test_nfe_import.py
@@ -38,10 +38,7 @@ def build_attrs_fake(self, node, create_m2o=False):
value = getattr(node, fname)
if value is None:
continue
- key = "%s%s" % (
- self._field_prefix,
- fspec.metadata.get("name", fname),
- )
+ key = f"{self._field_prefix}{fspec.metadata.get('name', fname)}"
if (
fspec.type == str or not any(["." in str(i) for i in fspec.type.__args__])
) and not str(fspec.type).startswith("typing.List"):
@@ -67,7 +64,7 @@ def build_attrs_fake(self, node, create_m2o=False):
comodel_name = fields[key]["relation"]
else:
clean_type = binding_type.lower() # TODO double check
- comodel_name = "%s.%s.%s" % (
+ comodel_name = "{}.{}.{}".format(
self._schema_name,
self._schema_version.replace(".", "")[0:2],
clean_type.split(".")[-1],
@@ -143,7 +140,7 @@ def fields_convert_to_cache(self, value, record, validate=True):
# cache format: tuple(ids)
if isinstance(value, BaseModel):
if validate and value._name != self.comodel_name:
- raise ValueError("Wrong value for %s: %s" % (self, value))
+ raise ValueError(f"Wrong value for {self}: {value}")
ids = value._ids
if record and not record.id:
# x2many field value of new record is new records
@@ -156,7 +153,9 @@ def fields_convert_to_cache(self, value, record, validate=True):
# if record is new, the field's value is new records
# THE NEXT LINE WAS PATCHED:
if record and hasattr(record, "id") and not record.id:
- browse = lambda it: comodel.browse([it and NewId(it)])
+
+ def browse(it):
+ return comodel.browse((it and NewId(it),))
else:
browse = comodel.browse
# determine the value ids
@@ -195,7 +194,7 @@ def fields_convert_to_cache(self, value, record, validate=True):
elif not value:
return ()
- raise ValueError("Wrong value for %s: %s" % (self, value))
+ raise ValueError(f"Wrong value for {self}: {value}")
fields_convert_to_cache._original_method = fields._RelationalMulti.convert_to_cache
@@ -215,7 +214,7 @@ def models_update_cache(self, values, validate=True):
try:
field_values = [(fields[name], value) for name, value in values.items()]
except KeyError as e:
- raise ValueError("Invalid field %r on model %r" % (e.args[0], self._name))
+ raise ValueError(f"Invalid field {e.args[0]} on model {self._name}") from e
# convert monetary fields after other columns for correct value rounding
for field, value in sorted(field_values, key=lambda item: item[0].write_sequence):
@@ -231,8 +230,10 @@ def models_update_cache(self, values, validate=True):
continue
for invf in self.pool.field_inverses[field]:
# DLE P98: `test_40_new_fields`
- # /home/dle/src/odoo/master-nochange-fp/odoo/addons/test_new_api/tests/test_new_fields.py
- # Be careful to not break `test_onchange_taxes_1`, `test_onchange_taxes_2`, `test_onchange_taxes_3`
+ # /home/dle/src/odoo/master-nochange-fp/odoo/addons/
+ # test_new_api/tests/test_new_fields.py
+ # Be careful to not break `test_onchange_taxes_1`,
+ # `test_onchange_taxes_2`, `test_onchange_taxes_3`
# If you attempt to find a better solution
for inv_rec in inv_recs:
if not cache.contains(inv_rec, invf):
diff --git a/l10n_br_nfse_focus/models/document.py b/l10n_br_nfse_focus/models/document.py
index e870f756c211..35adf347d122 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.
@@ -586,7 +588,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 21931ff4eba9..e9f24f3cba19 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
@@ -176,7 +176,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
@@ -216,7 +217,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(
@@ -334,7 +337,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
@@ -351,7 +355,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
@@ -361,7 +366,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."""
@@ -437,7 +443,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"
)
@@ -531,7 +538,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,
@@ -550,7 +558,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
@@ -561,7 +570,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"
@@ -575,7 +585,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_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 1aba0e995895..d871ca03d2e6 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:
@@ -334,7 +337,7 @@ def test_l10n_br_purchase_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:
@@ -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_resource/models/resource_calendar.py b/l10n_br_resource/models/resource_calendar.py
index 688f02fefd46..65efa2d0357f 100644
--- a/l10n_br_resource/models/resource_calendar.py
+++ b/l10n_br_resource/models/resource_calendar.py
@@ -8,7 +8,6 @@
class ResourceCalendar(models.Model):
-
_inherit = "resource.calendar"
_parent_store = True
diff --git a/l10n_br_resource/models/resource_calendar_leaves.py b/l10n_br_resource/models/resource_calendar_leaves.py
index 76948c15593b..7abce938741e 100644
--- a/l10n_br_resource/models/resource_calendar_leaves.py
+++ b/l10n_br_resource/models/resource_calendar_leaves.py
@@ -23,7 +23,6 @@
class ResourceCalendarLeave(models.Model):
-
_inherit = "resource.calendar.leaves"
country_id = fields.Many2one(
diff --git a/l10n_br_resource/tests/test_resource_calendar.py b/l10n_br_resource/tests/test_resource_calendar.py
index c15d04ee460f..057d15558a74 100644
--- a/l10n_br_resource/tests/test_resource_calendar.py
+++ b/l10n_br_resource/tests/test_resource_calendar.py
@@ -7,7 +7,7 @@
class TestResourceCalendar(test_common.SingleTransactionCase):
def setUp(self):
- super(TestResourceCalendar, self).setUp()
+ super().setUp()
self.resource_calendar = self.env["resource.calendar"]
self.resource_leaves = self.env["resource.calendar.leaves"]
diff --git a/l10n_br_resource/tests/test_resource_calendar_2.py b/l10n_br_resource/tests/test_resource_calendar_2.py
index ed5b11281acf..a4fc58aacde9 100644
--- a/l10n_br_resource/tests/test_resource_calendar_2.py
+++ b/l10n_br_resource/tests/test_resource_calendar_2.py
@@ -5,7 +5,7 @@
class TestResourceCalendar(common.TransactionCase):
def setUp(self):
- super(TestResourceCalendar, self).setUp()
+ super().setUp()
self.calendar = self.env["resource.calendar"].create({"name": "Test Calendar"})
self.env["resource.calendar.leaves"].create(
@@ -19,7 +19,6 @@ def setUp(self):
)
def test_data_eh_feriado(self):
-
holiday_date = datetime(2023, 12, 25)
result = self.calendar.data_eh_feriado(holiday_date)
expected_result = True
@@ -73,7 +72,6 @@ def test_data_eh_feriado_bancario(self):
)
def test_data_eh_feriado_emendado(self):
-
reference_data = datetime(2023, 9, 7, 15, 0, 0)
expected_result = False
diff --git a/l10n_br_resource/tools/brazil_all_holidays_set.py b/l10n_br_resource/tools/brazil_all_holidays_set.py
index 0bfb8968fbb5..2dba84f5f3ab 100644
--- a/l10n_br_resource/tools/brazil_all_holidays_set.py
+++ b/l10n_br_resource/tools/brazil_all_holidays_set.py
@@ -6,7 +6,6 @@
class BrazilianHoliday:
def __init__(self, nome, data, estado_ibge, municipio_ibge, abrangencia, tipo):
-
self.estado_ibge = estado_ibge
self.municipio_ibge = municipio_ibge
self.municipio_nome = ""
@@ -58,7 +57,6 @@ def brazil_all_holidays_set(year):
for register in IBGE_REGISTER.items():
estado_ibge = re.sub("BR-IBGE-", "", register[0])
if len(estado_ibge) == 2:
-
cal_state = IBGE_REGISTER[register[0]]()
for state_holidays in cal_state.holidays(year):
holiday_name = state_holidays[1]
@@ -80,7 +78,6 @@ def brazil_all_holidays_set(year):
municipio_ibge = re.sub("BR-IBGE-", "", register[0])
estado_ibge = municipio_ibge[0:2]
if len(municipio_ibge) > 2:
-
cal_city = IBGE_REGISTER[register[0]]()
for city_holiday in cal_city.holidays(year):
diff --git a/l10n_br_resource/wizards/workalendar_holiday_import_wizard.py b/l10n_br_resource/wizards/workalendar_holiday_import_wizard.py
index 41e01481db17..e84edf01e894 100644
--- a/l10n_br_resource/wizards/workalendar_holiday_import_wizard.py
+++ b/l10n_br_resource/wizards/workalendar_holiday_import_wizard.py
@@ -21,7 +21,6 @@
class WorkalendarHolidayImport(models.TransientModel):
-
_name = "wizard.workalendar.holiday.import"
_description = "Wizard de import de feriados"
@@ -66,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',
}
)
@@ -147,7 +146,6 @@ def holiday_import(self):
while date_reference.year <= fields.Date.to_date(wiz.end_date).year:
all_holidays = brazil_all_holidays_set(date_reference.year)
for holiday in all_holidays:
-
if holiday.municipio_ibge:
municipio_nome = (
self.env["res.city"]
diff --git a/l10n_br_sale/models/sale_order.py b/l10n_br_sale/models/sale_order.py
index 367d22371de9..80139c2fca81 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 f2e1810ec358..a5480c47636f 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 39543e6f7165..8e705bf1fde8 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_zip/models/l10n_br_zip.py b/l10n_br_zip/models/l10n_br_zip.py
index 5dbcfc014aae..93648d89543a 100644
--- a/l10n_br_zip/models/l10n_br_zip.py
+++ b/l10n_br_zip/models/l10n_br_zip.py
@@ -72,7 +72,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"
)
)
@@ -166,7 +167,6 @@ def _consultar_cep(self, zip_code):
@api.model
def zip_search(self, obj):
-
try:
domain = self._set_domain(
country_id=obj.country_id.id,
@@ -188,12 +188,10 @@ def zip_search(self, obj):
# More than one ZIP was found
elif len(zips) > 1:
-
return self.create_wizard(obj, zips)
# Address not found in local DB, search by PyCEP-Correios
elif not zips and obj.zip:
-
cep_values = self._consultar_cep(obj.zip)
if cep_values:
@@ -203,7 +201,6 @@ def zip_search(self, obj):
return True
def create_wizard(self, obj, zips):
-
context = dict(self.env.context)
context.update({"address_id": obj.id, "object_name": obj._name})
diff --git a/l10n_br_zip/tests/test_l10n_br_zip_res_company.py b/l10n_br_zip/tests/test_l10n_br_zip_res_company.py
index cc20a933bd69..5b2f03cce59a 100644
--- a/l10n_br_zip/tests/test_l10n_br_zip_res_company.py
+++ b/l10n_br_zip/tests/test_l10n_br_zip_res_company.py
@@ -12,7 +12,7 @@
class L10nBRZipTest(TransactionCase):
def setUp(self):
- super(L10nBRZipTest, self).setUp()
+ super().setUp()
self.zip_obj = self.env["l10n_br.zip"]
self.zip_1 = self.zip_obj.create(
diff --git a/l10n_br_zip/wizard/l10n_br_zip_search.py b/l10n_br_zip/wizard/l10n_br_zip_search.py
index 4509633f715b..6f754624fe85 100644
--- a/l10n_br_zip/wizard/l10n_br_zip_search.py
+++ b/l10n_br_zip/wizard/l10n_br_zip_search.py
@@ -48,7 +48,7 @@ class L10nBrZipSearch(models.TransientModel):
@api.model
def default_get(self, fields_list):
- data = super(L10nBrZipSearch, self).default_get(fields_list)
+ data = super().default_get(fields_list)
context = dict(self._context or {})
data["zip"] = context.get("zip", False)
@@ -66,7 +66,6 @@ def default_get(self, fields_list):
return data
def zip_search(self):
-
self.ensure_one()
data = self
obj_zip = self.env["l10n_br.zip"]
diff --git a/spec_driven_model/models/spec_export.py b/spec_driven_model/models/spec_export.py
index aa553814352c..3ba7e483f294 100644
--- a/spec_driven_model/models/spec_export.py
+++ b/spec_driven_model/models/spec_export.py
@@ -32,7 +32,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
@@ -137,7 +137,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]
@@ -175,7 +175,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 40d595574fb7..83ed68d3d682 100644
--- a/spec_driven_model/models/spec_import.py
+++ b/spec_driven_model/models/spec_import.py
@@ -69,11 +69,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],
@@ -196,7 +196,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]
@@ -277,8 +277,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 a31f6cb4b9af..533d4ffa5f0d 100644
--- a/spec_driven_model/models/spec_mixin.py
+++ b/spec_driven_model/models/spec_mixin.py
@@ -59,7 +59,7 @@ def _register_hook(self):
if not hasattr(self, "_spec_module"):
return res
- load_key = "_%s_loaded" % (self._spec_module,)
+ load_key = f"_{self._spec_module}_loaded"
if hasattr(self.env.registry, load_key): # already done for registry
return res
setattr(self.env.registry, load_key, True)
@@ -141,10 +141,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(
[
@@ -157,7 +154,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",
@@ -176,7 +173,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 6faae882cb6a..ed5df9baf8c0 100644
--- a/spec_driven_model/models/spec_models.py
+++ b/spec_driven_model/models/spec_models.py
@@ -93,8 +93,39 @@ class as long as the generated spec mixins inherit from some
item[0] if isinstance(item, list) else item for item in list(cls._inherit)
]
for parent in parents:
- # this will register that the spec mixins where injected in this class
- cls._map_concrete(cr.dbname, parent, cls._name)
+ cls._map_concrete(parent, cls._name)
+ super_parents = list(pool[parent]._inherit)
+ for super_parent in super_parents:
+ if (
+ not super_parent.startswith("spec.mixin.")
+ or not hasattr(pool[super_parent], "_odoo_module")
+ or "spec.mixin" in [c._name for c in pool[super_parent].__bases__]
+ ):
+ continue
+
+ cr.execute(
+ "SELECT name FROM ir_module_module "
+ "WHERE name=%(name)s "
+ "AND state in ('to install', 'to upgrade', 'to remove')",
+ {"name": pool[super_parent]._odoo_module},
+ )
+ if cr.fetchall():
+ setattr(
+ pool,
+ f"_{pool[super_parent]._odoo_module}_need_hook",
+ True,
+ )
+
+ pool[super_parent]._inherit = list(pool[super_parent]._inherit) + [
+ "spec.mixin"
+ ]
+ pool[super_parent]._BaseModel__base_classes = (
+ pool["spec.mixin"],
+ ) + pool[super_parent]._BaseModel__base_classes
+ pool[super_parent].__bases__ = (pool["spec.mixin"],) + pool[
+ super_parent
+ ].__bases__
+
return super()._build_model(pool, cr)
@api.model
@@ -178,9 +209,14 @@ def _setup_fields(self):
def _map_concrete(cls, dbname, key, target, quiet=False):
# TODO bookkeep according to a key to allow multiple injection contexts
if not quiet:
- _logger.debug("%s ---> %s" % (key, target))
- global SPEC_MIXIN_MAPPINGS
- SPEC_MIXIN_MAPPINGS[dbname][key] = target
+ _logger.debug(f"{key} ---> {target}")
+ models.MetaModel.mixin_mappings[key] = target
+
+ @classmethod
+ def _get_concrete(cls, key):
+ if not hasattr(models.MetaModel, "mixin_mappings"):
+ models.MetaModel.mixin_mappings = {}
+ return models.MetaModel.mixin_mappings.get(key)
@classmethod
def spec_module_classes(cls, spec_module):
@@ -188,7 +224,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)
@@ -239,7 +276,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(
@@ -318,7 +355,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