Skip to content

Commit

Permalink
[REF] pre-commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniospneto authored and CristianoMafraJunior committed Nov 1, 2024
1 parent 218416f commit 0a1917e
Show file tree
Hide file tree
Showing 94 changed files with 431 additions and 403 deletions.
2 changes: 1 addition & 1 deletion l10n_br_account/models/account_incoterms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions l10n_br_account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
)
)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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"
]
Expand Down Expand Up @@ -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")
Expand Down
9 changes: 5 additions & 4 deletions l10n_br_account/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand All @@ -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())

Expand Down
4 changes: 3 additions & 1 deletion l10n_br_account/models/account_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
12 changes: 6 additions & 6 deletions l10n_br_account/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -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

Expand Down
12 changes: 5 additions & 7 deletions l10n_br_account/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion l10n_br_account/tests/test_account_move_lc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_account/tests/test_account_move_sn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions l10n_br_account/tests/test_document_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down Expand Up @@ -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)
)
Expand Down
14 changes: 7 additions & 7 deletions l10n_br_account/tests/test_multi_localizations_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_account_due_list/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions l10n_br_account_nfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions l10n_br_account_payment_order/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand Down
17 changes: 5 additions & 12 deletions l10n_br_account_payment_order/models/account_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
19 changes: 10 additions & 9 deletions l10n_br_account_payment_order/tests/test_payment_order_inbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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],
Expand All @@ -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,
}
)

Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion l10n_br_account_withholding/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class AccountMove(models.Model):

_inherit = "account.move"

wh_invoice_count = fields.Integer(
Expand Down
1 change: 0 additions & 1 deletion l10n_br_account_withholding/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class AccountMoveLine(models.Model):

_inherit = "account.move.line"

wh_move_line_id = fields.Many2one(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class FiscalTaxGroup(models.Model):

_inherit = "l10n_br_fiscal.tax.group"

journal_id = fields.Many2one(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions l10n_br_base/models/res_partner_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
)
Loading

0 comments on commit 0a1917e

Please sign in to comment.