Compare commits
1 Commits
18.0
...
18.0-proje
| Author | SHA1 | Date | |
|---|---|---|---|
| 1493a4a25e |
@@ -1,42 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Run the Python tests of the given Odoo modules.
|
|
||||||
#
|
|
||||||
# This script is meant to be executed *inside* an Elabore doodba image
|
|
||||||
# (docker.0k.io/mirror/odoo:rc_<version>-ELABORE-LIGHT), with a
|
|
||||||
# PostgreSQL service reachable at $PGHOST. The modules under test are
|
|
||||||
# read from the current working directory (the checked-out repository),
|
|
||||||
# which is prepended to the addons path so that the PR's code takes
|
|
||||||
# precedence over the modules already baked in the image.
|
|
||||||
#
|
|
||||||
# Usage: odoo-tests.sh <module1,module2,...>
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
modules="${1:?usage: odoo-tests.sh <module1,module2,...>}"
|
|
||||||
|
|
||||||
export PGHOST=postgres
|
|
||||||
export PGUSER=odoo
|
|
||||||
export PGPASSWORD=odoopassword
|
|
||||||
export PGDATABASE="test_$(basename "$PWD" | tr '.-' '__')"
|
|
||||||
export WITHOUT_DEMO=all
|
|
||||||
export DB_FILTER='.*'
|
|
||||||
|
|
||||||
# Generate /opt/odoo/auto/odoo.conf from the environment and wait for
|
|
||||||
# the database to accept connections.
|
|
||||||
/opt/odoo/common/entrypoint
|
|
||||||
|
|
||||||
# Odoo test-tags format: "/module1,/module2" (one leading slash).
|
|
||||||
tags="/$(echo "$modules" | tr ',' ',/')"
|
|
||||||
|
|
||||||
exec odoo \
|
|
||||||
--config=/opt/odoo/auto/odoo.conf \
|
|
||||||
--max-cron-threads=0 \
|
|
||||||
--limit-time-real=10000 \
|
|
||||||
--workers=0 \
|
|
||||||
--test-enable \
|
|
||||||
--stop-after-init \
|
|
||||||
--addons-path="$PWD,/opt/odoo/auto/addons" \
|
|
||||||
-d "$PGDATABASE" \
|
|
||||||
-i "$modules" \
|
|
||||||
--test-tags "$tags"
|
|
||||||
@@ -2,6 +2,8 @@ name: pre-commit
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- "16.0*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pre-commit:
|
pre-commit:
|
||||||
@@ -13,10 +15,10 @@ jobs:
|
|||||||
python-version: "3.11"
|
python-version: "3.11"
|
||||||
- name: Get python version
|
- name: Get python version
|
||||||
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
|
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
|
||||||
- uses: https://gitea.com/actions/cache@v3
|
# - uses: actions/cache@v4
|
||||||
with:
|
# with:
|
||||||
path: ~/.cache/pre-commit
|
# path: ~/.cache/pre-commit
|
||||||
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
# key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
- name: Install pre-commit
|
- name: Install pre-commit
|
||||||
run: pip install pre-commit
|
run: pip install pre-commit
|
||||||
- name: Run pre-commit
|
- name: Run pre-commit
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
name: tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- "18.0*"
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: odoo-ci
|
|
||||||
container:
|
|
||||||
image: docker.0k.io/mirror/odoo:rc_18.0-ELABORE-LIGHT
|
|
||||||
services:
|
|
||||||
postgres:
|
|
||||||
image: docker.0k.io/postgres:17.2.0-myc
|
|
||||||
env:
|
|
||||||
POSTGRES_USER: odoo
|
|
||||||
POSTGRES_PASSWORD: odoopassword
|
|
||||||
POSTGRES_DB: postgres
|
|
||||||
steps:
|
|
||||||
# The doodba image ships no Node.js, so actions/checkout@v4 cannot
|
|
||||||
# run here. The repository is private, so the job token is required.
|
|
||||||
- name: Checkout
|
|
||||||
env:
|
|
||||||
SECRET_GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
SECRET_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
token="${GITEA_TOKEN:-${GITHUB_TOKEN:-${SECRET_GITEA_TOKEN:-${SECRET_GITHUB_TOKEN:-}}}}"
|
|
||||||
if [ -z "$token" ]; then
|
|
||||||
echo "::error::No job token available to clone the repository"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
server="${GITHUB_SERVER_URL:-https://git.elabore.coop}"
|
|
||||||
repo="${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is not set}"
|
|
||||||
ref="${GITHUB_REF:-${GITHUB_SHA:?neither GITHUB_REF nor GITHUB_SHA is set}}"
|
|
||||||
auth_url="$(printf '%s' "${server%/}/${repo}.git" |
|
|
||||||
sed -E "s#^https://#https://${token}@#")"
|
|
||||||
git init -q .
|
|
||||||
git config --global --add safe.directory "$PWD"
|
|
||||||
git remote add origin "$auth_url"
|
|
||||||
git fetch -q --depth=1 origin "$ref"
|
|
||||||
git checkout -q FETCH_HEAD
|
|
||||||
|
|
||||||
- name: Detect changed modules
|
|
||||||
id: changed
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
if [ -n "${GITHUB_BASE_REF:-}" ]; then
|
|
||||||
git fetch -q --depth=1 origin "refs/heads/$GITHUB_BASE_REF"
|
|
||||||
base_rev="FETCH_HEAD"
|
|
||||||
scope="diff against $GITHUB_BASE_REF"
|
|
||||||
else
|
|
||||||
base_rev=""
|
|
||||||
scope="all installable modules (manual run)"
|
|
||||||
fi
|
|
||||||
if [ -n "$base_rev" ]; then
|
|
||||||
modules="$(
|
|
||||||
git diff --name-only "$base_rev" HEAD |
|
|
||||||
awk -F/ '{print $1}' | sort -u |
|
|
||||||
while read -r dir; do
|
|
||||||
[ -f "$dir/__manifest__.py" ] && echo "$dir"
|
|
||||||
done | paste -sd, -
|
|
||||||
)"
|
|
||||||
else
|
|
||||||
modules="$(
|
|
||||||
for dir in */; do
|
|
||||||
dir="${dir%/}"
|
|
||||||
[ -f "$dir/__manifest__.py" ] && echo "$dir"
|
|
||||||
done | paste -sd, -
|
|
||||||
)"
|
|
||||||
fi
|
|
||||||
echo "modules=$modules" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "Modules to test ($scope): ${modules:-<none>}"
|
|
||||||
|
|
||||||
- name: Run Odoo tests
|
|
||||||
if: steps.changed.outputs.modules != ''
|
|
||||||
run: bash .gitea/scripts/odoo-tests.sh "${{ steps.changed.outputs.modules }}"
|
|
||||||
90
.gitignore
vendored
90
.gitignore
vendored
@@ -1,88 +1,2 @@
|
|||||||
# Byte-compiled / optimized / DLL files
|
*.*~
|
||||||
__pycache__/
|
*.pyc
|
||||||
*.py[cod]
|
|
||||||
/.venv
|
|
||||||
/.pytest_cache
|
|
||||||
/.ruff_cache
|
|
||||||
|
|
||||||
# C extensions
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Distribution / packaging
|
|
||||||
.Python
|
|
||||||
env/
|
|
||||||
bin/
|
|
||||||
build/
|
|
||||||
develop-eggs/
|
|
||||||
dist/
|
|
||||||
eggs/
|
|
||||||
lib64/
|
|
||||||
parts/
|
|
||||||
sdist/
|
|
||||||
var/
|
|
||||||
*.egg-info/
|
|
||||||
.installed.cfg
|
|
||||||
*.egg
|
|
||||||
*.eggs
|
|
||||||
|
|
||||||
# Windows installers
|
|
||||||
*.msi
|
|
||||||
|
|
||||||
# Debian packages
|
|
||||||
*.deb
|
|
||||||
|
|
||||||
# Redhat packages
|
|
||||||
*.rpm
|
|
||||||
|
|
||||||
# MacOS packages
|
|
||||||
*.dmg
|
|
||||||
*.pkg
|
|
||||||
|
|
||||||
# Installer logs
|
|
||||||
pip-log.txt
|
|
||||||
pip-delete-this-directory.txt
|
|
||||||
|
|
||||||
# Unit test / coverage reports
|
|
||||||
htmlcov/
|
|
||||||
.tox/
|
|
||||||
.coverage
|
|
||||||
.cache
|
|
||||||
nosetests.xml
|
|
||||||
coverage.xml
|
|
||||||
|
|
||||||
# Translations
|
|
||||||
*.mo
|
|
||||||
|
|
||||||
# Pycharm
|
|
||||||
.idea
|
|
||||||
|
|
||||||
# Eclipse
|
|
||||||
.settings
|
|
||||||
|
|
||||||
# Visual Studio cache/options directory
|
|
||||||
.vs/
|
|
||||||
.vscode
|
|
||||||
|
|
||||||
# OSX Files
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# Django stuff:
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# Mr Developer
|
|
||||||
.mr.developer.cfg
|
|
||||||
.project
|
|
||||||
.pydevproject
|
|
||||||
|
|
||||||
# Rope
|
|
||||||
.ropeproject
|
|
||||||
|
|
||||||
# Sphinx documentation
|
|
||||||
docs/_build/
|
|
||||||
|
|
||||||
# Backup files
|
|
||||||
*~
|
|
||||||
*.swp
|
|
||||||
|
|
||||||
# OCA rules
|
|
||||||
!static/lib/
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ exclude: |
|
|||||||
(LICENSE.*|COPYING.*)
|
(LICENSE.*|COPYING.*)
|
||||||
default_language_version:
|
default_language_version:
|
||||||
python: python3
|
python: python3
|
||||||
node: "22.9.0"
|
node: "16.17.0"
|
||||||
repos:
|
repos:
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
@@ -38,12 +38,8 @@ repos:
|
|||||||
entry: found a en.po file
|
entry: found a en.po file
|
||||||
language: fail
|
language: fail
|
||||||
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
|
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
|
||||||
- repo: https://github.com/sbidoul/whool
|
|
||||||
rev: v1.3
|
|
||||||
hooks:
|
|
||||||
- id: whool-init
|
|
||||||
- repo: https://github.com/oca/maintainer-tools
|
- repo: https://github.com/oca/maintainer-tools
|
||||||
rev: b89f767503be6ab2b11e4f50a7557cb20066e667
|
rev: f9b919b9868143135a9c9cb03021089cabba8223
|
||||||
hooks:
|
hooks:
|
||||||
# update the NOT INSTALLABLE ADDONS section above
|
# update the NOT INSTALLABLE ADDONS section above
|
||||||
- id: oca-update-pre-commit-excluded-addons
|
- id: oca-update-pre-commit-excluded-addons
|
||||||
@@ -53,13 +49,16 @@ repos:
|
|||||||
$(git rev-parse --show-toplevel))"'
|
$(git rev-parse --show-toplevel))"'
|
||||||
- id: oca-gen-addon-readme
|
- id: oca-gen-addon-readme
|
||||||
entry:
|
entry:
|
||||||
bash -c 'oca-gen-addon-readme --addons-dir=. --branch=$(git symbolic-ref
|
bash -c 'oca-gen-addon-readme
|
||||||
|
--addons-dir=.
|
||||||
|
--branch=$(git symbolic-ref
|
||||||
refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@")
|
refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@")
|
||||||
--repo-name=$(basename $(git rev-parse --show-toplevel)) --org-name="Elabore"
|
--repo-name=$(basename $(git rev-parse --show-toplevel))
|
||||||
--if-source-changed --keep-source-digest --convert-fragments-to-markdown'
|
--org-name="Elabore"
|
||||||
- id: oca-gen-external-dependencies
|
--if-source-changed --keep-source-digest'
|
||||||
|
|
||||||
- repo: https://github.com/OCA/odoo-pre-commit-hooks
|
- repo: https://github.com/OCA/odoo-pre-commit-hooks
|
||||||
rev: v0.0.33
|
rev: v0.1.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: oca-checks-odoo-module
|
- id: oca-checks-odoo-module
|
||||||
- id: oca-checks-po
|
- id: oca-checks-po
|
||||||
@@ -78,8 +77,8 @@ repos:
|
|||||||
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
|
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
|
||||||
language: node
|
language: node
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- "prettier@3.3.3"
|
- "prettier@2.7.1"
|
||||||
- "@prettier/plugin-xml@3.4.1"
|
- "@prettier/plugin-xml@2.2.0"
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: eslint
|
- id: eslint
|
||||||
@@ -92,11 +91,10 @@ repos:
|
|||||||
types: [javascript]
|
types: [javascript]
|
||||||
language: node
|
language: node
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- "eslint@9.12.0"
|
- "eslint@8.24.0"
|
||||||
- "eslint-plugin-jsdoc@50.3.1"
|
- "eslint-plugin-jsdoc@"
|
||||||
- "globals@16.0.0"
|
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.6.0
|
rev: v5.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
# exclude autogenerated files
|
# exclude autogenerated files
|
||||||
@@ -117,8 +115,23 @@ repos:
|
|||||||
- id: check-xml
|
- id: check-xml
|
||||||
- id: mixed-line-ending
|
- id: mixed-line-ending
|
||||||
args: ["--fix=lf"]
|
args: ["--fix=lf"]
|
||||||
|
- repo: https://github.com/PyCQA/docformatter
|
||||||
|
rev: v1.7.7
|
||||||
|
hooks:
|
||||||
|
- id: docformatter
|
||||||
|
args: [
|
||||||
|
"--in-place", # modify the files
|
||||||
|
"--recursive", # run on all the files
|
||||||
|
"--wrap-summaries",
|
||||||
|
"88", # max length of 1st line
|
||||||
|
"--wrap-descriptions",
|
||||||
|
"88", # max length of other lines
|
||||||
|
"--pre-summary-newline", # new line before a long summary
|
||||||
|
"--make-summary-multi-line", # force summary on multilines
|
||||||
|
]
|
||||||
|
additional_dependencies: ["tomli"] # if Python <3.11
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.6.8
|
rev: v0.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: [--fix, --exit-non-zero-on-fix]
|
args: [--fix, --exit-non-zero-on-fix]
|
||||||
|
|||||||
73
.pylintrc
73
.pylintrc
@@ -10,7 +10,7 @@ manifest-required-authors=Elabore
|
|||||||
manifest-required-keys=license
|
manifest-required-keys=license
|
||||||
manifest-deprecated-keys=description,active
|
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
|
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
|
||||||
valid-odoo-versions=18.0
|
valid-odoo-versions=16.0
|
||||||
|
|
||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
disable=all
|
disable=all
|
||||||
@@ -25,25 +25,19 @@ disable=all
|
|||||||
enable=anomalous-backslash-in-string,
|
enable=anomalous-backslash-in-string,
|
||||||
api-one-deprecated,
|
api-one-deprecated,
|
||||||
api-one-multi-together,
|
api-one-multi-together,
|
||||||
|
assignment-from-none,
|
||||||
|
attribute-deprecated,
|
||||||
class-camelcase,
|
class-camelcase,
|
||||||
|
dangerous-default-value,
|
||||||
dangerous-view-replace-wo-priority,
|
dangerous-view-replace-wo-priority,
|
||||||
|
development-status-allowed,
|
||||||
duplicate-id-csv,
|
duplicate-id-csv,
|
||||||
|
duplicate-key,
|
||||||
duplicate-xml-fields,
|
duplicate-xml-fields,
|
||||||
duplicate-xml-record-id,
|
duplicate-xml-record-id,
|
||||||
eval-referenced,
|
eval-referenced,
|
||||||
incoherent-interpreter-exec-perm,
|
|
||||||
openerp-exception-warning,
|
|
||||||
redundant-modulename-xml,
|
|
||||||
relative-import,
|
|
||||||
rst-syntax-error,
|
|
||||||
wrong-tabs-instead-of-spaces,
|
|
||||||
xml-syntax-error,
|
|
||||||
assignment-from-none,
|
|
||||||
attribute-deprecated,
|
|
||||||
dangerous-default-value,
|
|
||||||
development-status-allowed,
|
|
||||||
duplicate-key,
|
|
||||||
eval-used,
|
eval-used,
|
||||||
|
incoherent-interpreter-exec-perm,
|
||||||
license-allowed,
|
license-allowed,
|
||||||
manifest-author-string,
|
manifest-author-string,
|
||||||
manifest-deprecated-key,
|
manifest-deprecated-key,
|
||||||
@@ -54,68 +48,73 @@ enable=anomalous-backslash-in-string,
|
|||||||
method-inverse,
|
method-inverse,
|
||||||
method-required-super,
|
method-required-super,
|
||||||
method-search,
|
method-search,
|
||||||
|
openerp-exception-warning,
|
||||||
pointless-statement,
|
pointless-statement,
|
||||||
pointless-string-statement,
|
pointless-string-statement,
|
||||||
print-used,
|
print-used,
|
||||||
redundant-keyword-arg,
|
redundant-keyword-arg,
|
||||||
|
redundant-modulename-xml,
|
||||||
reimported,
|
reimported,
|
||||||
|
relative-import,
|
||||||
return-in-init,
|
return-in-init,
|
||||||
|
rst-syntax-error,
|
||||||
sql-injection,
|
sql-injection,
|
||||||
too-few-format-args,
|
too-few-format-args,
|
||||||
translation-field,
|
translation-field,
|
||||||
translation-required,
|
translation-required,
|
||||||
unreachable,
|
unreachable,
|
||||||
use-vim-comment,
|
use-vim-comment,
|
||||||
|
wrong-tabs-instead-of-spaces,
|
||||||
|
xml-syntax-error,
|
||||||
|
attribute-string-redundant,
|
||||||
character-not-valid-in-resource-link,
|
character-not-valid-in-resource-link,
|
||||||
|
consider-merging-classes-inherited,
|
||||||
|
context-overridden,
|
||||||
create-user-wo-reset-password,
|
create-user-wo-reset-password,
|
||||||
dangerous-filter-wo-user,
|
dangerous-filter-wo-user,
|
||||||
dangerous-qweb-replace-wo-priority,
|
dangerous-qweb-replace-wo-priority,
|
||||||
deprecated-data-xml-node,
|
deprecated-data-xml-node,
|
||||||
deprecated-openerp-xml-node,
|
deprecated-openerp-xml-node,
|
||||||
duplicate-po-message-definition,
|
duplicate-po-message-definition,
|
||||||
file-not-used,
|
|
||||||
missing-newline-extrafiles,
|
|
||||||
old-api7-method-defined,
|
|
||||||
po-msgstr-variables,
|
|
||||||
po-syntax-error,
|
|
||||||
str-format-used,
|
|
||||||
unnecessary-utf8-coding-comment,
|
|
||||||
xml-attribute-translatable,
|
|
||||||
xml-deprecated-qweb-directive,
|
|
||||||
xml-deprecated-tree-attribute,
|
|
||||||
attribute-string-redundant,
|
|
||||||
consider-merging-classes-inherited,
|
|
||||||
context-overridden,
|
|
||||||
except-pass,
|
except-pass,
|
||||||
|
file-not-used,
|
||||||
invalid-commit,
|
invalid-commit,
|
||||||
manifest-maintainers-list,
|
manifest-maintainers-list,
|
||||||
|
missing-newline-extrafiles,
|
||||||
missing-readme,
|
missing-readme,
|
||||||
missing-return,
|
missing-return,
|
||||||
odoo-addons-relative-import,
|
odoo-addons-relative-import,
|
||||||
|
old-api7-method-defined,
|
||||||
|
po-msgstr-variables,
|
||||||
|
po-syntax-error,
|
||||||
renamed-field-parameter,
|
renamed-field-parameter,
|
||||||
resource-not-exist,
|
resource-not-exist,
|
||||||
|
str-format-used,
|
||||||
test-folder-imported,
|
test-folder-imported,
|
||||||
translation-contains-variable,
|
translation-contains-variable,
|
||||||
translation-positional-used,
|
translation-positional-used,
|
||||||
website-manifest-key-not-valid-uri,
|
|
||||||
external-request-timeout,
|
|
||||||
missing-manifest-dependency,
|
|
||||||
too-complex,,
|
|
||||||
create-user-wo-reset-password,
|
|
||||||
dangerous-filter-wo-user,
|
|
||||||
file-not-used,
|
|
||||||
missing-newline-extrafiles,
|
|
||||||
no-utf8-coding-comment,
|
|
||||||
old-api7-method-defined,
|
|
||||||
unnecessary-utf8-coding-comment,
|
unnecessary-utf8-coding-comment,
|
||||||
|
website-manifest-key-not-valid-uri,
|
||||||
|
xml-attribute-translatable,
|
||||||
|
xml-deprecated-qweb-directive,
|
||||||
|
xml-deprecated-tree-attribute,
|
||||||
|
external-request-timeout,
|
||||||
# messages that do not cause the lint step to fail
|
# messages that do not cause the lint step to fail
|
||||||
consider-merging-classes-inherited,
|
consider-merging-classes-inherited,
|
||||||
|
create-user-wo-reset-password,
|
||||||
|
dangerous-filter-wo-user,
|
||||||
deprecated-module,
|
deprecated-module,
|
||||||
|
file-not-used,
|
||||||
invalid-commit,
|
invalid-commit,
|
||||||
|
missing-manifest-dependency,
|
||||||
|
missing-newline-extrafiles,
|
||||||
missing-readme,
|
missing-readme,
|
||||||
|
no-utf8-coding-comment,
|
||||||
odoo-addons-relative-import,
|
odoo-addons-relative-import,
|
||||||
|
old-api7-method-defined,
|
||||||
redefined-builtin,
|
redefined-builtin,
|
||||||
manifest-external-assets
|
too-complex,
|
||||||
|
unnecessary-utf8-coding-comment
|
||||||
|
|
||||||
|
|
||||||
[REPORTS]
|
[REPORTS]
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ manifest-required-authors=Elabore
|
|||||||
manifest-required-keys=license
|
manifest-required-keys=license
|
||||||
manifest-deprecated-keys=description,active
|
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
|
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
|
||||||
valid-odoo-versions=18.0
|
valid-odoo-versions=16.0
|
||||||
|
|
||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
disable=all
|
disable=all
|
||||||
@@ -17,25 +17,19 @@ disable=all
|
|||||||
enable=anomalous-backslash-in-string,
|
enable=anomalous-backslash-in-string,
|
||||||
api-one-deprecated,
|
api-one-deprecated,
|
||||||
api-one-multi-together,
|
api-one-multi-together,
|
||||||
|
assignment-from-none,
|
||||||
|
attribute-deprecated,
|
||||||
class-camelcase,
|
class-camelcase,
|
||||||
|
dangerous-default-value,
|
||||||
dangerous-view-replace-wo-priority,
|
dangerous-view-replace-wo-priority,
|
||||||
|
development-status-allowed,
|
||||||
duplicate-id-csv,
|
duplicate-id-csv,
|
||||||
|
duplicate-key,
|
||||||
duplicate-xml-fields,
|
duplicate-xml-fields,
|
||||||
duplicate-xml-record-id,
|
duplicate-xml-record-id,
|
||||||
eval-referenced,
|
eval-referenced,
|
||||||
incoherent-interpreter-exec-perm,
|
|
||||||
openerp-exception-warning,
|
|
||||||
redundant-modulename-xml,
|
|
||||||
relative-import,
|
|
||||||
rst-syntax-error,
|
|
||||||
wrong-tabs-instead-of-spaces,
|
|
||||||
xml-syntax-error,
|
|
||||||
assignment-from-none,
|
|
||||||
attribute-deprecated,
|
|
||||||
dangerous-default-value,
|
|
||||||
development-status-allowed,
|
|
||||||
duplicate-key,
|
|
||||||
eval-used,
|
eval-used,
|
||||||
|
incoherent-interpreter-exec-perm,
|
||||||
license-allowed,
|
license-allowed,
|
||||||
manifest-author-string,
|
manifest-author-string,
|
||||||
manifest-deprecated-key,
|
manifest-deprecated-key,
|
||||||
@@ -46,50 +40,56 @@ enable=anomalous-backslash-in-string,
|
|||||||
method-inverse,
|
method-inverse,
|
||||||
method-required-super,
|
method-required-super,
|
||||||
method-search,
|
method-search,
|
||||||
|
openerp-exception-warning,
|
||||||
pointless-statement,
|
pointless-statement,
|
||||||
pointless-string-statement,
|
pointless-string-statement,
|
||||||
print-used,
|
print-used,
|
||||||
redundant-keyword-arg,
|
redundant-keyword-arg,
|
||||||
|
redundant-modulename-xml,
|
||||||
reimported,
|
reimported,
|
||||||
|
relative-import,
|
||||||
return-in-init,
|
return-in-init,
|
||||||
|
rst-syntax-error,
|
||||||
sql-injection,
|
sql-injection,
|
||||||
too-few-format-args,
|
too-few-format-args,
|
||||||
translation-field,
|
translation-field,
|
||||||
translation-required,
|
translation-required,
|
||||||
unreachable,
|
unreachable,
|
||||||
use-vim-comment,
|
use-vim-comment,
|
||||||
|
wrong-tabs-instead-of-spaces,
|
||||||
|
xml-syntax-error,
|
||||||
|
attribute-string-redundant,
|
||||||
character-not-valid-in-resource-link,
|
character-not-valid-in-resource-link,
|
||||||
|
consider-merging-classes-inherited,
|
||||||
|
context-overridden,
|
||||||
create-user-wo-reset-password,
|
create-user-wo-reset-password,
|
||||||
dangerous-filter-wo-user,
|
dangerous-filter-wo-user,
|
||||||
dangerous-qweb-replace-wo-priority,
|
dangerous-qweb-replace-wo-priority,
|
||||||
deprecated-data-xml-node,
|
deprecated-data-xml-node,
|
||||||
deprecated-openerp-xml-node,
|
deprecated-openerp-xml-node,
|
||||||
duplicate-po-message-definition,
|
duplicate-po-message-definition,
|
||||||
file-not-used,
|
|
||||||
missing-newline-extrafiles,
|
|
||||||
old-api7-method-defined,
|
|
||||||
po-msgstr-variables,
|
|
||||||
po-syntax-error,
|
|
||||||
str-format-used,
|
|
||||||
unnecessary-utf8-coding-comment,
|
|
||||||
xml-attribute-translatable,
|
|
||||||
xml-deprecated-qweb-directive,
|
|
||||||
xml-deprecated-tree-attribute,
|
|
||||||
attribute-string-redundant,
|
|
||||||
consider-merging-classes-inherited,
|
|
||||||
context-overridden,
|
|
||||||
except-pass,
|
except-pass,
|
||||||
|
file-not-used,
|
||||||
invalid-commit,
|
invalid-commit,
|
||||||
manifest-maintainers-list,
|
manifest-maintainers-list,
|
||||||
|
missing-newline-extrafiles,
|
||||||
missing-readme,
|
missing-readme,
|
||||||
missing-return,
|
missing-return,
|
||||||
odoo-addons-relative-import,
|
odoo-addons-relative-import,
|
||||||
|
old-api7-method-defined,
|
||||||
|
po-msgstr-variables,
|
||||||
|
po-syntax-error,
|
||||||
renamed-field-parameter,
|
renamed-field-parameter,
|
||||||
resource-not-exist,
|
resource-not-exist,
|
||||||
|
str-format-used,
|
||||||
test-folder-imported,
|
test-folder-imported,
|
||||||
translation-contains-variable,
|
translation-contains-variable,
|
||||||
translation-positional-used,
|
translation-positional-used,
|
||||||
|
unnecessary-utf8-coding-comment,
|
||||||
website-manifest-key-not-valid-uri,
|
website-manifest-key-not-valid-uri,
|
||||||
|
xml-attribute-translatable,
|
||||||
|
xml-deprecated-qweb-directive,
|
||||||
|
xml-deprecated-tree-attribute,
|
||||||
external-request-timeout
|
external-request-timeout
|
||||||
|
|
||||||
[REPORTS]
|
[REPORTS]
|
||||||
|
|||||||
@@ -1,205 +0,0 @@
|
|||||||
var globals = require('globals');
|
|
||||||
jsdoc = require("eslint-plugin-jsdoc");
|
|
||||||
|
|
||||||
const config = [{
|
|
||||||
plugins: {
|
|
||||||
jsdoc,
|
|
||||||
},
|
|
||||||
|
|
||||||
languageOptions: {
|
|
||||||
globals: {
|
|
||||||
_: "readonly",
|
|
||||||
$: "readonly",
|
|
||||||
fuzzy: "readonly",
|
|
||||||
jQuery: "readonly",
|
|
||||||
moment: "readonly",
|
|
||||||
odoo: "readonly",
|
|
||||||
openerp: "readonly",
|
|
||||||
owl: "readonly",
|
|
||||||
luxon: "readonly",
|
|
||||||
QUnit: "readonly",
|
|
||||||
...globals.browser,
|
|
||||||
},
|
|
||||||
|
|
||||||
ecmaVersion: 2024,
|
|
||||||
sourceType: "script",
|
|
||||||
},
|
|
||||||
|
|
||||||
rules: {
|
|
||||||
"accessor-pairs": "warn",
|
|
||||||
"array-callback-return": "warn",
|
|
||||||
"callback-return": "warn",
|
|
||||||
"capitalized-comments": ["warn", "always", {
|
|
||||||
ignoreConsecutiveComments: true,
|
|
||||||
ignoreInlineComments: true,
|
|
||||||
}],
|
|
||||||
complexity: ["warn", 15],
|
|
||||||
"constructor-super": "warn",
|
|
||||||
"dot-notation": "warn",
|
|
||||||
eqeqeq: "warn",
|
|
||||||
"global-require": "warn",
|
|
||||||
"handle-callback-err": "warn",
|
|
||||||
"id-blacklist": "warn",
|
|
||||||
"id-match": "warn",
|
|
||||||
"init-declarations": "error",
|
|
||||||
"max-depth": "warn",
|
|
||||||
"max-nested-callbacks": "warn",
|
|
||||||
"max-statements-per-line": "warn",
|
|
||||||
"no-alert": "warn",
|
|
||||||
"no-array-constructor": "warn",
|
|
||||||
"no-caller": "warn",
|
|
||||||
"no-case-declarations": "warn",
|
|
||||||
"no-class-assign": "warn",
|
|
||||||
"no-cond-assign": "error",
|
|
||||||
"no-const-assign": "error",
|
|
||||||
"no-constant-condition": "warn",
|
|
||||||
"no-control-regex": "warn",
|
|
||||||
"no-debugger": "error",
|
|
||||||
"no-delete-var": "warn",
|
|
||||||
"no-div-regex": "warn",
|
|
||||||
"no-dupe-args": "error",
|
|
||||||
"no-dupe-class-members": "error",
|
|
||||||
"no-dupe-keys": "error",
|
|
||||||
"no-duplicate-case": "error",
|
|
||||||
"no-duplicate-imports": "error",
|
|
||||||
"no-else-return": "warn",
|
|
||||||
"no-empty-character-class": "warn",
|
|
||||||
"no-empty-function": "error",
|
|
||||||
"no-empty-pattern": "error",
|
|
||||||
"no-empty": "warn",
|
|
||||||
"no-eq-null": "error",
|
|
||||||
"no-eval": "error",
|
|
||||||
"no-ex-assign": "error",
|
|
||||||
"no-extend-native": "warn",
|
|
||||||
"no-extra-bind": "warn",
|
|
||||||
"no-extra-boolean-cast": "warn",
|
|
||||||
"no-extra-label": "warn",
|
|
||||||
"no-fallthrough": "warn",
|
|
||||||
"no-func-assign": "error",
|
|
||||||
"no-global-assign": "error",
|
|
||||||
"no-implicit-coercion": ["warn", {
|
|
||||||
allow: ["~"],
|
|
||||||
}],
|
|
||||||
"no-implicit-globals": "warn",
|
|
||||||
"no-implied-eval": "warn",
|
|
||||||
"no-inline-comments": "warn",
|
|
||||||
"no-inner-declarations": "warn",
|
|
||||||
"no-invalid-regexp": "warn",
|
|
||||||
"no-irregular-whitespace": "warn",
|
|
||||||
"no-iterator": "warn",
|
|
||||||
"no-label-var": "warn",
|
|
||||||
"no-labels": "warn",
|
|
||||||
"no-lone-blocks": "warn",
|
|
||||||
"no-lonely-if": "error",
|
|
||||||
"no-mixed-requires": "error",
|
|
||||||
"no-multi-str": "warn",
|
|
||||||
"no-native-reassign": "error",
|
|
||||||
"no-negated-condition": "warn",
|
|
||||||
"no-negated-in-lhs": "error",
|
|
||||||
"no-new-func": "warn",
|
|
||||||
"no-new-object": "warn",
|
|
||||||
"no-new-require": "warn",
|
|
||||||
"no-new-symbol": "warn",
|
|
||||||
"no-new-wrappers": "warn",
|
|
||||||
"no-new": "warn",
|
|
||||||
"no-obj-calls": "warn",
|
|
||||||
"no-octal-escape": "warn",
|
|
||||||
"no-octal": "warn",
|
|
||||||
"no-param-reassign": "warn",
|
|
||||||
"no-path-concat": "warn",
|
|
||||||
"no-process-env": "warn",
|
|
||||||
"no-process-exit": "warn",
|
|
||||||
"no-proto": "warn",
|
|
||||||
"no-prototype-builtins": "warn",
|
|
||||||
"no-redeclare": "warn",
|
|
||||||
"no-regex-spaces": "warn",
|
|
||||||
"no-restricted-globals": "warn",
|
|
||||||
"no-restricted-imports": "warn",
|
|
||||||
"no-restricted-modules": "warn",
|
|
||||||
"no-restricted-syntax": "warn",
|
|
||||||
"no-return-assign": "error",
|
|
||||||
"no-script-url": "warn",
|
|
||||||
"no-self-assign": "warn",
|
|
||||||
"no-self-compare": "warn",
|
|
||||||
"no-sequences": "warn",
|
|
||||||
"no-shadow-restricted-names": "warn",
|
|
||||||
"no-shadow": "warn",
|
|
||||||
"no-sparse-arrays": "warn",
|
|
||||||
"no-sync": "warn",
|
|
||||||
"no-this-before-super": "warn",
|
|
||||||
"no-throw-literal": "warn",
|
|
||||||
"no-undef-init": "warn",
|
|
||||||
"no-undef": "error",
|
|
||||||
"no-unmodified-loop-condition": "warn",
|
|
||||||
"no-unneeded-ternary": "error",
|
|
||||||
"no-unreachable": "error",
|
|
||||||
"no-unsafe-finally": "error",
|
|
||||||
"no-unused-expressions": "error",
|
|
||||||
"no-unused-labels": "error",
|
|
||||||
"no-unused-vars": "error",
|
|
||||||
"no-use-before-define": "error",
|
|
||||||
"no-useless-call": "warn",
|
|
||||||
"no-useless-computed-key": "warn",
|
|
||||||
"no-useless-concat": "warn",
|
|
||||||
"no-useless-constructor": "warn",
|
|
||||||
"no-useless-escape": "warn",
|
|
||||||
"no-useless-rename": "warn",
|
|
||||||
"no-void": "warn",
|
|
||||||
"no-with": "warn",
|
|
||||||
"operator-assignment": ["error", "always"],
|
|
||||||
"prefer-const": "warn",
|
|
||||||
radix: "warn",
|
|
||||||
"require-yield": "warn",
|
|
||||||
"sort-imports": "warn",
|
|
||||||
"spaced-comment": ["error", "always"],
|
|
||||||
strict: ["error", "function"],
|
|
||||||
"use-isnan": "error",
|
|
||||||
|
|
||||||
"jsdoc/check-tag-names": "warn",
|
|
||||||
"jsdoc/check-types": "warn",
|
|
||||||
"jsdoc/require-param-description": "off",
|
|
||||||
"jsdoc/require-return": "off",
|
|
||||||
"jsdoc/require-return-description": "off",
|
|
||||||
"jsdoc/require-return-type": "off",
|
|
||||||
|
|
||||||
"valid-typeof": "warn",
|
|
||||||
yoda: "warn",
|
|
||||||
},
|
|
||||||
|
|
||||||
settings: {
|
|
||||||
jsdoc: {
|
|
||||||
tagNamePreference: {
|
|
||||||
arg: "param",
|
|
||||||
argument: "param",
|
|
||||||
augments: "extends",
|
|
||||||
constructor: "class",
|
|
||||||
exception: "throws",
|
|
||||||
func: "function",
|
|
||||||
method: "function",
|
|
||||||
prop: "property",
|
|
||||||
return: "returns",
|
|
||||||
virtual: "abstract",
|
|
||||||
yield: "yields",
|
|
||||||
},
|
|
||||||
preferredTypes: {
|
|
||||||
array: "Array",
|
|
||||||
bool: "Boolean",
|
|
||||||
boolean: "Boolean",
|
|
||||||
number: "Number",
|
|
||||||
object: "Object",
|
|
||||||
str: "String",
|
|
||||||
string: "String",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
}, {
|
|
||||||
files: ["**/*.esm.js", "**/*test.js"],
|
|
||||||
|
|
||||||
languageOptions: {
|
|
||||||
ecmaVersion: 2024,
|
|
||||||
sourceType: "module",
|
|
||||||
},
|
|
||||||
}];
|
|
||||||
|
|
||||||
module.exports = config
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/** @type {import('prettier').Config} */
|
|
||||||
|
|
||||||
const config = {
|
|
||||||
// https://github.com/prettier/prettier/issues/15388#issuecomment-1717746872
|
|
||||||
plugins: [require.resolve("@prettier/plugin-xml")],
|
|
||||||
bracketSpacing: false,
|
|
||||||
printWidth: 88,
|
|
||||||
proseWrap: "always",
|
|
||||||
semi: true,
|
|
||||||
trailingComma: "es5",
|
|
||||||
xmlWhitespaceSensitivity: "preserve",
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = config;
|
|
||||||
1
project_dashboard_billable_hours/__init__.py
Normal file
1
project_dashboard_billable_hours/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
32
project_dashboard_billable_hours/__manifest__.py
Normal file
32
project_dashboard_billable_hours/__manifest__.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Copyright 2026 Maud Buchwalter (Elabore)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "project_dashboard_billable_hours",
|
||||||
|
"version": "18.0.1.0.0",
|
||||||
|
"author": "Elabore",
|
||||||
|
"website": "https://git.elabore.coop/elabore/project-tools",
|
||||||
|
"maintainer": "Maud Buchwalter",
|
||||||
|
"license": "AGPL-3",
|
||||||
|
"category": "Tools",
|
||||||
|
"summary": "Display billable hours (timesheets linked to a SO line) in the project dashboard panel",
|
||||||
|
# any module necessary for this one to work correctly
|
||||||
|
"depends": ["sale_timesheet"],
|
||||||
|
"qweb": [
|
||||||
|
# "static/src/xml/*.xml",
|
||||||
|
],
|
||||||
|
"external_dependencies": {
|
||||||
|
"python": [],
|
||||||
|
},
|
||||||
|
# always loaded
|
||||||
|
"data": [],
|
||||||
|
# only loaded in demonstration mode
|
||||||
|
"demo": [],
|
||||||
|
"js": [],
|
||||||
|
"css": [],
|
||||||
|
"installable": True,
|
||||||
|
# Install this module automatically if all dependency have been previously
|
||||||
|
# and independently installed. Used for synergetic or glue modules.
|
||||||
|
"auto_install": False,
|
||||||
|
"application": False,
|
||||||
|
}
|
||||||
57
project_dashboard_billable_hours/i18n/fr.po
Normal file
57
project_dashboard_billable_hours/i18n/fr.po
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * project_dashboard_billable_hours
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 18.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2026-09-25 16:40+0000\n"
|
||||||
|
"PO-Revision-Date: 2026-09-25 16:40+0000\n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: \n"
|
||||||
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
|
#. module: project_dashboard_billable_hours
|
||||||
|
#. odoo-python
|
||||||
|
#: code:addons/project_dashboard_billable_hours/models/project_project.py:0
|
||||||
|
msgid "%(billable)s %(uom_name)s"
|
||||||
|
msgstr "%(billable)s %(uom_name)s"
|
||||||
|
|
||||||
|
#. module: project_dashboard_billable_hours
|
||||||
|
#. odoo-python
|
||||||
|
#: code:addons/project_dashboard_billable_hours/models/project_project.py:0
|
||||||
|
msgid "%(billable)s / %(effective)s %(uom_name)s"
|
||||||
|
msgstr "%(billable)s / %(effective)s %(uom_name)s"
|
||||||
|
|
||||||
|
#. module: project_dashboard_billable_hours
|
||||||
|
#. odoo-python
|
||||||
|
#: code:addons/project_dashboard_billable_hours/models/project_project.py:0
|
||||||
|
msgid "%(billable)s / %(effective)s %(uom_name)s (%(billable_rate)s%%)"
|
||||||
|
msgstr "%(billable)s / %(effective)s %(uom_name)s (%(billable_rate)s%%)"
|
||||||
|
|
||||||
|
#. module: project_dashboard_billable_hours
|
||||||
|
#. odoo-python
|
||||||
|
#: code:addons/project_dashboard_billable_hours/models/project_project.py:0
|
||||||
|
msgid "%(name)s's Billable Timesheets"
|
||||||
|
msgstr "%(name)s's Feuille de temps facturable"
|
||||||
|
|
||||||
|
#. module: project_dashboard_billable_hours
|
||||||
|
#. odoo-python
|
||||||
|
#: code:addons/project_dashboard_billable_hours/models/project_project.py:0
|
||||||
|
#: model:ir.model.fields,field_description:project_dashboard_billable_hours.field_project_project__billable_hours
|
||||||
|
msgid "Billable Time"
|
||||||
|
msgstr "Temps facturable"
|
||||||
|
|
||||||
|
#. module: project_dashboard_billable_hours
|
||||||
|
#: model:ir.model,name:project_dashboard_billable_hours.model_project_project
|
||||||
|
msgid "Project"
|
||||||
|
msgstr "Projet"
|
||||||
|
|
||||||
|
#. module: project_dashboard_billable_hours
|
||||||
|
#: model:ir.model.fields,field_description:project_dashboard_billable_hours.field_project_project__smart_search
|
||||||
|
msgid "Smart Search"
|
||||||
|
msgstr ""
|
||||||
1
project_dashboard_billable_hours/models/__init__.py
Normal file
1
project_dashboard_billable_hours/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import project_project
|
||||||
104
project_dashboard_billable_hours/models/project_project.py
Normal file
104
project_dashboard_billable_hours/models/project_project.py
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class Project(models.Model):
|
||||||
|
_inherit = "project.project"
|
||||||
|
|
||||||
|
billable_hours = fields.Float(
|
||||||
|
string="Billable Time",
|
||||||
|
compute="_compute_billable_hours",
|
||||||
|
compute_sudo=True,
|
||||||
|
groups="hr_timesheet.group_hr_timesheet_user",
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends('timesheet_ids.unit_amount', 'timesheet_ids.so_line')
|
||||||
|
def _compute_billable_hours(self):
|
||||||
|
if not any(self._ids):
|
||||||
|
for project in self:
|
||||||
|
filtered_timesheets = project.timesheet_ids.filtered(
|
||||||
|
lambda t: t.so_line
|
||||||
|
)
|
||||||
|
project.billable_hours = sum(
|
||||||
|
filtered_timesheets.mapped("unit_amount")
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
timesheet_read_group = self.env["account.analytic.line"]._read_group(
|
||||||
|
[
|
||||||
|
("project_id", "in", self.ids),
|
||||||
|
("so_line", "!=", False),
|
||||||
|
],
|
||||||
|
["project_id"],
|
||||||
|
["unit_amount:sum"],
|
||||||
|
)
|
||||||
|
|
||||||
|
timesheets_per_project = {
|
||||||
|
project.id: unit_amount for project, unit_amount in timesheet_read_group
|
||||||
|
}
|
||||||
|
for project in self:
|
||||||
|
project.billable_hours = timesheets_per_project.get(project.id, 0.0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def action_project_billable_timesheets(self):
|
||||||
|
self.ensure_one()
|
||||||
|
action = self.action_billable_time_button() # sale_timesheet
|
||||||
|
action['domain'] = [('project_id', '=', self.id), ('so_line', '!=', False)]
|
||||||
|
action['display_name'] = self.env._("%(name)s's Billable Timesheets", name=self.name)
|
||||||
|
return action
|
||||||
|
|
||||||
|
|
||||||
|
def _get_stat_buttons(self):
|
||||||
|
buttons = super()._get_stat_buttons()
|
||||||
|
if not (self.allow_billable and self.allow_timesheets) \
|
||||||
|
or not self.env.user.has_group("hr_timesheet.group_hr_timesheet_user"):
|
||||||
|
return buttons
|
||||||
|
|
||||||
|
|
||||||
|
encode_uom = self.env.company.timesheet_encode_uom_id
|
||||||
|
uom_ratio = self.env.ref('uom.product_uom_hour').factor / encode_uom.factor
|
||||||
|
billable = self.billable_hours / uom_ratio
|
||||||
|
effective = self.total_timesheet_time / uom_ratio
|
||||||
|
|
||||||
|
color = ""
|
||||||
|
if billable:
|
||||||
|
number = f"{round(billable)} / {round(effective)} {encode_uom.name}"
|
||||||
|
billable_rate = round(100 * billable / effective)
|
||||||
|
if billable_rate < 50:
|
||||||
|
number = self.env._(
|
||||||
|
"%(billable)s / %(effective)s %(uom_name)s",
|
||||||
|
effective=round(effective),
|
||||||
|
billable=round(billable),
|
||||||
|
uom_name=encode_uom.name,
|
||||||
|
)
|
||||||
|
color = "text-danger"
|
||||||
|
else:
|
||||||
|
number = self.env._(
|
||||||
|
"%(billable)s / %(effective)s %(uom_name)s (%(billable_rate)s%%)",
|
||||||
|
effective=round(effective),
|
||||||
|
billable=round(billable),
|
||||||
|
uom_name=encode_uom.name,
|
||||||
|
billable_rate=billable_rate,
|
||||||
|
)
|
||||||
|
if billable_rate < 80:
|
||||||
|
color = "text-warning"
|
||||||
|
else:
|
||||||
|
color = "text-success"
|
||||||
|
else:
|
||||||
|
number = self.env._(
|
||||||
|
"%(billable)s %(uom_name)s",
|
||||||
|
billable=round(billable),
|
||||||
|
uom_name=encode_uom.name,
|
||||||
|
)
|
||||||
|
|
||||||
|
buttons.append({
|
||||||
|
"icon": f"money {color}",
|
||||||
|
"text": self.env._("Billable Time"),
|
||||||
|
"number": number,
|
||||||
|
"action_type": "object",
|
||||||
|
"action": "action_project_billable_timesheets",
|
||||||
|
"show": True,
|
||||||
|
"sequence": 3,
|
||||||
|
})
|
||||||
|
return buttons
|
||||||
Reference in New Issue
Block a user