Skip to content

Commit

Permalink
copier update
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniospneto committed Sep 8, 2024
1 parent 651e2fb commit 1139014
Show file tree
Hide file tree
Showing 112 changed files with 465 additions and 476 deletions.
5 changes: 3 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Do NOT update manually; changes here will be overwritten by Copier
_commit: v1.21.1
_commit: v1.24
_src_path: gh:oca/oca-addons-repo-template
additional_ruff_rules: []
ci: GitHub
convert_readme_fragments_to_markdown: false
generate_requirements_txt: true
Expand All @@ -26,5 +27,5 @@ repo_name: Odoo Brazilian Localization / Localização brasileira do Odoo
repo_slug: l10n-brazil
repo_website: https://github.com/OCA/l10n-brazil
use_pyproject_toml: false
use_ruff: false
use_ruff: true

9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ var/
*.egg
*.eggs

# Debian packages
*.deb

# Redhat packages
*.rpm

# MacOS packages
*.dmg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
Expand Down
37 changes: 7 additions & 30 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exclude: |
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
default_language_version:
python: python3
python: python3.11
node: "14.13.0"
repos:
- repo: local
Expand All @@ -45,7 +45,7 @@ repos:
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: 9a170331575a265c092ee6b24b845ec508e8ef75
rev: d5fab7ee87fceee858a3d01048c78a548974d935
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
Expand All @@ -64,21 +64,6 @@ repos:
hooks:
- id: oca-checks-odoo-module
- id: oca-checks-po
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args:
- --expand-star-imports
- --ignore-init-module-imports
- --in-place
- --remove-all-unused-imports
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.1.2
hooks:
Expand Down Expand Up @@ -125,14 +110,6 @@ repos:
hooks:
- id: pyupgrade
args: ["--keep-percent-format"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: isort except __init__.py
args:
- --settings=.
exclude: /__init__\.py$
- repo: https://github.com/acsone/setuptools-odoo
rev: 3.1.8
hooks:
Expand All @@ -143,12 +120,12 @@ repos:
- requirements.txt
- --header
- "# generated from manifests external_dependencies"
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: flake8
name: flake8
additional_dependencies: ["flake8-bugbear==20.1.4"]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/OCA/pylint-odoo
rev: 7.0.2
hooks:
Expand Down
30 changes: 30 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

target-version = "py39"

fix = true

[lint]
extend-select = [
"B",
"C90",
"E501", # line too long (default 88)
"I", # isort
]
exclude = ["setup/*"]

[format]
exclude = ["setup/*"]

[per-file-ignores]
"__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py
"__manifest__.py" = ["B018"] # useless expression

[isort]
section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"]

[isort.sections]
"odoo" = ["odoo"]
"odoo-addons" = ["odoo.addons"]

[mccabe]
max-complexity = 16
42 changes: 0 additions & 42 deletions .t2d.yml

This file was deleted.

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
6 changes: 4 additions & 2 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 @@ -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
7 changes: 4 additions & 3 deletions l10n_br_account/models/account_move_line.py
Original file line number Diff line number Diff line change
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 @@ -137,7 +137,9 @@ def compute_all(
account_taxes_by_domain.update({tax.id: tax_domain})

for account_tax in taxes_results["taxes"]:
tax = self.filtered(lambda t: t.id == account_tax.get("id"))
tax = self.filtered(
lambda t, account_tax=account_tax: t.id == account_tax.get("id")
)
fiscal_tax = fiscal_taxes_results["taxes"].get(
account_taxes_by_domain.get(tax.id)
)
Expand Down
12 changes: 6 additions & 6 deletions l10n_br_account/models/fiscal_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ def unlink(self):
@api.model_create_multi
def create(self, vals_list):
"""
It's not allowed to create a fiscal document line without a document_type_id anyway.
But instead of letting Odoo crash in this case we simply avoid creating the
record. This makes it possible to create an account.move without
a fiscal_document_id despite the _inherits system:
It's not allowed to create a fiscal document line without a document_type_id
anyway. But instead of letting Odoo crash in this case we simply avoid creating
the record. This makes it possible to create an account.move without a
fiscal_document_id despite the _inherits system:
Odoo will write NULL as the value in this case.
"""
if self._context.get("create_from_move"):
Expand Down Expand Up @@ -158,14 +158,14 @@ def cancel_move_ids(self):

def _document_cancel(self, justificative):
result = super()._document_cancel(justificative)
msg = "Cancelamento: {}".format(justificative)
msg = f"Cancelamento: {justificative}"

Check warning on line 161 in l10n_br_account/models/fiscal_document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account/models/fiscal_document.py#L161

Added line #L161 was not covered by tests
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}"

Check warning on line 168 in l10n_br_account/models/fiscal_document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account/models/fiscal_document.py#L168

Added line #L168 was not covered by tests
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 @@ -289,7 +289,8 @@ def init_invoice(
document_number=None,
):
"""
We could not override the super one because we need to inject extra BR fiscal fields.
We could not override the super one because we need to inject extra BR fiscal
fields.
"""
products = [] if products is None else products
amounts = [] if amounts is None else amounts
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 = (

Check warning on line 368 in l10n_br_account/tests/common.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account/tests/common.py#L368

Added line #L368 was not covered by tests
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 @@ -124,7 +124,7 @@ def setup_company_data(cls, company_name, chart_template=None, **kwargs):
icms_regulation_id=cls.env.ref("l10n_br_fiscal.tax_icms_regulation").id,
cnae_main_id=cls.env.ref("l10n_br_fiscal.cnae_3101200").id,
document_type_id=cls.env.ref("l10n_br_fiscal.document_55").id,
**kwargs
**kwargs,
)
res["company"].partner_id.state_id = cls.env.ref("base.state_br_sp").id
res["company"].partner_id.cnpj_cpf = cnpj
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_move.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")
)
move.financial_move_line_ids = lines.sorted()

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 @@ -152,8 +152,8 @@ def _check_fiscal_payment_mode(self):
if not rec.move_ids.payment_mode_id.fiscal_payment_mode:
raise UserError(
_(
"Payment Mode %(mode)s should have "
"a Fiscal Payment Mode filled to be used in the Fiscal Document!",
"Payment Mode %(mode)s should have a Fiscal Payment Mode"
" filled to be used in the Fiscal Document!",
mode=rec.move_ids.payment_mode_id.name,
)
)
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
Loading

0 comments on commit 1139014

Please sign in to comment.