Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16.0 pre commit hooks #24

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .flake8

This file was deleted.

62 changes: 9 additions & 53 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ exclude: |
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
# TODO: Remove js exlusion when all js files are prettier compliant
.js$|.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
# Maybe reactivate this when all README files include prettier ignore tags?
^README\.md$|
# Library files can have extraneous formatting (even minimized)
Expand Down Expand Up @@ -44,35 +45,13 @@ repos:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
- id: oca-fix-manifest-website
args: ["https://github.com/OCA/crm"]
- id: oca-gen-addon-readme
args:
- --addons-dir=.
- --branch=16.0
- --org-name=OCA
- --repo-name=crm
- --if-source-changed
- --keep-source-digest
args: ["https://github.com/altinkaya-opensource/odoo-addons"]

- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.0.25
hooks:
- id: oca-checks-odoo-module
- id: oca-checks-po
- repo: https://github.com/myint/autoflake
rev: v1.6.1
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.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
Expand Down Expand Up @@ -114,35 +93,12 @@ repos:
- id: check-xml
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.38.2
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:
- id: setuptools-odoo-make-default
- id: setuptools-odoo-get-requirements
args:
- --output
- requirements.txt
- --header
- "# generated from manifests external_dependencies"
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: flake8
name: flake8
additional_dependencies: ["flake8-bugbear==21.9.2"]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/OCA/pylint-odoo
rev: v8.0.19
hooks:
Expand Down
5 changes: 1 addition & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ score=n

[ODOOLINT]
readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest-required-authors=Odoo Community Association (OCA)
manifest-required-authors=Altinkaya Enclosures
manifest-required-keys=license
manifest-deprecated-keys=description,active
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
Expand Down Expand Up @@ -41,7 +41,6 @@ enable=anomalous-backslash-in-string,
license-allowed,
manifest-author-string,
manifest-deprecated-key,
manifest-required-author,
manifest-required-key,
manifest-version-format,
method-compute,
Expand Down Expand Up @@ -81,7 +80,6 @@ enable=anomalous-backslash-in-string,
invalid-commit,
manifest-maintainers-list,
missing-newline-extrafiles,
missing-readme,
missing-return,
odoo-addons-relative-import,
old-api7-method-defined,
Expand All @@ -108,7 +106,6 @@ enable=anomalous-backslash-in-string,
invalid-commit,
missing-manifest-dependency,
missing-newline-extrafiles,
missing-readme,
no-utf8-coding-comment,
odoo-addons-relative-import,
old-api7-method-defined,
Expand Down
3 changes: 1 addition & 2 deletions .pylintrc-mandatory
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ score=n

[ODOOLINT]
readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest-required-authors=Odoo Community Association (OCA)
manifest-required-authors=Altinkaya Enclosures
manifest-required-keys=license
manifest-deprecated-keys=description,active
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
Expand Down Expand Up @@ -73,7 +73,6 @@ enable=anomalous-backslash-in-string,
invalid-commit,
manifest-maintainers-list,
missing-newline-extrafiles,
missing-readme,
missing-return,
odoo-addons-relative-import,
old-api7-method-defined,
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 = "py312"
fix = true

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

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

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

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

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

[lint.mccabe]
max-complexity = 16
6 changes: 3 additions & 3 deletions account_statement_import_online_finekra/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Online Bank Statements: Finekra",
"version": "12.0.1.1.0",
"version": "16.0.1.1.0",
"category": "Account",
"website": "https://github.com/odoo-turkey/integration",
"author": "Yiğit Budak, Odoo Turkey Localization Group",
"website": "https://github.com/altinkaya-opensource/odoo-addons",
"author": "Yiğit Budak, Odoo Turkey Localization Group, Altinkaya Enclosures",
"license": "AGPL-3",
"installable": True,
"depends": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright 2024 Yiğit Budak (https://github.com/yibudak)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import models, api, fields
from odoo.tools import float_compare
import re

from odoo import api, fields, models
from odoo.tools import float_compare


class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"
Expand All @@ -23,7 +24,7 @@ def create(self, vals):
:param vals:
:return:
"""
res = super(AccountBankStatementLine, self).create(vals)
res = super().create(vals)
order_ref_pattern = r"\b[A-Za-z]{2}\d{6,7}\b"
matched_refs = re.findall(order_ref_pattern, res.name)
if matched_refs:
Expand Down Expand Up @@ -55,7 +56,7 @@ def create(self, vals):
"counterpart_aml_dicts": [],
"new_aml_dicts": [
{
"account_id": commercial_partner.property_account_receivable_id.id,
"account_id": commercial_partner.property_account_receivable_id.id, # noqa
"analytic_tag_ids": [[6, None, []]],
"credit": res.amount,
"company_id": res.company_id.id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2022 Yiğit Budak (https://github.com/yibudak)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import models, fields
from odoo import fields, models


class AccountJournal(models.Model):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Copyright 2022 Yiğit Budak (https://github.com/yibudak)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import requests
from datetime import datetime, timedelta

import uuid
import requests

from odoo import api, fields, models, _
from odoo import _, api, fields, models
from odoo.exceptions import UserError

FINEKRA_ENDPOINT = "https://test-api.finekra.com"
Expand Down Expand Up @@ -50,19 +49,22 @@ def _finekra_get_request(self, endpoint, data=None):
:return:
"""
headers = {
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true",
"Authorization": "Bearer %s" % self.finekra_jwt_token,
"Content-Type": (
"application/json;odata.metadata=minimal;odata.streaming=true"
),
"Authorization": f"Bearer {self.finekra_jwt_token}",
}
response = requests.get(endpoint, params=data, headers=headers)

response = requests.get(endpoint, params=data, headers=headers, timeout=10)

if response.status_code == 200:
return response.json()
else:
for i in range(len(response.text)):
print(i)
print(response.text)
raise UserError(_(response))
raise UserError(
_(
"Finekra API returned an error: %(resp_content)d",
resp_content=response.content,
),
)

def _finekra_post_request(self, endpoint, data=None):
"""
Expand All @@ -72,10 +74,12 @@ def _finekra_post_request(self, endpoint, data=None):
:return:
"""
headers = {
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true",
"Authorization": "Bearer %s" % self.finekra_jwt_token,
"Content-Type": (
"application/json;odata.metadata=minimal;odata.streaming=true"
),
"Authorization": f"Bearer {self.finekra_jwt_token}",
}
response = requests.post(endpoint, json=data, headers=headers)
response = requests.post(endpoint, json=data, headers=headers, timeout=10)

if response.status_code == 200:
return response.json()
Expand All @@ -85,7 +89,6 @@ def _finekra_post_request(self, endpoint, data=None):
def _finekra_get_auth(self):
self.ensure_one()
if self.finekra_email and self.finekra_password and self.finekra_tenant_code:

if (
not self.finekra_jwt_token
or self.finekra_token_interval < datetime.now()
Expand All @@ -97,7 +100,7 @@ def _finekra_get_auth(self):
"screenOption": 0,
}
resp = requests.post(
"%s/api/Auth/DealerLogin" % FINEKRA_ENDPOINT, json=vals
f"{FINEKRA_ENDPOINT}/api/Auth/DealerLogin", json=vals, timeout=10
).json()
if resp.get("success"):
self.write(
Expand All @@ -111,17 +114,12 @@ def _finekra_get_auth(self):
raise UserError(_("Please fill email, password and tenant code."))

def _finekra_get_transaction(self, account_id, date_since, date_until):
page_url = "%s/api/AccountTransaction" % FINEKRA_ENDPOINT
page_url = f"{FINEKRA_ENDPOINT}/api/AccountTransaction"

vals = {
"$filter": "TenantAccountId eq %s and"
" date(TransactionDateValue) le %s and"
" date(TransactionDateValue) ge %s"
% (
account_id,
date_until.strftime("%Y-%m-%d"),
date_since.strftime("%Y-%m-%d"),
)
"$filter": f"TenantAccountId eq {account_id} and"
f" date(TransactionDateValue) le {date_until.strftime('%Y-%m-%d')} and"
f" date(TransactionDateValue) ge {date_since.strftime('%Y-%m-%d')}"
}

data = self._finekra_get_request(endpoint=page_url, data=vals)
Expand All @@ -136,7 +134,6 @@ def _finekra_date_from_string(self, date_str):
return dt

def _finekra_obtain_statement_data(self, date_since, date_until):
# currency_dict = {x.name: x.id for x in self.env['res.currency'].search([('active', '=', True)])}
self.ensure_one()
self._finekra_get_auth()
journal = self.journal_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
<record model="ir.ui.view" id="bank_statement_line_tree_finekra">
<field name="name">account.bank.statement.line.tree.finekra</field>
<field name="model">account.bank.statement.line</field>
<field name="inherit_id" ref="account_statement_base.account_bank_statement_line_tree"/>
<field
name="inherit_id"
ref="account_statement_base.account_bank_statement_line_tree"
/>
<field name="arch" type="xml">
<field name="ref" position="after">
<field name="order_ids"/>
<field name="order_ids" />
</field>
</field>
</record>
</odoo>
</odoo>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record model="ir.ui.view" id="view_account_journal_form_finekra">
<field name="name">account.journal.form</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.view_account_journal_form"/>
<field name="inherit_id" ref="account.view_account_journal_form" />
<field name="arch" type="xml">
<group name="online_bank_statements" position="inside">
<field name="finekra_account_id"/>
<field name="finekra_account_id" />
</group>
</field>
</record>
Expand Down
Loading
Loading