Skip to content

Commit

Permalink
[FIX] pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Saran440 committed Jun 7, 2024
1 parent 9fb18ad commit 971b77d
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 36 deletions.
8 changes: 4 additions & 4 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Do NOT update manually; changes here will be overwritten by Copier
_commit: v1.17.1
_commit: v1.22
_src_path: gh:oca/oca-addons-repo-template
ci: GitHub
dependency_installation_mode: PIP
convert_readme_fragments_to_markdown: false
generate_requirements_txt: true
github_check_license: true
github_ci_extra_env: {}
Expand All @@ -20,6 +20,6 @@ repo_description: 'TODO: add repo description.'
repo_name: budgeting
repo_slug: budgeting
repo_website: https://github.com/ecosoft-odoo/budgeting
travis_apt_packages: []
travis_apt_sources: []
use_pyproject_toml: false
use_ruff: false

2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Get python version
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Stale PRs and issues policy
uses: actions/stale@v4
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# General settings.
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
# * Issues that are pending more information
# * Except Issues marked as "no stale"
- name: Needs more information stale issues policy
uses: actions/stale@v4
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
ascending: true
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,19 @@ jobs:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: codecov/codecov-action@v1
- name: Install addons and dependencies
run: oca_install_addons
- name: Check licenses
run: manifestoo -d . check-licenses
- name: Check development status
run: manifestoo -d . check-dev-status --default-dev-status=Beta
- name: Initialize test db
run: oca_init_test_database
# - name: Run tests
# run: oca_run_tests
# - uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# - name: Update .pot files
# run: oca_export_and_push_pot https://x-access-token:${{ secrets.GIT_PUSH_TOKEN }}@github.com/${{ github.repository }}
# if: ${{ matrix.makepot == 'true' && github.event_name == 'push' && github.repository_owner == 'OCA' }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __pycache__/
*.py[cod]
/.venv
/.pytest_cache
/.ruff_cache

# C extensions
*.so
Expand Down
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ exclude: |
^docs/_templates/.*\.html$|
# Don't bother non-technical authors with formatting issues in docs
readme/.*\.(rst|md)$|
# Ignore build and dist directories in addons
/build/|/dist/|
# Ignore test files in addons
/tests/samples/.*|
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
default_language_version:
Expand All @@ -35,7 +39,7 @@ repos:
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: 969238e47c07d0c40573acff81d170f63245d738
rev: 9a170331575a265c092ee6b24b845ec508e8ef75
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
Expand All @@ -48,6 +52,7 @@ repos:
- --org-name=ecosoft-odoo
- --repo-name=budgeting
- --if-source-changed
- --keep-source-digest
- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.0.25
hooks:
Expand Down Expand Up @@ -139,7 +144,7 @@ repos:
name: flake8
additional_dependencies: ["flake8-bugbear==21.9.2"]
- repo: https://github.com/OCA/pylint-odoo
rev: 7.0.2
rev: 7.0.5
hooks:
- id: pylint_odoo
name: pylint with optional checks
Expand Down
16 changes: 12 additions & 4 deletions budget_allocation/models/base_budget_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ def check_budget_allocation_limit(self, doclines):
query_dict = self._get_query_dict(docline)
if not any(x["amount_type"] == "1_budget" for x in query_dict):
errors.append(
_("{} & {} & {} is not allocated on budget allocation").format(
name, fund_name, tag_name or "False"
_(
"%(name)s & %(fund_name)s & %(tag_name)s is not allocated "
"on budget allocation",
name=name,
fund_name=fund_name,
tag_name=tag_name or "False",
)
)
continue
Expand All @@ -140,8 +144,12 @@ def check_budget_allocation_limit(self, doclines):
if float_compare(total_spend, 0.0, precision_digits=prec_digits) == -1:
errors.append(
_(
"{} & {} & {} spend amount over budget allocation limit {:,.2f}"
).format(name, fund_name, tag_name or "False", total_spend)
"%(name)s & %(fund_name)s & %(tag_name)s spend amount "
"over budget allocation limit {:,.2f}",
name=name,
fund_name=fund_name,
tag_name=tag_name or "False",
).format(total_spend)
)
return errors

Expand Down
26 changes: 12 additions & 14 deletions budget_allocation/models/budget_transfer_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,12 @@ def transfer(self):
allocation_lines = rec.allocation_line_from_ids + rec.allocation_line_to_ids
budget_allocation_ids = allocation_lines.mapped("budget_allocation_id")
message = _(
"{}<br/><b>transfer to</b><br/>{}<br/>with amount {:,.2f} {}"
).format(
rec._get_message_transfer_from(),
rec._get_message_transfer_to(),
rec.amount,
self.env.company.currency_id.symbol,
)
"%(message_from)s<br/><b>transfer to</b><br/>%(message_to)s"
"<br/>with amount {:,.2f} %(symbol)s",
message_from=rec._get_message_transfer_from(),
message_to=rec._get_message_transfer_to(),
symbol=self.env.company.currency_id.symbol,
).format(rec.amount)
budget_allocation_ids.message_post(body=message)
return res

Expand All @@ -329,12 +328,11 @@ def reverse(self):
allocation_lines = rec.allocation_line_from_ids + rec.allocation_line_to_ids
budget_allocation_ids = allocation_lines.mapped("budget_allocation_id")
message = _(
"{}<br/><b>reverse from</b><br/>{}<br/>with amount {:,.2f} {}"
).format(
rec._get_message_transfer_from(),
rec._get_message_transfer_to(),
rec.amount,
self.env.company.currency_id.symbol,
)
"%(message_from)s<br/><b>reverse from</b><br/>%(message_to)s"
"<br/>with amount {:,.2f} %(symbol)s",
message_from=rec._get_message_transfer_from(),
message_to=rec._get_message_transfer_to(),
symbol=self.env.company.currency_id.symbol,
).format(rec.amount)
budget_allocation_ids.message_post(body=message)
return res
18 changes: 11 additions & 7 deletions budget_control/models/budget_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,10 @@ def _check_budget_control_over_consumed(self):
)
if budget_info["amount_balance"] < 0:
raise UserError(
_("Total amount in KPI {} will result in {:,.2f}").format(
line.name, budget_info["amount_balance"]
)
_(
"Total amount in KPI %(name)s will result in {:,.2f}",
name=line.name,
).format(budget_info["amount_balance"])
)

@api.onchange("use_all_kpis")
Expand Down Expand Up @@ -365,8 +366,10 @@ def _check_budget_amount(self):
):
raise UserError(
_(
"Planning amount should equal to the released amount {:,.2f} {}"
).format(rec.released_amount, rec.currency_id.symbol)
"Planning amount should equal "
"to the released amount {:,.2f} %(symbol)s",
symbol=rec.currency_id.symbol,
).format(rec.released_amount)
)
# Check plan vs intial
if (
Expand All @@ -380,8 +383,9 @@ def _check_budget_amount(self):
raise UserError(
_(
"Planning amount should be greater than "
"initial balance {:,.2f} {}"
).format(rec.amount_initial, rec.currency_id.symbol)
"initial balance {:,.2f} %(symbol)s",
symbol=rec.currency_id.symbol,
).format(rec.amount_initial)
)

def action_draft(self):
Expand Down
8 changes: 6 additions & 2 deletions budget_control/models/budget_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def _check_budget_available(self, controls, budget_period):
balance_currency = self._get_balance_currency(
company, balance, doc_currency, date_commit
)
fomatted_balance = format_amount(
formatted_balance = format_amount(
self.env, balance_currency, doc_currency
)
analytic_name = Analytic.browse(analytic_id).display_name
Expand All @@ -447,7 +447,11 @@ def _check_budget_available(self, controls, budget_period):
template_lines.display_name, analytic_name
)
warnings.append(
_("{0}, will result in {1}").format(analytic_name, fomatted_balance)
_(
"%(analytic_name)s, will result in %(formatted_balance)s",
analytic_name=analytic_name,
formatted_balance=formatted_balance,
)
)
return list(set(warnings))

Expand Down

0 comments on commit 971b77d

Please sign in to comment.