2 Commits

Author SHA1 Message Date
Stéphan Sainléger
fb7ff241f5 [FIX] hr_expense_report_merge_attachment: handle HEIC images uploaded as JPEG
Some iPhone users upload HEIC files with a ``.jpg`` extension. Odoo stores
the file as-is, but the mimetype is detected as ``image/...``, so the code
enters the image processing branch. ``reportlab``'s ``ImageReader`` relies
on ``PIL.Image.open()`` which cannot identify HEIC files without an explicit
plugin, causing a ``PIL.UnidentifiedImageError`` and a 500 error on report
download.

Fix by:
- Registering the ``pillow-heif`` opener at module load time (optional
  dependency, silently ignored if not installed) so that Pillow can decode
  HEIC/HEIF images.
- Converting any image to JPEG in memory via Pillow before passing it to
  ``ImageReader``, bypassing ``reportlab``'s own format detection entirely.
- Wrapping the image block in a ``try/except`` to gracefully skip
  attachments that cannot be decoded, consistent with the existing PDF
  error handling.
2026-05-15 13:36:43 +02:00
87dd45a49f [MIG]allow_negative_leave_and_allocation:v14 2025-01-07 17:06:52 +01:00
147 changed files with 1874 additions and 4416 deletions

View File

@@ -1,20 +0,0 @@
# Configuration for known file extensions
[*.{css,js,json,less,md,py,rst,sass,scss,xml,yaml,yml}]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.{json,yml,yaml,rst,md}]
indent_size = 2
# Do not configure editor for libs and autogenerated content
[{*/static/{lib,src/lib}/**,*/static/description/index.html,*/readme/../README.rst}]
charset = unset
end_of_line = unset
indent_size = unset
indent_style = unset
insert_final_newline = false
trim_trailing_whitespace = false

View File

@@ -1,188 +0,0 @@
env:
browser: true
es6: true
# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
parserOptions:
ecmaVersion: 2019
overrides:
- files:
- "**/*.esm.js"
parserOptions:
sourceType: module
# Globals available in Odoo that shouldn't produce errorings
globals:
_: readonly
$: readonly
fuzzy: readonly
jQuery: readonly
moment: readonly
odoo: readonly
openerp: readonly
owl: readonly
luxon: readonly
# Styling is handled by Prettier, so we only need to enable AST rules;
# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890
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
valid-jsdoc:
- warn
- prefer:
arg: param
argument: param
augments: extends
constructor: class
exception: throws
func: function
method: function
prop: property
return: returns
virtual: abstract
yield: yields
preferType:
array: Array
bool: Boolean
boolean: Boolean
number: Number
object: Object
str: String
string: String
requireParamDescription: false
requireReturn: false
requireReturnDescription: false
requireReturnType: false
valid-typeof: warn
yoda: warn

View File

@@ -1,42 +0,0 @@
name: pre-commit
on:
pull_request:
branches:
- "16.0*"
jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Get python version
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
# - uses: actions/cache@v4
# with:
# path: ~/.cache/pre-commit
# key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure --color=always
env:
# Consider valid a PR that changes README fragments but doesn't
# change the README.rst file itself. It's not really a problem
# because the bot will update it anyway after merge. This way, we
# lower the barrier for functional contributors that want to fix the
# readme fragments, while still letting developers get README
# auto-generated (which also helps functionals when using runboat).
# DOCS https://pre-commit.com/#temporarily-disabling-hooks
SKIP: oca-gen-addon-readme
- name: Check that all files generated by pre-commit are in git
run: |
newfiles="$(git ls-files --others --exclude-from=.gitignore)"
if [ "$newfiles" != "" ] ; then
echo "Please check-in the following files:"
echo "$newfiles"
exit 1
fi

View File

@@ -1,150 +0,0 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
# END NOT INSTALLABLE ADDONS
# 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/|^eslint.config.cjs|^prettier.config.cjs|
# Maybe reactivate this when all README files include prettier ignore tags?
^README\.md$|
# Library files can have extraneous formatting (even minimized)
/static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying
^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:
python: python3
node: "16.17.0"
repos:
- repo: local
hooks:
# These files are most likely copier diff rejection junks; if found,
# review them manually, fix the problem (if needed) and remove them
- id: forbidden-files
name: forbidden files
entry: found forbidden files; remove them
language: fail
files: "\\.rej$"
- id: en-po-files
name: en.po files cannot exist
entry: found a en.po file
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: f9b919b9868143135a9c9cb03021089cabba8223
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
- id: oca-fix-manifest-website
entry:
bash -c 'oca-fix-manifest-website "https://git.elabore.coop/elabore/$(basename
$(git rev-parse --show-toplevel))"'
- id: oca-gen-addon-readme
entry:
bash -c 'oca-gen-addon-readme
--addons-dir=.
--branch=$(git symbolic-ref
refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@")
--repo-name=$(basename $(git rev-parse --show-toplevel))
--org-name="Elabore"
--if-source-changed --keep-source-digest'
- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.1.4
hooks:
- id: oca-checks-odoo-module
- id: oca-checks-po
args:
- --disable=po-pretty-format
- repo: local
hooks:
- id: prettier
name: prettier (with plugin-xml)
entry: prettier
args:
- --write
- --list-different
- --ignore-unknown
types: [text]
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
language: node
additional_dependencies:
- "prettier@2.7.1"
- "@prettier/plugin-xml@2.2.0"
- repo: local
hooks:
- id: eslint
name: eslint
entry: eslint
args:
- --color
- --fix
verbose: true
types: [javascript]
language: node
additional_dependencies:
- "eslint@8.24.0"
- "eslint-plugin-jsdoc@"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
# exclude autogenerated files
exclude: /README\.rst$|\.pot?$
- id: end-of-file-fixer
# exclude autogenerated files
exclude: /README\.rst$|\.pot?$
- id: debug-statements
- id: fix-encoding-pragma
args: ["--remove"]
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
# exclude files where underlines are not distinguishable from merge conflicts
exclude: /README\.rst$|^docs/.*\.rst$
- id: check-symlinks
- id: check-xml
- id: mixed-line-ending
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
rev: v0.12.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/OCA/pylint-odoo
rev: v9.1.3
hooks:
- id: pylint_odoo
name: pylint with optional checks
args:
- --rcfile=.pylintrc
- --exit-zero
verbose: true
- id: pylint_odoo
args:
- --rcfile=.pylintrc-mandatory

View File

@@ -1,8 +0,0 @@
# Defaults for all prettier-supported languages.
# Prettier will complete this with settings from .editorconfig file.
bracketSpacing: false
printWidth: 88
proseWrap: always
semi: true
trailingComma: "es5"
xmlWhitespaceSensitivity: "strict"

123
.pylintrc
View File

@@ -1,123 +0,0 @@
[MASTER]
load-plugins=pylint_odoo
score=n
[ODOOLINT]
readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest-required-authors=Elabore
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
valid-odoo-versions=16.0
[MESSAGES CONTROL]
disable=all
# This .pylintrc contains optional AND mandatory checks and is meant to be
# loaded in an IDE to have it check everything, in the hope this will make
# optional checks more visible to contributors who otherwise never look at a
# green travis to see optional checks that failed.
# .pylintrc-mandatory containing only mandatory checks is used the pre-commit
# config as a blocking check.
enable=anomalous-backslash-in-string,
api-one-deprecated,
api-one-multi-together,
assignment-from-none,
attribute-deprecated,
class-camelcase,
dangerous-default-value,
dangerous-view-replace-wo-priority,
development-status-allowed,
duplicate-id-csv,
duplicate-key,
duplicate-xml-fields,
duplicate-xml-record-id,
eval-referenced,
eval-used,
incoherent-interpreter-exec-perm,
license-allowed,
manifest-author-string,
manifest-deprecated-key,
manifest-required-author,
manifest-required-key,
manifest-version-format,
method-compute,
method-inverse,
method-required-super,
method-search,
openerp-exception-warning,
pointless-statement,
pointless-string-statement,
print-used,
redundant-keyword-arg,
redundant-modulename-xml,
reimported,
relative-import,
return-in-init,
rst-syntax-error,
sql-injection,
too-few-format-args,
translation-field,
translation-required,
unreachable,
use-vim-comment,
wrong-tabs-instead-of-spaces,
xml-syntax-error,
attribute-string-redundant,
character-not-valid-in-resource-link,
consider-merging-classes-inherited,
context-overridden,
create-user-wo-reset-password,
dangerous-filter-wo-user,
dangerous-qweb-replace-wo-priority,
deprecated-data-xml-node,
deprecated-openerp-xml-node,
duplicate-po-message-definition,
except-pass,
file-not-used,
invalid-commit,
manifest-maintainers-list,
missing-newline-extrafiles,
missing-readme,
missing-return,
odoo-addons-relative-import,
old-api7-method-defined,
po-msgstr-variables,
po-syntax-error,
renamed-field-parameter,
resource-not-exist,
str-format-used,
test-folder-imported,
translation-contains-variable,
translation-positional-used,
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
consider-merging-classes-inherited,
create-user-wo-reset-password,
dangerous-filter-wo-user,
deprecated-module,
file-not-used,
invalid-commit,
missing-manifest-dependency,
missing-newline-extrafiles,
missing-readme,
no-utf8-coding-comment,
odoo-addons-relative-import,
old-api7-method-defined,
redefined-builtin,
too-complex,
unnecessary-utf8-coding-comment
[REPORTS]
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no

View File

@@ -1,98 +0,0 @@
[MASTER]
load-plugins=pylint_odoo
score=n
[ODOOLINT]
readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest-required-authors=Elabore
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
valid-odoo-versions=16.0
[MESSAGES CONTROL]
disable=all
enable=anomalous-backslash-in-string,
api-one-deprecated,
api-one-multi-together,
assignment-from-none,
attribute-deprecated,
class-camelcase,
dangerous-default-value,
dangerous-view-replace-wo-priority,
development-status-allowed,
duplicate-id-csv,
duplicate-key,
duplicate-xml-fields,
duplicate-xml-record-id,
eval-referenced,
eval-used,
incoherent-interpreter-exec-perm,
license-allowed,
manifest-author-string,
manifest-deprecated-key,
manifest-required-author,
manifest-required-key,
manifest-version-format,
method-compute,
method-inverse,
method-required-super,
method-search,
openerp-exception-warning,
pointless-statement,
pointless-string-statement,
print-used,
redundant-keyword-arg,
redundant-modulename-xml,
reimported,
relative-import,
return-in-init,
rst-syntax-error,
sql-injection,
too-few-format-args,
translation-field,
translation-required,
unreachable,
use-vim-comment,
wrong-tabs-instead-of-spaces,
xml-syntax-error,
attribute-string-redundant,
character-not-valid-in-resource-link,
consider-merging-classes-inherited,
context-overridden,
create-user-wo-reset-password,
dangerous-filter-wo-user,
dangerous-qweb-replace-wo-priority,
deprecated-data-xml-node,
deprecated-openerp-xml-node,
duplicate-po-message-definition,
except-pass,
file-not-used,
invalid-commit,
manifest-maintainers-list,
missing-newline-extrafiles,
missing-readme,
missing-return,
odoo-addons-relative-import,
old-api7-method-defined,
po-msgstr-variables,
po-syntax-error,
renamed-field-parameter,
resource-not-exist,
str-format-used,
test-folder-imported,
translation-contains-variable,
translation-positional-used,
unnecessary-utf8-coding-comment,
website-manifest-key-not-valid-uri,
xml-attribute-translatable,
xml-deprecated-qweb-directive,
xml-deprecated-tree-attribute,
external-request-timeout
[REPORTS]
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no

View File

@@ -1,31 +0,0 @@
target-version = "py310"
fix = true
[lint]
extend-select = [
"B",
"C90",
"E501", # line too long (default 88)
"I", # isort
"UP", # pyupgrade
]
extend-safe-fixes = ["UP008"]
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

View File

@@ -2,7 +2,7 @@
allow_negative_leave_and_allocation allow_negative_leave_and_allocation
=================================== ===================================
allow negative leaves, manage negative leave balances and negative allocations allow negative leaves and allocations
Installation Installation
============ ============
@@ -18,7 +18,7 @@ None yet.
Bug Tracker Bug Tracker
=========== ===========
Bugs are tracked on `our issues website <https://git.elabore.coop/Elabore/hr-tools/issues>`_. In case of Bugs are tracked on `our issues website <https://github.com/elabore-coop/allow_negative_leave_and_allocation/issues>`_. In case of
trouble, please check there if your issue has already been trouble, please check there if your issue has already been
reported. If you spotted it first, help us smashing it by providing a reported. If you spotted it first, help us smashing it by providing a
detailed and welcomed feedback. detailed and welcomed feedback.
@@ -29,7 +29,7 @@ Credits
Contributors Contributors
------------ ------------
* `Elabore <mailto:contact@elabore.coop>` * `Elabore <mailto:laetitia.dacosta@elabore.coop>`
Funders Funders
------- -------

View File

@@ -2,14 +2,14 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "hr_negative_leave", "name": "allow_negative_leave_and_allocation",
"version": "16.0.3.0.1", "version": "14.0.1.0.0",
"author": "Elabore", "author": "Elabore",
"website": "https://elabore.coop", "website": "https://elabore.coop",
"maintainer": "Elabore", "maintainer": "Elabore",
"license": "AGPL-3", "license": "AGPL-3",
"category": "hr", "category": "hr",
"summary": "allow negative leaves, manage negative leave balances and negative allocations", "summary": "allow negative leaves and allocations",
# any module necessary for this one to work correctly # any module necessary for this one to work correctly
"depends": [ "depends": [
"base","hr_holidays", "base","hr_holidays",

View File

@@ -0,0 +1,60 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * allow_negative_leave_and_allocation
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-02 12:11+0000\n"
"PO-Revision-Date: 2025-01-02 12:11+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: allow_negative_leave_and_allocation
#: model:ir.model.fields,field_description:allow_negative_leave_and_allocation.field_hr_leave_type__allows_negative
msgid "Allow Negative Leaves"
msgstr ""
#. module: allow_negative_leave_and_allocation
#: model_terms:ir.ui.view,arch_db:allow_negative_leave_and_allocation.hr_leave_type_negative_leave
msgid "Allow negative"
msgstr ""
#. module: allow_negative_leave_and_allocation
#: model:ir.model.fields,help:allow_negative_leave_and_allocation.field_hr_leave_type__allows_negative
msgid ""
"If checked, users request can exceed the allocated days and balance can go "
"in negative."
msgstr ""
#. module: allow_negative_leave_and_allocation
#: model:ir.model.constraint,message:allow_negative_leave_and_allocation.constraint_hr_leave_allocation_duration_check
msgid "The duration must be greater than 0."
msgstr ""
#. module: allow_negative_leave_and_allocation
#: model:ir.model.constraint,message:allow_negative_leave_and_allocation.constraint_hr_leave_allocation_type_value
msgid ""
"The employee, department, company or employee category of this request is "
"missing. Please make sure that your user login is linked to an employee."
msgstr ""
#. module: allow_negative_leave_and_allocation
#: model:ir.model,name:allow_negative_leave_and_allocation.model_hr_leave
msgid "Time Off"
msgstr ""
#. module: allow_negative_leave_and_allocation
#: model:ir.model,name:allow_negative_leave_and_allocation.model_hr_leave_allocation
msgid "Time Off Allocation"
msgstr ""
#. module: allow_negative_leave_and_allocation
#: model:ir.model,name:allow_negative_leave_and_allocation.model_hr_leave_type
msgid "Time Off Type"
msgstr ""

View File

@@ -0,0 +1,60 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * allow_negative_leave_and_allocation
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-02 12:11+0000\n"
"PO-Revision-Date: 2025-01-02 12:11+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: allow_negative_leave_and_allocation
#: model:ir.model.fields,field_description:allow_negative_leave_and_allocation.field_hr_leave_type__allows_negative
msgid "Allow Negative Leaves"
msgstr "Autoriser les congés négatifs"
#. module: allow_negative_leave_and_allocation
#: model_terms:ir.ui.view,arch_db:allow_negative_leave_and_allocation.hr_leave_type_negative_leave
msgid "Allow negative"
msgstr "Autoriser les congés négatifs"
#. module: allow_negative_leave_and_allocation
#: model:ir.model.fields,help:allow_negative_leave_and_allocation.field_hr_leave_type__allows_negative
msgid ""
"If checked, users request can exceed the allocated days and balance can go "
"in negative."
msgstr ""
#. module: allow_negative_leave_and_allocation
#: model:ir.model.constraint,message:allow_negative_leave_and_allocation.constraint_hr_leave_allocation_duration_check
msgid "The duration must be greater than 0."
msgstr ""
#. module: allow_negative_leave_and_allocation
#: model:ir.model.constraint,message:allow_negative_leave_and_allocation.constraint_hr_leave_allocation_type_value
msgid ""
"The employee, department, company or employee category of this request is "
"missing. Please make sure that your user login is linked to an employee."
msgstr ""
#. module: allow_negative_leave_and_allocation
#: model:ir.model,name:allow_negative_leave_and_allocation.model_hr_leave
msgid "Time Off"
msgstr "Congés"
#. module: allow_negative_leave_and_allocation
#: model:ir.model,name:allow_negative_leave_and_allocation.model_hr_leave_allocation
msgid "Time Off Allocation"
msgstr "Allocation de congés"
#. module: allow_negative_leave_and_allocation
#: model:ir.model,name:allow_negative_leave_and_allocation.model_hr_leave_type
msgid "Time Off Type"
msgstr "Type de congés"

View File

@@ -0,0 +1 @@
from . import hr_leave_type, hr_leave, hr_leave_allocation

View File

@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# Copyright (c) 2005-2006 Axelor SARL. (http://www.axelor.com)
from odoo import api, models
class HrLeave(models.Model):
_inherit = "hr.leave"
@api.constrains("state", "number_of_days", "holiday_status_id")
def _check_holidays(self):
for holiday in self:
if holiday.holiday_status_id.allows_negative:
continue
super()._check_holidays()

View File

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# Copyright (c) 2005-2006 Axelor SARL. (http://www.axelor.com)
from odoo import models
class HrLeaveAllocation(models.Model):
_inherit = "hr.leave.allocation"
_sql_constraints = [
('type_value',
"CHECK( (holiday_type='employee' AND (employee_id IS NOT NULL OR multi_employee IS TRUE)) or "
"(holiday_type='category' AND category_id IS NOT NULL) or "
"(holiday_type='department' AND department_id IS NOT NULL) or "
"(holiday_type='company' AND mode_company_id IS NOT NULL))",
"The employee, department, company or employee category of this request is missing. Please make sure that your user login is linked to an employee."),
('duration_check', "CHECK((allocation_type != 'regular'))", "The duration must be greater than 0."),
]

View File

@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class HolidaysType(models.Model):
_inherit = "hr.leave.type"
# negative time off
allows_negative = fields.Boolean(string='Allow Negative Leaves',
help="If checked, users request can exceed the allocated days and balance can go in negative.")
@api.depends('validity_start', 'validity_stop')
def _compute_valid(self):
res = super()._compute_valid()
for holiday_type in res:
if not holiday_type.valid:
holiday_type.valid = holiday_type.allows_negative

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_leave_type_negative_leave" model="ir.ui.view">
<field name="name">hr.leave.type.negative.leave</field>
<field name="model">hr.leave.type</field>
<field name="inherit_id" ref="hr_holidays.edit_holiday_status_form" />
<field name="arch" type="xml">
<field name='request_unit' position="after">
<field name="allows_negative" />
</field>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,26 @@
<odoo>
<record id="hr_leave_view_negative_leave" model="ir.ui.view">
<field name="name">hr.leave.view.negative.leave</field>
<field name="model">hr.leave</field>
<field name="inherit_id" ref="hr_holidays.hr_leave_view_form" />
<field name="arch" type="xml">
<field name='holiday_status_id' position="attributes">
<attribute name="domain">
[
'|',
('allows_negative', '=', True),
'&amp;',
('allows_negative', '=', False),
'&amp;',
('virtual_remaining_leaves', '>', 0),
'|',
('allocation_type', 'in', ['fixed_allocation', 'no']),
'&amp;',
('allocation_type', '=', 'fixed'),
('max_leaves', '>', '0')
]
</attribute>
</field>
</field>
</record>
</odoo>

View File

@@ -1,25 +1,23 @@
=================================== ==============================
timesheet_timesheet_analysis_report hr_effective_attendance_period
=================================== ==============================
add a timesheet_id relation many2one to timesheet.analysis.report model Provide indication that attendance are effectively worked periods or not
in order to allow filter by timesheet
Installation Installation
============ ============
Use Odoo normal module installation procedure to install Use Odoo normal module installation procedure to install
``timesheet_timesheet_analysis_report``. ``hr_effective_attendance_period``.
Known issues / Roadmap Known issues / Roadmap
====================== ======================
None yet. None yet.
Bug Tracker Bug Tracker
=========== ===========
Bugs are tracked on `our issues website <https://github.com/elabore-coop/timesheet_timesheet_analysis_report/issues>`_. In case of Bugs are tracked on `our issues website <https://github.com/elabore-coop/hr-tools/issues>`_. In case of
trouble, please check there if your issue has already been trouble, please check there if your issue has already been
reported. If you spotted it first, help us smashing it by providing a reported. If you spotted it first, help us smashing it by providing a
detailed and welcomed feedback. detailed and welcomed feedback.
@@ -30,7 +28,7 @@ Credits
Contributors Contributors
------------ ------------
* `Elabore <mailto:laetitia.dacosta@elabore.coop>` * Stéphan Sainléger
Funders Funders
------- -------
@@ -42,4 +40,4 @@ The development of this module has been financially supported by:
Maintainer Maintainer
---------- ----------
This module is maintained by Elabore. This module is maintained by Elabore.

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -0,0 +1,37 @@
# Copyright 2023 Stéphan Sainléger (Elabore)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "hr_effective_attendance_period",
"version": "14.0.2.0.1",
"author": "Elabore",
"website": "https://elabore.coop",
"maintainer": "Stéphan Sainléger",
"license": "AGPL-3",
"category": "Tools",
"summary": "Provide indication that attendance are effectively worked periods or not",
# any module necessary for this one to work correctly
"depends": [
"base",
"resource",
],
"qweb": [
# "static/src/xml/*.xml",
],
"external_dependencies": {
"python": [],
},
# always loaded
"data": [
"views/resource_views.xml",
],
# 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,
}

View File

@@ -0,0 +1 @@
This directory should contain the *.po for Odoo translation.

View File

@@ -0,0 +1,49 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_effective_attendance_period
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-01-24 21:50+0000\n"
"PO-Revision-Date: 2023-01-24 21:50+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: hr_effective_attendance_period
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar__display_name
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar_attendance__display_name
msgid "Display Name"
msgstr "Nom affiché"
#. module: hr_effective_attendance_period
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar_attendance__effective_attendance_period
msgid "Effective Attendance Period"
msgstr "Présence effective"
#. module: hr_effective_attendance_period
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar__id
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar_attendance__id
msgid "ID"
msgstr ""
#. module: hr_effective_attendance_period
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar____last_update
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar_attendance____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"
#. module: hr_effective_attendance_period
#: model:ir.model,name:hr_effective_attendance_period.model_resource_calendar
msgid "Resource Working Time"
msgstr "Temps de travail de la ressource"
#. module: hr_effective_attendance_period
#: model:ir.model,name:hr_effective_attendance_period.model_resource_calendar_attendance
msgid "Work Detail"
msgstr "Détail du travail"

View File

@@ -0,0 +1,49 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_effective_attendance_period
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-01-24 21:49+0000\n"
"PO-Revision-Date: 2023-01-24 21:49+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: hr_effective_attendance_period
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar__display_name
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar_attendance__display_name
msgid "Display Name"
msgstr ""
#. module: hr_effective_attendance_period
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar_attendance__effective_attendance_period
msgid "Effective Attendance Period"
msgstr ""
#. module: hr_effective_attendance_period
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar__id
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar_attendance__id
msgid "ID"
msgstr ""
#. module: hr_effective_attendance_period
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar____last_update
#: model:ir.model.fields,field_description:hr_effective_attendance_period.field_resource_calendar_attendance____last_update
msgid "Last Modified on"
msgstr ""
#. module: hr_effective_attendance_period
#: model:ir.model,name:hr_effective_attendance_period.model_resource_calendar
msgid "Resource Working Time"
msgstr ""
#. module: hr_effective_attendance_period
#: model:ir.model,name:hr_effective_attendance_period.model_resource_calendar_attendance
msgid "Work Detail"
msgstr ""

View File

@@ -0,0 +1 @@
from . import resource

View File

@@ -0,0 +1,84 @@
import math
import pytz
from datetime import datetime, timedelta
from pytz import timezone
from odoo import models, fields
class ResourceCalendarAttendance(models.Model):
_inherit = "resource.calendar.attendance"
effective_attendance_period = fields.Boolean('Effective Attendance Period', store=True)
class ResourceCalendar(models.Model):
_inherit = "resource.calendar"
def _retrieve_day_matching_attendances(self, day):
domain = [
("calendar_id", "=", self.id),
("dayofweek", "=", day.weekday()),
("effective_attendance_period", "=", True)
]
if self.two_weeks_calendar:
# Employee has Even/Odd weekly calendar
week_type = 1 if int(math.floor((day.toordinal() - 1) / 7) % 2) else 0
domain.append(("week_type", "=", week_type))
result = self.env["resource.calendar.attendance"].search(domain)
return result
def is_working_day(self, day):
day_attendances = self._retrieve_day_matching_attendances(day)
if len(day_attendances) == 0:
# This day of the week is not supposed to be a working day
return False
else:
# This day of the week is supposed to be a working day
return True
def is_full_working_day(self, day):
day_attendances = self._retrieve_day_matching_attendances(day)
morning_worked = len(day_attendances.filtered(lambda x: x.day_period == "morning")) > 0
afternoon_worked = len(day_attendances.filtered(lambda x: x.day_period == "afternoon")) > 0
return morning_worked and afternoon_worked
def _compute_datetime_in_utc_tz(self, date):
user_tz = pytz.timezone(self.env.context.get('tz', 'utc') or 'utc')
return user_tz.localize(date).astimezone(pytz.utc)
def _is_worked_attendance(self, resource, day, attendance):
attendance_start = fields.Datetime.to_datetime(day.date()) + timedelta(hours=attendance.hour_from)
attendance_end = fields.Datetime.to_datetime(day.date()) + timedelta(hours=attendance.hour_to)
utc_start = self._compute_datetime_in_utc_tz(attendance_start)
utc_end = self._compute_datetime_in_utc_tz(attendance_end)
resource_leaves = self.env["resource.calendar.leaves"].sudo().search(
[
("company_id", "=", resource.company_id.id),
("date_from", "<=", utc_start),
("date_to", ">=", utc_end),
"|",
("resource_id", "=", resource.id),
("resource_id", "=", None),
]
)
if resource_leaves:
return False
else:
# a part or the whole attendance is worked
return True
def is_worked_day(self, resource, day):
day_attendances = self._retrieve_day_matching_attendances(day)
# If at least one attendance is worked, return True
for attendance in day_attendances:
if self._is_worked_attendance(resource, day, attendance):
return True
return False
def all_attendances_worked(self, resource, day):
day_attendances = self._retrieve_day_matching_attendances(day)
# If at least one attendance is not worked, return False
for attendance in day_attendances:
if not self._is_worked_attendance(resource, day, attendance):
return False
return True

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_resource_calendar_attendance_tree_inherit_effective_attendance"
model="ir.ui.view">
<field name="name">resource.calendar.attendance.view.tree.inherit</field>
<field name="model">resource.calendar.attendance</field>
<field name="inherit_id" ref="resource.view_resource_calendar_attendance_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='week_type']" position="after">
<field name="effective_attendance_period" />
</xpath>
</field>
</record>
<record id="view_resource_calendar_attendance_form_inherit_effective_attendance"
model="ir.ui.view">
<field name="name">resource.calendar.attendance.view.tree.inherit</field>
<field name="model">resource.calendar.attendance</field>
<field name="inherit_id" ref="resource.view_resource_calendar_attendance_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='day_period']" position="after">
<field name="effective_attendance_period" />
</xpath>
</field>
</record>
</odoo>

View File

@@ -1,55 +0,0 @@
=======================
hr_employee_stats_sheet
=======================
Summary
=======
Add global sheet for employee stats
Description
===========
This module add a global sheet stats in timesheet sheet
It compare planified working hours (from calendar ressouce) and worked hours form timesheets
Installation
============
Use Odoo normal module installation procedure to install
``hr_employee_stats_sheet``.
Known issues / Roadmap
======================
None yet.
Bug Tracker
===========
Bugs are tracked on `our issues website <https://git.elabore.coop/Elabore/hr-tools/issues>`_. In case of
trouble, please check there if your issue has already been
reported. If you spotted it first, help us smashing it by providing a
detailed and welcomed feedback.
Credits
=======
Contributors
------------
* `Alusage : Nicolas JEUDY`
* `Elabore <mailto:contact@elabore.coop>`
Funders
-------
The development of this module has been financially supported by:
* Alusage (https://github.com/Alusage)
* Elabore (https://elabore.coop)
Maintainer
----------
This module is maintained by Elabore.

View File

@@ -1,29 +0,0 @@
{
"name": "hr_employee_stats_sheet",
"version": "16.0.3.2.0",
"description": "Add global sheet for employee stats",
"summary": "Add global sheet for employee stats",
"author": "Nicolas JEUDY",
"website": "https://github.com/Alusage/odoo-hr-addons",
"license": "LGPL-3",
"category": "Human Resources",
"depends": [
"hr_negative_leave",
"base",
"hr",
"hr_holidays",
"hr_timesheet",
"hr_timesheet_sheet",
"resource",
"hr_employee_calendar_planning",
"hr_timesheet_sheet_usability_misc",
],
"data": [
"security/ir.model.access.csv",
"views/hr_employee_stats.xml",
"views/hr_timesheet_sheet.xml",
"views/res_config_settings_views.xml",
],
"installable": True,
"application": False,
}

View File

@@ -1,446 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_employee_stats_sheet
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-06-19 14:31+0000\n"
"PO-Revision-Date: 2025-06-19 14:31+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: hr_employee_stats_sheet
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.res_config_settings_view_form
msgid ""
"<span class=\"fa fa-lg fa-building\" title=\"Values set here are company-"
"specific.\" aria-label=\"Values set here are company-specific.\" "
"groups=\"base.group_multi_company\" role=\"img\"/>"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__message_needaction
msgid "Action Needed"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__activity_ids
msgid "Activities"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__activity_exception_decoration
msgid "Activity Exception Decoration"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__activity_state
msgid "Activity State"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__activity_type_icon
msgid "Activity Type Icon"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__message_attachment_count
msgid "Attachment Count"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_res_company__auto_validate_recovery_allocation
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_res_config_settings__auto_validate_recovery_allocation
msgid "Auto validate recovery allocation"
msgstr "Auto-validation des allocations de récupération"
#. module: hr_employee_stats_sheet
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.res_config_settings_view_form
msgid "Choose the coef to apply to recovery hours."
msgstr "Indiquer le coefficient multiplicateur à appliquer sur les heures supplémentaires (en %) pour générer les heures de récupération. Par défaut : 25,00%"
#. module: hr_employee_stats_sheet
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.res_config_settings_view_form
msgid "Choose the recovery type."
msgstr ""
"Sélectionner le type de congé utilisé pour générer des allocations de "
"récupération. Le type de congé doit accepter les allocations négatives et être pris à l'heure."
#. module: hr_employee_stats_sheet
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.res_config_settings_view_form
msgid "Choose to auto-validate the recovery allocation or not"
msgstr "Validation automatique des allocations de récupération"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_res_company__coef
msgid "Coef"
msgstr "Coefficient"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_res_config_settings__coef
msgid "Coef (in %)"
msgstr "Coefficient (en %)"
#. module: hr_employee_stats_sheet
#: model:ir.model,name:hr_employee_stats_sheet.model_res_company
msgid "Companies"
msgstr "Sociétés"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__company_id
msgid "Company"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model,name:hr_employee_stats_sheet.model_res_config_settings
msgid "Config Settings"
msgstr "Paramètres de configuration"
#. module: hr_employee_stats_sheet
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.view_hr_timesheet_sheet_form_inherit
msgid "Create recovery allocation"
msgstr "Générer une récupération"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__create_uid
msgid "Created by"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__create_date
msgid "Created on"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__date
msgid "Date"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__dayofweek
msgid "Day of Week"
msgstr "Jour de la semaine"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__department_id
msgid "Department"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__display_name
msgid "Display Name"
msgstr ""
#. module: hr_employee_stats_sheet
#. odoo-python
#: code:addons/hr_employee_stats_sheet/models/hr_timesheet_sheet.py:0
#, python-format
msgid ""
"Employe not defined for the timesheet sheet or recovery type not defined in "
"settings"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__employee_id
msgid "Employee"
msgstr "Employé·e"
#. module: hr_employee_stats_sheet
#: model:ir.model,name:hr_employee_stats_sheet.model_hr_employee_stats
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_timesheet_sheet__employee_stats_ids
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.view_hr_timesheet_sheet_form_inherit
msgid "Employee Stats"
msgstr "Statistique des employé·e·s"
#. module: hr_employee_stats_sheet
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.hr_timesheet_sheet_stats_overview_pivot_view
msgid "Employee time stats pivot"
msgstr "Statistique de l'employé·e"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__failed_message_ids
msgid "Failed Messages"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__message_follower_ids
msgid "Followers"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__message_partner_ids
msgid "Followers (Partners)"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,help:hr_employee_stats_sheet.field_hr_employee_stats__activity_type_icon
msgid "Font awesome icon e.g. fa-tasks"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__gap_hours
msgid "Gap Hours"
msgstr "Heures d'écart"
#. module: hr_employee_stats_sheet
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.view_hr_timesheet_sheet_form_inherit
msgid "Generated recovery allocations"
msgstr "Allocation(s) de récupération générée(s)"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__has_message
msgid "Has Message"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__id
msgid "ID"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__activity_exception_icon
msgid "Icon"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,help:hr_employee_stats_sheet.field_hr_employee_stats__activity_exception_icon
msgid "Icon to indicate an exception activity."
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,help:hr_employee_stats_sheet.field_hr_employee_stats__message_needaction
msgid "If checked, new messages require your attention."
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,help:hr_employee_stats_sheet.field_hr_employee_stats__message_has_error
msgid "If checked, some messages have a delivery error."
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__message_is_follower
msgid "Is Follower"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats____last_update
msgid "Last Modified on"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__write_uid
msgid "Last Updated by"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__write_date
msgid "Last Updated on"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_res_company__recovery_type_id
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_res_config_settings__recovery_type_id
msgid "Leave recovery type"
msgstr "Type de congé pour les récupérations"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__message_main_attachment_id
msgid "Main Attachment"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__message_has_error
msgid "Message Delivery error"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__message_ids
msgid "Messages"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__my_activity_date_deadline
msgid "My Activity Deadline"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__name
msgid "Name"
msgstr "Nom"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__activity_calendar_event_id
msgid "Next Activity Calendar Event"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__activity_date_deadline
msgid "Next Activity Deadline"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__activity_summary
msgid "Next Activity Summary"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__activity_type_id
msgid "Next Activity Type"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__message_needaction_counter
msgid "Number of Actions"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__message_has_error_counter
msgid "Number of errors"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,help:hr_employee_stats_sheet.field_hr_employee_stats__message_needaction_counter
msgid "Number of messages requiring action"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,help:hr_employee_stats_sheet.field_hr_employee_stats__message_has_error_counter
msgid "Number of messages with delivery error"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__is_public_holiday
msgid "Public Holiday"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_timesheet_sheet__recovery_allocation_ids
msgid "Recovery Allocations"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__activity_user_id
msgid "Responsible User"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,help:hr_employee_stats_sheet.field_hr_employee_stats__activity_state
msgid ""
"Status based on activities\n"
"Overdue: Due date is already passed\n"
"Today: Activity date is today\n"
"Planned: Future activities."
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,help:hr_employee_stats_sheet.field_res_config_settings__coef
msgid ""
"The coef is applied to recovery hoursExample : an employe make 1h overtime, "
"if coef is set to 25%, the recovery hours allocated will be 1,25h"
msgstr ""
#. module: hr_employee_stats_sheet
#. odoo-python
#: code:addons/hr_employee_stats_sheet/models/hr_timesheet_sheet.py:0
#, python-format
msgid ""
"The number of recovery hours exceeds the authorized limit (%s h) by %s hours"
msgstr ""
#. module: hr_employee_stats_sheet
#. odoo-python
#: code:addons/hr_employee_stats_sheet/models/hr_timesheet_sheet.py:0
#, python-format
msgid ""
"There is a contract starting during the timesheet sheet time period for the "
"employee %sPlease create a new timesheet sheet starting from the new "
"contract start date"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model,name:hr_employee_stats_sheet.model_hr_leave_allocation
msgid "Time Off Allocation"
msgstr "Allocation de congés"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__sheet_id
msgid "Timesheet"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model,name:hr_employee_stats_sheet.model_hr_timesheet_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_leave_allocation__timesheet_sheet_id
msgid "Timesheet Sheet"
msgstr "Feuille de temps"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__timesheet_line_ids
msgid "Timesheet lines"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_timesheet_sheet__timesheet_sheet_gap_hours
msgid "Timesheet sheet gap hours"
msgstr "Heures d'écart sur la période de la feuille de temps"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_timesheet_sheet__timesheet_sheet_recovery_hours
msgid "Timesheet sheet recovery hours"
msgstr "Heures de récupération sur la période de la feuille de temps"
#. module: hr_employee_stats_sheet
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.view_hr_employee_stats_tree
msgid "Total"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__total_hours
msgid "Total Hours"
msgstr "Heures comptabilisées"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__total_leave_hours
msgid "Total Leave Hours"
msgstr "Heures de congés"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__total_planned_hours
msgid "Total Planning Hours"
msgstr "Heures planifiées"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__total_recovery_hours
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_timesheet_sheet__total_recovery_hours
msgid "Total Recovery Hours"
msgstr "Heures de récupération"
#. module: hr_employee_stats_sheet
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.view_hr_timesheet_sheet_form_inherit
msgid "Total gap hours in this timesheet sheet time range"
msgstr "Total heures d'écart sur cette période de temps"
#. module: hr_employee_stats_sheet
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet.view_hr_timesheet_sheet_form_inherit
msgid "Total recovery hours in this timesheet sheet time range"
msgstr ""
"Total heures de repos compensateur accumulé sur cette période de temps"
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,help:hr_employee_stats_sheet.field_hr_employee_stats__activity_exception_decoration
msgid "Type of the exception activity on record."
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,field_description:hr_employee_stats_sheet.field_hr_employee_stats__website_message_ids
msgid "Website Messages"
msgstr ""
#. module: hr_employee_stats_sheet
#: model:ir.model.fields,help:hr_employee_stats_sheet.field_hr_employee_stats__website_message_ids
msgid "Website communication history"
msgstr ""

View File

@@ -1,6 +0,0 @@
from . import hr_employee_stats
from . import hr_timesheet_sheet
from . import res_config
from . import res_company
from . import hr_leave_allocation
from . import hr_employee

View File

@@ -1,38 +0,0 @@
import pytz
from odoo import models, _
from datetime import timedelta
from pytz import utc
from odoo.exceptions import UserError
class HrEmployee(models.Model):
_inherit = "hr.employee"
def _get_calendar_in_progress_during_a_time_period(self, date_start, date_end):
"""
get the ressource calendar which was used during the timesheet sheet time period
"""
self.ensure_one()
# find calendar(s) running over the duration of the timesheet
calendars = self.env["hr.employee.calendar"].search(
[
("employee_id", "=", self.id),
("date_start", "<=", date_end),
"|",
("date_end", "=", False), # pas de date de fin OU
("date_end", ">=", date_start), # date de fin après le début
],
)
if len(calendars) > 1:
raise UserError(
_("There is a calendar starting during the timesheet sheet time period for the employee %s "
"Please create a new timesheet sheet starting from the new calendar start date")
% self.display_name
)
# if hr_employee_calendar found, use its calendar_id
elif calendars and calendars[0].calendar_id:
return calendars[0].calendar_id
# if resource calendar not found, use the ressource calendar of the company linked to the employee
elif self.company_id.resource_calendar_id:
return self.company_id.resource_calendar_id
return None

View File

@@ -1,239 +0,0 @@
import logging
import pytz
from odoo import api, fields, models, _
from datetime import timedelta
from pytz import utc
from odoo.exceptions import UserError
class HrEmployeeStats(models.Model):
_name = "hr.employee.stats"
_description = "Employee Stats"
_order = "date desc"
_inherit = ["mail.thread", "mail.activity.mixin"]
name = fields.Char("Name", compute="_compute_name", store=True)
dayofweek = fields.Integer("Day of Week", compute="_compute_dayofweek")
is_public_holiday = fields.Boolean("Public Holiday", compute="_compute_dayofweek")
employee_id = fields.Many2one("hr.employee", "Employee", required=True)
department_id = fields.Many2one("hr.department", "Department")
timesheet_line_ids = fields.Many2many(
"account.analytic.line",
compute="_compute_timesheet_line_ids",
string="Timesheet lines",
)
date = fields.Date("Date", required=True)
company_id = fields.Many2one(
"res.company",
"Company",
default=lambda self: self.env.company,
required=True,
)
sheet_id = fields.Many2one("hr_timesheet.sheet", "Timesheet")
total_hours = fields.Float("Total Hours", compute="_compute_hours")
total_planned_hours = fields.Float("Total Planning Hours", compute="_compute_hours")
total_leave_hours = fields.Float("Total Leave Hours", compute="_compute_hours")
total_recovery_hours = fields.Float(
"Total Recovery Hours", compute="_compute_hours"
)
gap_hours = fields.Float("Gap Hours", compute="_compute_hours")
def _get_holiday_status_id(self):
recovery_type_id = self.env.company.recovery_type_id
if recovery_type_id:
return recovery_type_id.id
else:
return False
def _compute_timesheet_line_ids(self):
for stat in self:
stat.timesheet_line_ids = self.env["account.analytic.line"].search(
[
("employee_id", "=", stat.employee_id.id),
("date", "=", stat.date),
]
)
def _get_intersects(
self, datetime1_start, datetime1_end, datetime2_start, datetime2_end
):
latest_start = max(datetime1_start, datetime2_start)
earliest_end = min(datetime1_end, datetime2_end)
delta = (earliest_end - latest_start).total_seconds() / 3600
return max(0, delta)
def get_total_hours_domain(self):
return [
("employee_id", "=", self.employee_id.id),
("date", "=", self.date),
]
@api.depends("timesheet_line_ids")
def _get_total_hours(self):
self.ensure_one()
total_hours = 0
timesheet_line = self.env["account.analytic.line"]
if self.date and self.employee_id:
timesheet_line_ids = timesheet_line.search(
self.get_total_hours_domain()
)
total_hours = sum(timesheet_line_ids.mapped("unit_amount"))
return total_hours
def _get_total_planned_hours(self):
self.ensure_one()
total_planned_hours = 0
if self.employee_id and self.date and not self.is_public_holiday:
dayofweek = int(self.date.strftime("%u")) - 1
calendar_id = self.employee_id._get_calendar_in_progress_during_a_time_period(self.date,self.date)
week_number = self.date.isocalendar()[1] % 2
if calendar_id.two_weeks_calendar:
hours = calendar_id.attendance_ids.search(
[
("dayofweek", "=", dayofweek),
("calendar_id", "=", calendar_id.id),
("week_type", "=", week_number),
]
)
else:
hours = calendar_id.attendance_ids.search(
[
("dayofweek", "=", dayofweek),
("calendar_id", "=", calendar_id.id),
]
)
total_planned_hours = sum(
hours.mapped(lambda r: r.hour_to - r.hour_from)
)
return total_planned_hours
def _get_total_recovery_hours(self):
self.ensure_one()
recovery = self.env["hr.leave"]
total_recovery_hours = 0
if self.date and self.employee_id and self._get_holiday_status_id():
recovery_ids = recovery.search(
[
("employee_id", "=", self.employee_id.id),
("holiday_status_id", "=", self._get_holiday_status_id()),
("request_date_from", "<=", self.date),
("request_date_to", ">=", self.date),
],
)
if recovery_ids:
for recovery_id in recovery_ids:
if recovery_id.request_unit_hours:
recovery_hours = recovery_id.number_of_hours_display
total_recovery_hours += min(recovery_hours,self._get_total_planned_hours())
elif recovery_id.request_unit_half:
total_recovery_hours += self._get_total_planned_hours() / 2
else :
total_recovery_hours += self._get_total_planned_hours()
return total_recovery_hours
def _get_total_leave_hours(self):
self.ensure_one()
leave = self.env["hr.leave"]
total_leave_hours = 0
if self.date and self.employee_id:
leave_ids = leave.search(
[
("employee_id", "=", self.employee_id.id),
("holiday_status_id", "!=", self._get_holiday_status_id()),
("request_date_from", "<=", self.date),
("request_date_to", ">=", self.date),
("state", '=', 'validate'),
("active", '=', True),
],
)
if leave_ids:
for leave_id in leave_ids:
if leave_id.request_unit_hours:
leave_hours = leave_id.number_of_hours_display
total_leave_hours += min(leave_hours,self._get_total_planned_hours())
elif leave_id.request_unit_half:
total_leave_hours += self._get_total_planned_hours() / 2
else :
total_leave_hours += self._get_total_planned_hours()
return total_leave_hours
@api.depends("employee_id", "date")
def _compute_name(self):
for stat in self:
stat.name = "%s - %s" % (stat.employee_id.name, stat.date)
@api.depends("date","employee_id")
def _compute_dayofweek(self):
for stat in self:
if not stat.date:
stat.dayofweek = None
stat.is_public_holiday = False
continue
stat.dayofweek = int(stat.date.strftime("%u")) - 1
stat.is_public_holiday = stat._is_public_holiday_accordig_to_employe_tz()
def _convert_to_employee_tz(self, date):
"""Convert a UTC datetime to the employee's timezone datetime."""
self.ensure_one()
if not date:
return None
employee_tz = pytz.timezone(self.employee_id.tz or "UTC")
if date.tzinfo is None:
dt = pytz.utc.localize(date)
return dt.astimezone(employee_tz)
def _is_public_holiday_accordig_to_employe_tz(self):
self.ensure_one()
if not self.date or not self.employee_id:
return False
#get public holidays for the employee
public_holidays = self.employee_id._get_public_holidays(
self.date, self.date
)
if not public_holidays:
return False
if len(public_holidays) > 1:
raise UserError(
_("Several holidays have been found ont he date '%s'. Please correct the anomaly before continuing.") % self.date
)
ph = public_holidays[0]
# Convert public holiday to the employee timezone
ph_datetime_from_tz = self._convert_to_employee_tz(ph.date_from)
ph_datetime_to_tz = self._convert_to_employee_tz(ph.date_to)
# Convert datetime to date
ph_date_from = ph_datetime_from_tz.date()
ph_date_to = ph_datetime_to_tz.date()
# Check if the stat date falls within the public holiday range after conversion in employee tz
if ph_date_from <= self.date <= ph_date_to:
return True
else:
return False
def _get_gap_hours(self, total_hours, total_recovery_hours, total_leave_hours, total_planned_hours):
self.ensure_one()
balance = (
total_hours
+ total_recovery_hours
+ total_leave_hours
- total_planned_hours
)
return balance
@api.depends(
"employee_id",
"date",
"total_hours",
"total_planned_hours",
"timesheet_line_ids",
)
def _compute_hours(self):
for stat in self:
total_hours = stat._get_total_hours()
total_planned_hours = stat._get_total_planned_hours()
total_recovery_hours = stat._get_total_recovery_hours()
total_leave_hours = stat._get_total_leave_hours()
stat.total_hours = total_hours
stat.total_planned_hours = total_planned_hours
stat.gap_hours = stat._get_gap_hours(total_hours, total_recovery_hours, total_leave_hours, total_planned_hours)
stat.total_recovery_hours = total_recovery_hours
stat.total_leave_hours = total_leave_hours

View File

@@ -1,9 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields
class HrLeaveAllocation(models.Model):
_inherit = "hr.leave.allocation"
timesheet_sheet_id = fields.Many2one("hr_timesheet.sheet", string="Timesheet Sheet", readonly=True)

View File

@@ -1,183 +0,0 @@
from datetime import timedelta
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.addons.resource.models.resource import HOURS_PER_DAY
class HrTimesheetSheet(models.Model):
_inherit = "hr_timesheet.sheet"
employee_stats_ids = fields.One2many(
"hr.employee.stats", "sheet_id", "Employee Stats"
)
timesheet_sheet_gap_hours = fields.Float(
"Timesheet sheet gap hours", compute="_compute_hours"
)
timesheet_sheet_recovery_hours = fields.Float(
"Timesheet sheet recovery hours", compute="_compute_hours"
)
recovery_allocation_ids = fields.One2many(
'hr.leave.allocation',
'timesheet_sheet_id',
string='Recovery Allocations',
)
@api.depends("employee_stats_ids.gap_hours", "employee_id")
def _compute_hours(self):
for sheet in self:
sheet.timesheet_sheet_gap_hours = sheet._get_timesheet_sheet_gap_hours()
sheet.timesheet_sheet_recovery_hours = sheet._get_timesheet_sheet_recovery_hours()
def _get_timesheet_sheet_gap_hours(self):
self.ensure_one()
timesheet_sheet_gap_hours = sum(
self.employee_stats_ids.filtered(
lambda stat: stat.date <= fields.Date.today()
).mapped("gap_hours")
)
return timesheet_sheet_gap_hours
def _get_timesheet_sheet_recovery_hours(self):
self.ensure_one()
coef = self.env.company.coef
# apply coef only if hours to recovery are positive and coef is existing
if self.timesheet_sheet_gap_hours > 0 and coef > 0:
timesheet_sheet_recovery_hours = self.timesheet_sheet_gap_hours + (
self.timesheet_sheet_gap_hours * coef / 100
)
else:
timesheet_sheet_recovery_hours = self.timesheet_sheet_gap_hours
return timesheet_sheet_recovery_hours
def search_and_create_employee_stats(self):
for sheet in self:
if sheet.employee_id:
for day in range((sheet.date_end - sheet.date_start).days + 1):
date = sheet.date_start + timedelta(days=day)
stats = self.env["hr.employee.stats"].search(
[
("employee_id", "=", sheet.employee_id.id),
("date", "=", date),
]
)
if stats and not stats.sheet_id:
stats.write({"sheet_id": sheet.id})
if not stats:
self.env["hr.employee.stats"].create(
{
"employee_id": sheet.employee_id.id,
"date": date,
"sheet_id": sheet.id,
"company_id": sheet.company_id.id,
}
)
return True
@api.model
def create(self, vals):
res = super().create(vals)
res.search_and_create_employee_stats()
return res
def write(self, vals):
res = super().write(vals)
if "date_end" in vals or "date_start" in vals or "employee_id" in vals:
self.search_and_create_employee_stats()
return res
def unlink(self):
for sheet in self:
sheet.employee_stats_ids.unlink()
return super().unlink()
def action_timesheet_draft(self):
res = super().action_timesheet_draft()
for sheet in self:
# set the state of the recovery allocation to refuse if the timesheet sheet is set to draft
if sheet.state == "draft":
sheet.recovery_allocation_ids.write({"state": "refuse"})
return res
def _get_working_hours_per_day(self):
"""
Get the hours per day for the employee according to:
- the employee's work contract,
- or their resource calendar,
- or the company's resource calendar,
- or the default value of 8 hours per day.
:return: hours per day
"""
# get ressource calendar id used during the timesheet sheet time period
ressource_calendar_id = self.employee_id._get_calendar_in_progress_during_a_time_period(self.date_start,self.date_end)
if ressource_calendar_id:
return ressource_calendar_id.hours_per_day
return HOURS_PER_DAY
def action_generate_recovery_allocation(self):
# check if the user has the right to review the timesheet sheet
self.ensure_one()
self._check_can_review()
recovery_type_id = self.env.company.recovery_type_id
employee_id = self.employee_id
if not employee_id or not recovery_type_id:
raise UserError(
_("Employee not defined for the timesheet sheet or recovery type not defined in settings")
)
if recovery_type_id.request_unit != 'hour' or not recovery_type_id.allows_negative:
raise UserError(
_("The recovery type must be set to 'Hours' and allow negative leaves in the settings")
)
# check if allocation already exists for this timesheet sheet, if yes, refuse it
allocations = (
self.env["hr.leave.allocation"]
.sudo()
.search(
[
("timesheet_sheet_id.id", "=", self.id),
("state", "!=", "refuse"),
]
)
)
if allocations:
allocations.write({"state": "refuse"})
# get recovery hours from total gap hours of the timesheet sheet
recovery_hours = self._get_timesheet_sheet_recovery_hours()
# convert recovery hours into days
recovery_days = recovery_hours / self._get_working_hours_per_day()
# create an allocation (positive or negative) according to the total gap hours for the timesheet sheet range time
new_alloc = self.env["hr.leave.allocation"].create(
{
"private_name": "Allocation : %s - %s" % (recovery_type_id.name, employee_id.display_name),
"holiday_status_id": recovery_type_id.id,
"employee_id": employee_id.id,
"number_of_days": recovery_days,
"timesheet_sheet_id": self.id,
"allocation_type": 'accrual',
"date_from": self.date_start,
}
)
# set the allocation to validate or not
if self.env.company.auto_validate_recovery_allocation:
new_alloc.write({"state": "validate"})
return {
"type": "ir.actions.act_window",
"res_model": "hr.leave.allocation",
"res_id": new_alloc.id,
"view_mode": "form",
"target": "current",
"views": [
(
self.env.ref("hr_holidays.hr_leave_allocation_view_form").id,
"form",
)
],
}

View File

@@ -1,12 +0,0 @@
from odoo import fields, models
class ResCompany(models.Model):
_inherit = "res.company"
recovery_type_id = fields.Many2one(
"hr.leave.type", string="Leave recovery type"
)
coef = fields.Float("Coef", default=25)
auto_validate_recovery_allocation = fields.Boolean("Auto validate recovery allocation", default=True)

View File

@@ -1,29 +0,0 @@
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
recovery_type_id = fields.Many2one(
"hr.leave.type",
related="company_id.recovery_type_id",
string="Leave recovery type",
readonly=False,
domain="[('request_unit', '=', 'hour'), ('allows_negative', '=', True)]",
)
coef = fields.Float(
related="company_id.coef",
required=True,
string="Coef (in %)",
domain="[('company_id', '=', company_id)]",
readonly=False,
help="The coef is applied to recovery hours"
"Example : an employe make 1h overtime, if coef is set to 25%, the recovery hours allocated will be 1,25h",
)
auto_validate_recovery_allocation = fields.Boolean(
related="company_id.auto_validate_recovery_allocation",
readonly=False,
domain="[('company_id', '=', company_id)]",
)

View File

@@ -1,3 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_hr_employee_stats_manager,hr.employee.stats,model_hr_employee_stats,hr_timesheet.group_timesheet_manager,1,1,1,1
access_hr_employee_stats_user,hr.employee.stats,model_hr_employee_stats,hr_timesheet.group_hr_timesheet_user,1,0,1,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_hr_employee_stats_manager hr.employee.stats model_hr_employee_stats hr_timesheet.group_timesheet_manager 1 1 1 1
3 access_hr_employee_stats_user hr.employee.stats model_hr_employee_stats hr_timesheet.group_hr_timesheet_user 1 0 1 0

View File

@@ -1 +0,0 @@
from . import test_employee_stats

View File

@@ -1,404 +0,0 @@
from odoo.tests.common import TransactionCase
from odoo.tests import tagged
from datetime import date, timedelta, datetime
from odoo.exceptions import UserError
from odoo.fields import Date
@tagged("post_install", "-at_install")
class TestHrEmployeeStatsRecovery(TransactionCase):
def setUp(self):
super().setUp()
self.user = self.env['res.users'].create({
'name': 'Camille',
'login': 'camille',
})
self.recovery_type = self.env['hr.leave.type'].create({
'name': 'Recovery',
'request_unit': 'hour',
'allows_negative': True,
})
self.employee = self.env['hr.employee'].create({
'name': 'Camille',
'user_id': self.user.id,
'tz': 'Europe/Paris',
})
self.base_calendar = self.env['resource.calendar'].create({
'name': 'Default Calendar',
'attendance_ids': [
(0, 0, {'name': 'Monday Morning', 'dayofweek': '0', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Monday Afternoon', 'dayofweek': '0', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Tuesday Morning', 'dayofweek': '1', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Tuesday Afternoon', 'dayofweek': '1', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Wednesday Morning', 'dayofweek': '2', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Wednesday Afternoon', 'dayofweek': '2', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Thursday Morning', 'dayofweek': '3', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Thursday Afternoon', 'dayofweek': '3', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Friday Morning', 'dayofweek': '4', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Friday Afternoon', 'dayofweek': '4', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
],
})
self.base_calendar.hours_per_day = 7
self.employee.resource_calendar_id = self.base_calendar
self.env.company.recovery_type_id = self.recovery_type
self.env.company.coef = 25
analytic_plan = self.env['account.analytic.plan'].create({
'name': 'Test Plan',
})
self.analytic_account = self.env['account.analytic.account'].create({
'name': 'Test Analytic Account',
'plan_id': analytic_plan.id,
})
def _create_timesheet_sheet(self, start_date):
# Create a timesheet for the week (Monday to Sunday)
return self.env['hr_timesheet.sheet'].create({
'employee_id': self.employee.id,
'date_start': start_date,
'date_end': start_date + timedelta(days=6),
})
def _create_stats(self, start_date, nb_days, unit_amount):
# Create timesheet lines from Monday to Friday (or nb_days)
for i in range(nb_days):
self.env['account.analytic.line'].create({
'employee_id': self.employee.id,
'date': start_date + timedelta(days=i),
'unit_amount': unit_amount,
'account_id': self.analytic_account.id,
'name': 'Work Entry',
})
# Generate hr.employee.stats for each day of the period
stat = self.env['hr.employee.stats'].create({
'employee_id': self.employee.id,
'date': start_date + timedelta(days=i),
})
stat._compute_dayofweek()
stat._compute_hours()
yield stat
def test_invalide_recovery_type(self):
start_date = date.today() - timedelta(days=date.today().weekday() + 7) # monday of last week
self.recovery_type.request_unit = 'day'
self.recovery_type.allows_negative = False
timesheet_sheet = self._create_timesheet_sheet(start_date)
self.env.company.recovery_type_id = self.recovery_type
with self.assertRaises(UserError):
timesheet_sheet.action_generate_recovery_allocation()
def test_no_recovery_hours(self):
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2025-01-01"),
'date_end': None,
'calendar_id': self.base_calendar.id,
})
start_date = date.today() - timedelta(days=date.today().weekday() + 7) # monday of last week
timesheet_sheet = self._create_timesheet_sheet(start_date)
for stat in self._create_stats(start_date, 5, 7): #créer 5 stats de 7h chacune
# Compare les heures de récupération calculées et le calendrier qui prévoit 7h par jour
self.assertEqual(stat.total_hours, 7, "total_hours should be 7",) # l'employé a travaillé 7h chaque jour
self.assertEqual(stat.total_planned_hours, 7, "total_planned_hours should be 7",) # le calendrier prévoit 7h chaque jour
self.assertEqual(stat.total_leave_hours, 0, "total_leave_hours should be 0",) # l'employé n'a pas de congé sur ce jour
self.assertEqual(stat.total_recovery_hours, 0, "total_recovery_hours should be 0",) # l'employé n'a pas posé de récupération sur ce jour
self.assertEqual(stat.gap_hours, 0, "gap_hours should be 0",) # pas de différence entre les heures travaillées et les heures planifiées
# La feuille de temps sur cette période doit compter 0h de déficit et 0h de récupération
self.assertEqual(timesheet_sheet.timesheet_sheet_gap_hours, 0, "timesheet_sheet_gap_hours should be 0",)
self.assertEqual(timesheet_sheet.timesheet_sheet_recovery_hours, 0, "timesheet_sheet_recovery_hours should be 0",)
def test_positive_recovery_hours(self):
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2025-01-01"),
'date_end': None,
'calendar_id': self.base_calendar.id,
})
start_date = date.today() - timedelta(days=date.today().weekday() + 7) # lundi de la semaine dernière
timesheet_sheet = self._create_timesheet_sheet(start_date)
for stat in self._create_stats(start_date, 5, 8): #créer 5 stats de 8h chacune
# Compare les heures de récupération calculées et le calendrier qui prévoit 7h par jour
self.assertEqual(stat.total_hours, 8, "total_hours should be 8",) # l'employé a travaillé 8h chaque jour
self.assertEqual(stat.total_planned_hours, 7, "total_planned_hours should be 7",) # le calendrier prévoit 7h chaque jour
self.assertEqual(stat.total_leave_hours, 0, "total_leave_hours should be 0",) # l'employé n'a pas de congé sur ce jour
self.assertEqual(stat.total_recovery_hours, 0, "total_recovery_hours should be 0",) # l'employé n'a pas posé de récupération sur ce jour
self.assertEqual(stat.gap_hours, 1, "gap_hours should be 1",) # l'employée a travaillé une heure de plus que prévu
# La feuille de temps doit compter 5h d'heure sup soit 6,25h de récupération avec la majoration de 25%
self.assertEqual(timesheet_sheet.timesheet_sheet_gap_hours, 5, "timesheet_sheet_gap_hours should be 5",)
self.assertEqual(timesheet_sheet.timesheet_sheet_recovery_hours, 6.25, "timesheet_sheet_recovery_hours should be 6,25",)
# générer l'allocation de récupération depuis la feuille de temps
timesheet_sheet.action_generate_recovery_allocation()
recovery_allocation = self.env["hr.leave.allocation"].search([("timesheet_sheet_id","=",timesheet_sheet.id)])
self.assertEqual(len(recovery_allocation), 1, "There should be one recovery")
self.assertEqual(recovery_allocation.number_of_days,0.8928571428571429, "The recovery allocation should be for 6.25h/7h = 0.8928571428571429 day")
def test_negative_recovery_hours(self):
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2025-01-01"),
'date_end': None,
'calendar_id': self.base_calendar.id,
})
start_date = date.today() - timedelta(days=date.today().weekday() + 7) # lundi de la semaine dernière
timesheet_sheet = self._create_timesheet_sheet(start_date)
for stat in self._create_stats(start_date, 5, 6): #créer 5 stats de 6h chacune
# Compare les heures de récupération calculées et le calendrier qui prévoit 7h par jour
self.assertEqual(stat.total_hours, 6, "total_hours should be 6",) # l'employé a travaillé 6h chaque jour
self.assertEqual(stat.total_planned_hours, 7, "total_planned_hours should be 7",) # le calendrier prévoit 7h chaque jour
self.assertEqual(stat.total_leave_hours, 0, "total_leave_hours should be 0",) # l'employé n'a pas de congé sur ce jour
self.assertEqual(stat.total_recovery_hours, 0, "total_recovery_hours should be 0",) # l'employé n'a pas posé de récupération sur ce jour
self.assertEqual(stat.gap_hours, -1, "gap_hours should be -1",) # l'employée a travaillé une heure de moins que prévu
# La feuille de temps doit compter -5h de déficit et -5h de récupération
self.assertEqual(timesheet_sheet.timesheet_sheet_gap_hours, -5, "timesheet_sheet_gap_hours should be -5",) # l'employé a travaillé -5h au total sur la semaine
self.assertEqual(timesheet_sheet.timesheet_sheet_recovery_hours, -5, "timesheet_sheet_recovery_hours should be -5",) # -5h sera le montant de l'allocation de récupération (pas de coef appliqué pour les déficites d'heures)
# générer l'allocation de récupération depuis la feuille de temps
timesheet_sheet.action_generate_recovery_allocation()
recovery_allocation = self.env["hr.leave.allocation"].search([("timesheet_sheet_id","=",timesheet_sheet.id)])
self.assertEqual(len(recovery_allocation), 1, "There should be one recovery")
self.assertEqual(recovery_allocation.number_of_days, -0.7142857142857143, "The recovery allocation should be for -5/7 hours = 0,714285714")
def test_recovery_hours_part_time_employee(self):
part_time_calendar = self.env['resource.calendar'].create({
'name': 'Part Time Calendar',
'attendance_ids': [
(0, 0, {'name': 'Monday Morning', 'dayofweek': '0', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Monday Afternoon', 'dayofweek': '0', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Tuesday Morning', 'dayofweek': '1', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Tuesday Afternoon', 'dayofweek': '1', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Wednesday Morning', 'dayofweek': '2', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Wednesday Afternoon', 'dayofweek': '2', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Thursday Morning', 'dayofweek': '3', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Thursday Afternoon', 'dayofweek': '3', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
],
})
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2025-01-01"),
'date_end': None,
'calendar_id': part_time_calendar.id,
})
start_date = date.today() - timedelta(days=date.today().weekday() + 7) # lundi de la semaine dernière
timesheet_sheet = self._create_timesheet_sheet(start_date)
for stat in self._create_stats(start_date, 4, 8): #créer 4 stats de 8h chacune
# Compare les heures de récupération calculées et le calendrier qui prévoit 7h par jour pendant 4 jours
self.assertEqual(stat.total_hours, 8, "total_hours should be 8",) # l'employé a travaillé 6h chaque jour
self.assertEqual(stat.total_planned_hours, 7, "total_planned_hours should be 7",) # le calendrier prévoit 7h chaque jour
self.assertEqual(stat.total_leave_hours, 0, "total_leave_hours should be 0",) # l'employé n'a pas de congé sur ce jour
self.assertEqual(stat.total_recovery_hours, 0, "total_recovery_hours should be 0",) # l'employé n'a pas posé de récupération sur ce jour
self.assertEqual(stat.gap_hours, 1, "gap_hours should be 1",) # l'employée a travaillé une heure de moins que prévu
# La feuille de temps doit compter 4h d'heure sup soit 5h de récupération avec la majoration de 25%
self.assertEqual(timesheet_sheet.timesheet_sheet_gap_hours, 4, "timesheet_sheet_gap_hours should be 4",) # l'employé a travaillé supplémentaire 4h au total sur la semaine
self.assertEqual(timesheet_sheet.timesheet_sheet_recovery_hours, 5, "timesheet_sheet_recovery_hours should be 5",) # 5h sera le montant de l'allocation de récupération (coef de 25% de majoration)
def test_recovery_hours_change_calendar(self):
employee_full_time_calendar = self.base_calendar # full time calendar (from monday to friday)
employee_part_time_calendar = self.env['resource.calendar'].create({
'name': 'Part Time Calendar',
'attendance_ids': [
(0, 0, {'name': 'Monday Morning', 'dayofweek': '0', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Monday Afternoon', 'dayofweek': '0', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Tuesday Morning', 'dayofweek': '1', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Tuesday Afternoon', 'dayofweek': '1', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Wednesday Morning', 'dayofweek': '2', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Wednesday Afternoon', 'dayofweek': '2', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Thursday Morning', 'dayofweek': '3', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Thursday Afternoon', 'dayofweek': '3', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
],
})
#create two hr.employee.calendar to change calendar during the timesheet period
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2023-07-01"),
'date_end': Date.to_date("2025-07-31"),
'calendar_id': employee_full_time_calendar.id,
})
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2025-08-01"),
'date_end': None,
'calendar_id': employee_part_time_calendar.id,
})
self.employee.resource_calendar_id = employee_part_time_calendar.id
#create recovery hours on a period including the change of calendar
timesheet_sheet = self._create_timesheet_sheet(Date.to_date("2025-07-28")) #a week including the change of calendar on 1st august
#the create of recovery allocation should raise an error
with self.assertRaises(UserError):
timesheet_sheet.action_generate_recovery_allocation()
def test_recovery_hours_change_calendar_sucess(self):
employee_full_time_calendar = self.base_calendar # full time calendar (from monday to friday)
employee_part_time_calendar = self.env['resource.calendar'].create({
'name': 'Part Time Calendar',
'attendance_ids': [
(0, 0, {'name': 'Monday Morning', 'dayofweek': '0', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Monday Afternoon', 'dayofweek': '0', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Tuesday Morning', 'dayofweek': '1', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Tuesday Afternoon', 'dayofweek': '1', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Wednesday Morning', 'dayofweek': '2', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Wednesday Afternoon', 'dayofweek': '2', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Thursday Morning', 'dayofweek': '3', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Thursday Afternoon', 'dayofweek': '3', 'hour_from': 13, 'hour_to': 17, 'day_period': 'afternoon'}),
],
})
#create two hr.employee.calendar to change calendar during the timesheet period
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2023-07-01"),
'date_end': Date.to_date("2025-07-31"),
'calendar_id': employee_full_time_calendar.id,
})
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2025-08-01"),
'date_end': None,
'calendar_id': employee_part_time_calendar.id,
})
self.employee.resource_calendar_id = employee_part_time_calendar.id
#create stats during period of full time calendar for the employee
timesheet_sheet = self.env['hr_timesheet.sheet'].create({
'employee_id': self.employee.id,
'date_start': "2025-07-07",
'date_end': "2025-07-13",
})
stats = self._create_stats(Date.to_date("2025-07-07"), 5, 7)
for stat in stats:
stat._compute_dayofweek()
stat._compute_hours()
timesheet_sheet.action_generate_recovery_allocation()
self.assertEqual(timesheet_sheet.timesheet_sheet_gap_hours, 0, "timesheet_sheet_gap_hours should be 0",)
self.assertEqual(timesheet_sheet.timesheet_sheet_recovery_hours, 0, "timesheet_sheet_recovery_hours should be 0",)
#create stats during period of part time calendar for the employee
stats = self._create_stats(Date.to_date("2025-09-08"), 5, 7)
for stat in stats:
stat._compute_dayofweek()
stat._compute_hours()
timesheet_sheet = self.env['hr_timesheet.sheet'].create({
'employee_id': self.employee.id,
'date_start': "2025-09-08",
'date_end': "2025-09-14",
})
self.assertEqual(timesheet_sheet.timesheet_sheet_gap_hours, 7, "timesheet_sheet_gap_hours should be 7",)
self.assertEqual(timesheet_sheet.timesheet_sheet_recovery_hours, 8.75, "timesheet_sheet_recovery_hours should be 8,75",)
def test_recovery_allocation_doesnt_change_with_of_calendar(self):
employee_full_time_calendar = self.base_calendar # full time calendar (from monday to friday)
employee_full_time_calendar.hours_per_day = 7
employee_part_time_calendar = self.env['resource.calendar'].create({
'name': 'Part Time Calendar',
'attendance_ids': [
(0, 0, {'name': 'Monday Morning', 'dayofweek': '0', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Monday Afternoon', 'dayofweek': '0', 'hour_from': 13, 'hour_to': 19, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Tuesday Morning', 'dayofweek': '1', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Tuesday Afternoon', 'dayofweek': '1', 'hour_from': 13, 'hour_to': 19, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Wednesday Morning', 'dayofweek': '2', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Wednesday Afternoon', 'dayofweek': '2', 'hour_from': 13, 'hour_to': 19, 'day_period': 'afternoon'}),
(0, 0, {'name': 'Thursday Morning', 'dayofweek': '3', 'hour_from': 9, 'hour_to': 12, 'day_period': 'morning'}),
(0, 0, {'name': 'Thursday Afternoon', 'dayofweek': '3', 'hour_from': 13, 'hour_to': 19, 'day_period': 'afternoon'}),
],
})
employee_part_time_calendar.hours_per_day = 9
#create two hr.employee.calendar to change calendar during the timesheet period
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2023-07-01"),
'date_end': Date.to_date("2025-07-31"),
'calendar_id': employee_full_time_calendar.id,
})
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2025-08-01"),
'date_end': None,
'calendar_id': employee_part_time_calendar.id,
})
self.employee.resource_calendar_id = employee_part_time_calendar.id
#create stats during period of full time calendar for the employee
timesheet_sheet_1 = self.env['hr_timesheet.sheet'].create({
'employee_id': self.employee.id,
'date_start': "2025-07-07",
'date_end': "2025-07-13",
})
stats = self._create_stats(Date.to_date("2025-07-07"), 5, 8)
for stat in stats:
stat._compute_dayofweek()
stat._compute_hours()
timesheet_sheet_1.action_generate_recovery_allocation()
self.assertEqual(timesheet_sheet_1.timesheet_sheet_gap_hours, 5, "timesheet_sheet_gap_hours should be 0",)
self.assertEqual(timesheet_sheet_1.timesheet_sheet_recovery_hours, 6.25, "timesheet_sheet_recovery_hours should be 6,25",)
allocation_1 = self.env["hr.leave.allocation"].search([("timesheet_sheet_id","=",timesheet_sheet_1.id)])
self.assertEqual(len(allocation_1), 1, "There should be one recovery")
self.assertEqual(allocation_1.number_of_days,0.8928571428571429, "The recovery allocation should be for 0.8928571428571429 day")
#create stats during period of part time calendar for the employee
# generation 4 stats of 10h each, the employee is supposed to work 9h per day during 4 days
stats_2 = self._create_stats(Date.to_date("2025-09-08"), 4, 10)
for stat in stats_2:
stat._compute_dayofweek()
stat._compute_hours()
timesheet_sheet_2 = self.env['hr_timesheet.sheet'].create({
'employee_id': self.employee.id,
'date_start': "2025-09-08",
'date_end': "2025-09-14",
})
timesheet_sheet_2.action_generate_recovery_allocation()
self.assertEqual(timesheet_sheet_2.timesheet_sheet_gap_hours, 4, "timesheet_sheet_gap_hours should be 4",)
self.assertEqual(timesheet_sheet_2.timesheet_sheet_recovery_hours, 5, "timesheet_sheet_recovery_hours should be 5",)
allocation_2 = self.env["hr.leave.allocation"].search([("timesheet_sheet_id","=",timesheet_sheet_2.id)])
self.assertEqual(len(allocation_2), 1, "There should be one recovery")
self.assertEqual(allocation_2.number_of_days,0.5555555555555556, "The recovery allocation should be for 0,555555556 (5/9) day")
#check that allocation_1 hasn't changed
self.assertEqual(allocation_1.number_of_days,0.8928571428571429, "The recovery allocation should be for 0,892857143 day")
def test_public_holiday(self):
self.env['hr.employee.calendar'].create({
'employee_id': self.employee.id,
'date_start': Date.to_date("2025-01-01"),
'date_end': None,
'calendar_id': self.base_calendar.id,
})
# create a public holiday :
# When you create holidays graphically with a TZ,
# they are saved in the database after conversion to UTC.
# This is why, for a holiday starting on May 1, 2025, at 00:00:00 UTC+2,
# it will be saved in the database as April 30, 2025, at 22:00:00.
self.env["resource.calendar.leaves"].create(
{
"name": "1 mai 2025",
"date_from": datetime(2025,4,30,22,0,0),
"date_to": datetime(2025,5,1,21,0,0),
}
)
#create 5 stats of 7h each including the public holiday on 1st may
stats = self._create_stats(Date.to_date("2025-04-28"), 5, 7)
for stat in stats:
stat._compute_dayofweek()
stat._compute_hours()
#create 1 timesheet sheet from monday to friday including the public holiday on 1st may
timesheet_sheet = self.env['hr_timesheet.sheet'].create({
'employee_id': self.employee.id,
'date_start': "2025-04-28",
'date_end': "2025-05-04",
})
# the employee has worked 7h on first may (public holiday) instead of 0h
# so the gap hours should be 7h and recovery hours 8,75h with coef 25%
self.assertEqual(timesheet_sheet.timesheet_sheet_gap_hours, 7, "timesheet_sheet_gap_hours should be 7",)
self.assertEqual(timesheet_sheet.timesheet_sheet_recovery_hours, 8.75, "timesheet_sheet_recovery_hours should be 8,75",)
timesheet_sheet.action_generate_recovery_allocation()
recovery_allocation = self.env["hr.leave.allocation"].search([("timesheet_sheet_id","=",timesheet_sheet.id)])
self.assertEqual(len(recovery_allocation), 1, "Il doit y avoir une allocation de récupération générée")
self.assertEqual(recovery_allocation.number_of_days,1.25, "The recovery allocation should be 1,25 days")

View File

@@ -1,20 +0,0 @@
<odoo>
<record id="view_hr_employee_stats_tree" model="ir.ui.view">
<field name="name">hr.employee.stats.tree</field>
<field name="model">hr.employee.stats</field>
<field name="arch" type="xml">
<tree name="Employee time stats" editable="top" decoration-muted="dayofweek in [5,6] or is_public_holiday">
<field name="name"/>
<field name="date"/>
<field name="employee_id"/>
<field name="total_hours" widget="float_time" sum="Total"/>
<field name="total_leave_hours" widget="float_time" sum="Total"/>
<field name="total_recovery_hours" widget="float_time" sum="Total"/>
<field name="total_planned_hours" widget="float_time" sum="Total"/>
<field name="gap_hours" widget="float_time" sum="Total"/>
<field name="dayofweek" invisible="1"/>
<field name="is_public_holiday" invisible="1"/>
</tree>
</field>
</record>
</odoo>

View File

@@ -1,78 +0,0 @@
<odoo>
<data>
<!-- Ajout d'une vue tree pour les stats dans la timesheet_sheet -->
<record id="view_hr_timesheet_sheet_form_inherit" model="ir.ui.view">
<field name="name">hr.timesheet.sheet.form.inherit</field>
<field name="model">hr_timesheet.sheet</field>
<field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form"/>
<field name="arch" type="xml">
<group name="dates" position="inside">
<field name="timesheet_sheet_gap_hours" string="Total gap hours in this timesheet sheet time range" widget="float_time"/>
<field name="timesheet_sheet_recovery_hours" string="Total recovery hours in this timesheet sheet time range" widget="float_time" style="font-weight: bold"/>
<button
colspan="2"
class="oe_highlight"
name="action_generate_recovery_allocation"
string='Create recovery allocation'
type='object'
attrs="{'invisible': ['|', ('can_review', '=', False),
('state', '!=', 'done'),
('timesheet_sheet_recovery_hours', '=', 0)]}"
/>
</group>
<xpath expr="//notebook" position="inside">
<page string="Employee Stats">
<field name="employee_stats_ids" no_label="1" readonly="1"/>
</page>
<page string="Generated recovery allocations">
<field name="recovery_allocation_ids" no_label="1" readonly="1"/>
</page>
</xpath>
</field>
</record>
<record id="hr_timesheet_sheet_stats_overview_pivot_view" model="ir.ui.view">
<field name="name">hr.timesheet.sheet.stats.overview.pivot.view</field>
<field name="model">hr_timesheet.sheet</field>
<field name="arch" type="xml">
<pivot string="Employee time stats pivot" sample="1">
<field name="employee_id" type="row"/>
</pivot>
</field>
</record>
<!-- Ajout d'une vue heure d'écart et récup sur la vue tree des hr_timesheet.sheet -->
<record id="view_hr_timesheet_sheet_tree_stats_inherit" model="ir.ui.view">
<field name="name">hr.timesheet.sheet.tree.stats.inherit</field>
<field name="model">hr_timesheet.sheet</field>
<field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_tree" />
<field name="arch" type="xml">
<field name="department_id" position="after">
<field name="timesheet_sheet_gap_hours" string="Heures d'écart" optional="show" widget="float_time" />
<field name="timesheet_sheet_recovery_hours" string="Heures de récupération" optional="hide" widget="float_time" />
</field>
</field>
</record>
<!-- Ajout d'une vue pivot pour hr_timesheet.sheet -->
<!-- <record id="hr_timesheet_sheet_pivot" model="ir.ui.view">
<field name="name">hr.timesheet.sheet.pivot</field>
<field name="model">hr_timesheet.sheet</field>
<field name="arch" type="xml">
<pivot string="Timesheet Sheets Analysis">
<field name="employee_id" type="row"/>
<field name="department_id"/>
<field name="reviewer_id"/>
<field name="state"/>
<field name="date_start" type="row"/>
<field name="date_end"/>
<field name="total_time" type="measure" />
</pivot>
</field>
</record> -->
<!-- Ajout de la vue pivot à l'action "All Timesheet Sheets" -->
<!-- <record id="act_hr_timesheet_sheet_all_timesheets_pivot" model="ir.actions.act_window.view">
<field name="view_mode">pivot</field>
<field name="sequence" eval="10"/>
<field name="view_id" ref="hr_timesheet_sheet_pivot"/>
<field name="act_window_id" ref="hr_timesheet_sheet.act_hr_timesheet_sheet_all_timesheets"/>
</record> -->
</data>
</odoo>

View File

@@ -1,60 +0,0 @@
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.hr.timesheet</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="55" />
<field name="inherit_id" ref="hr_timesheet.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@name='hr_timesheet_sheet']" position="inside">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="recovery_type_id"/>
<span
class="fa fa-lg fa-building"
title="Values set here are company-specific."
aria-label="Values set here are company-specific."
groups="base.group_multi_company"
role="img"
/>
<div class="text-muted">
Choose the recovery type.
</div>
<div class="content-group">
<div class="mb16">
<field
name="recovery_type_id"
class="o_light_label"
widget="selection"
required="1"
/>
</div>
</div>
<div class="text-muted">
Choose the coef to apply to recovery hours.
</div >
<div class="content-group">
<div class="mb16">
<field
name="coef"
class="o_light_label"
widget="float"
/> %
</div>
</div>
<div class="text-muted">
Choose to auto-validate the recovery allocation or not
</div>
<div class="content-group">
<div class="mb16">
<field
name="auto_validate_recovery_allocation"
widget="boolean_toggle"
/>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

View File

@@ -1 +0,0 @@
from . import models

View File

@@ -1,20 +0,0 @@
{
"name": "hr_employee_stats_sheet_lunch_voucher",
"version": "16.0.1.0.0",
"description": "Add global sheet for employee stats",
"summary": "Add global sheet for employee stats",
"author": "Elabore",
"website": "https://elabore.coop",
"license": "LGPL-3",
"category": "Human Resources",
"depends": [
"hr_employee_stats_sheet",
],
"data": [
"views/hr_employee_stats.xml",
"views/hr_timesheet_sheet.xml",
"views/res_config_settings_views.xml",
],
"installable": True,
"application": False,
}

View File

@@ -1,86 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_employee_stats_sheet_lunch_voucher
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-06-11 13:19+0000\n"
"PO-Revision-Date: 2025-06-11 13:19+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: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model.fields,help:hr_employee_stats_sheet_lunch_voucher.field_res_config_settings__lunch_voucher_min_worked_hours
msgid ""
"5h by default, meaning that if an employee works 5h or more in a day, he "
"will get a lunch voucher"
msgstr "5h par défaut"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet_lunch_voucher.res_config_settings_view_form
msgid ""
"<span class=\"fa fa-lg fa-building\" title=\"Minimal number of hours worked "
"in a day to get a lunch voucher.\" groups=\"base.group_multi_company\"/>"
msgstr ""
"<span class=\"fa fa-lg fa-building\" title=\"Nombre minimal d'heures travaillées "
"dans une journée pour cumuler un prime repas.\" groups=\"base.group_multi_company\"/>"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model,name:hr_employee_stats_sheet_lunch_voucher.model_res_company
msgid "Companies"
msgstr "Sociétés"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model,name:hr_employee_stats_sheet_lunch_voucher.model_res_config_settings
msgid "Config Settings"
msgstr "Paramètres de configuration"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model,name:hr_employee_stats_sheet_lunch_voucher.model_hr_employee_stats
msgid "Employee Stats"
msgstr "Statistique de l'employé·e"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet_lunch_voucher.res_config_settings_view_form
msgid ""
"Indicate the minimal number of hours worked in a day to get a lunch voucher "
"(by default 5 hours)."
msgstr "Indiquez le nombre d'heures minimal pour cumuler une prime repas/ticket restaurant"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model.fields,field_description:hr_employee_stats_sheet_lunch_voucher.field_hr_employee_stats__lunch_voucher
msgid "Lunch Voucher"
msgstr "Ticket restaurant"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model.fields,field_description:hr_employee_stats_sheet_lunch_voucher.field_res_company__lunch_voucher_min_worked_hours
msgid "Lunch Voucher Min Worked Hours"
msgstr "Prime repas Nombre d'heures minimal"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model.fields,field_description:hr_employee_stats_sheet_lunch_voucher.field_hr_timesheet_sheet__lunch_voucher_count
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet_lunch_voucher.hr_timesheet_sheet_tree_lunch_voucher_inherit
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet_lunch_voucher.timesheet_sheet_form_lunch_voucher_inherit
msgid "Lunch voucher Count"
msgstr "Nombre de ticket restaurant"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model.fields,field_description:hr_employee_stats_sheet_lunch_voucher.field_res_config_settings__lunch_voucher_min_worked_hours
msgid "Minimal number of hours worked in a day to get a lunch voucher"
msgstr "Nombre d'heures minimal pour cumuler une prime repas/ticket restaurant"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model,name:hr_employee_stats_sheet_lunch_voucher.model_hr_timesheet_sheet
msgid "Timesheet Sheet"
msgstr "Feuille de temps"
#. module: hr_employee_stats_sheet_lunch_voucher
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet_lunch_voucher.hr_employee_stats_tree_lunch_voucher_inherit
msgid "Total"
msgstr ""

View File

@@ -1,42 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_employee_stats_sheet_lunch_voucher
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-05-05 13:34+0000\n"
"PO-Revision-Date: 2025-05-05 13:34+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: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model,name:hr_employee_stats_sheet_lunch_voucher.model_hr_employee_stats
msgid "Employee Stats"
msgstr ""
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model.fields,field_description:hr_employee_stats_sheet_lunch_voucher.field_hr_employee_stats__lunch_voucher
msgid "Lunch Voucher"
msgstr ""
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model.fields,field_description:hr_employee_stats_sheet_lunch_voucher.field_hr_timesheet_sheet__lunch_voucher_count
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet_lunch_voucher.hr_timesheet_sheet_stats_overview_view_sikle_inherit
msgid "Lunch voucher Count"
msgstr ""
#. module: hr_employee_stats_sheet_lunch_voucher
#: model:ir.model,name:hr_employee_stats_sheet_lunch_voucher.model_hr_timesheet_sheet
msgid "Timesheet Sheet"
msgstr ""
#. module: hr_employee_stats_sheet_lunch_voucher
#: model_terms:ir.ui.view,arch_db:hr_employee_stats_sheet_lunch_voucher.view_hr_employee_stats_tree_sikle_inherit
msgid "Total"
msgstr ""

View File

@@ -1 +0,0 @@
from . import hr_employee_stats, hr_timesheet_sheet, res_config, res_company

View File

@@ -1,19 +0,0 @@
from odoo import fields, models, api
class HrEmployeeStats(models.Model):
_inherit = "hr.employee.stats"
lunch_voucher = fields.Integer("Lunch Voucher", compute="_compute_lunch_voucher")
@api.depends("total_hours")
def _compute_lunch_voucher(self):
for stat in self:
stat.lunch_voucher = 0
if stat.date and stat.employee_id:
stat._get_lunch_voucher()
def _get_lunch_voucher(self):
#do not factorize this method with _compute_lunch_voucher to be used in other modules
self.ensure_one()
if self.total_hours >= self.env.company.lunch_voucher_min_worked_hours:
self.lunch_voucher = 1

View File

@@ -1,15 +0,0 @@
from odoo import fields, models, api
class HrTimesheetSheet(models.Model):
_inherit = "hr_timesheet.sheet"
lunch_voucher_count = fields.Integer("Lunch voucher Count", compute="_compute_lunch_voucher_count")
@api.depends("employee_stats_ids.lunch_voucher")
def _compute_lunch_voucher_count(self):
for sheet in self:
sheet.lunch_voucher_count = 0
if sheet.employee_stats_ids:
for stat in sheet.employee_stats_ids:
sheet.lunch_voucher_count += stat.lunch_voucher

View File

@@ -1,7 +0,0 @@
from odoo import fields, models
class ResCompany(models.Model):
_inherit = "res.company"
lunch_voucher_min_worked_hours = fields.Float(default=5)

View File

@@ -1,14 +0,0 @@
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
lunch_voucher_min_worked_hours = fields.Float(
related="company_id.lunch_voucher_min_worked_hours",
required=True,
string="Minimal number of hours worked in a day to get a lunch voucher",
domain="[('company_id', '=', company_id)]",
readonly=False,
help="5h by default, meaning that if an employee works 5h or more in a day, he will get a lunch voucher",
)

View File

@@ -1,12 +0,0 @@
<odoo>
<record id="hr_employee_stats_tree_lunch_voucher_inherit" model="ir.ui.view">
<field name="name">hr.employee.stats.tree.lunch.voucher.inherit</field>
<field name="model">hr.employee.stats</field>
<field name="inherit_id" ref="hr_employee_stats_sheet.view_hr_employee_stats_tree"/>
<field name="arch" type="xml">
<field name="total_hours" position="after">
<field name="lunch_voucher" sum="Total"/>
</field>
</field>
</record>
</odoo>

View File

@@ -1,22 +0,0 @@
<odoo>
<record id="timesheet_sheet_form_lunch_voucher_inherit" model="ir.ui.view">
<field name="name">timesheet.sheet.form.lunch.voucher.inherit</field>
<field name="model">hr_timesheet.sheet</field>
<field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form" />
<field name="arch" type="xml">
<field name="department_id" position="after">
<field name="lunch_voucher_count" string="Lunch voucher Count" />
</field>
</field>
</record>
<record id="hr_timesheet_sheet_tree_lunch_voucher_inherit" model="ir.ui.view">
<field name="name">hr.timesheet.sheet.tree.lunch.voucher.inherit</field>
<field name="model">hr_timesheet.sheet</field>
<field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_tree" />
<field name="arch" type="xml">
<field name="department_id" position="after">
<field name="lunch_voucher_count" string="Lunch voucher Count" />
</field>
</field>
</record>
</odoo>

View File

@@ -1,35 +0,0 @@
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.hr.timesheet</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="55" />
<field name="inherit_id" ref="hr_timesheet.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@name='hr_timesheet_sheet']" position="inside">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="lunch_voucher_min_worked_hours"/>
<span
class="fa fa-lg fa-building"
title="Minimal number of hours worked in a day to get a lunch voucher."
groups="base.group_multi_company"
/>
<div class="text-muted">
Indicate the minimal number of hours worked in a day to get a lunch voucher (by default 5 hours).
</div>
<div class="content-group">
<div class="mb16">
<field
name="lunch_voucher_min_worked_hours"
class="o_light_label"
widget="float"
required="1"
/>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,43 @@
==============================
hr_expense_analytic_account_preselect_with_project
==============================
In expenses, preselect analytic account with project
Installation
============
Use Odoo normal module installation procedure to install
``hr_expense_analytic_account_preselect_with_project``.
Known issues / Roadmap
======================
None yet.
Bug Tracker
===========
Bugs are tracked on `our issues website <https://github.com/elabore-coop/hr-tools/issues>`_. In case of
trouble, please check there if your issue has already been
reported. If you spotted it first, help us smashing it by providing a
detailed and welcomed feedback.
Credits
=======
Contributors
------------
* Clément Thomas
Funders
-------
The development of this module has been financially supported by:
* Elabore (https://elabore.coop)
Maintainer
----------
This module is maintained by Elabore.

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -0,0 +1,37 @@
# Copyright 2023 Stéphan Sainléger (Elabore)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "hr_expense_analytic_account_preselect_with_project",
"version": "14.0.0.0.0",
"author": "Elabore",
"website": "https://elabore.coop",
"maintainer": "Clément Thomas",
"license": "AGPL-3",
"category": "Tools",
"summary": "Provide indication that attendance are effectively worked periods or not",
# any module necessary for this one to work correctly
"depends": [
"base",
"hr_expense",
],
"qweb": [
# "static/src/xml/*.xml",
],
"external_dependencies": {
"python": [],
},
# always loaded
"data": [
"views/hr_expense_views.xml",
],
# 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,
}

View File

@@ -0,0 +1 @@
This directory should contain the *.po for Odoo translation.

View File

@@ -0,0 +1 @@
from . import hr_expense

View File

@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
from odoo import fields, models, api
class HrExpense(models.Model):
_inherit = "hr.expense"
project_id = fields.Many2one('project.project', string="Projet", required=True)
@api.onchange('project_id')
def set_analytic_account(self):
self.analytic_account_id = self.project_id.analytic_account_id

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="hr_expense_view_form_analytic_account_preselect_with_project" model="ir.ui.view">
<field name="name">hr.expense.view.form.analytic.account.preselect.with.project</field>
<field name="model">hr.expense</field>
<field name="inherit_id" ref="hr_expense.hr_expense_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='analytic_account_id']" position="before">
<field name="project_id" />
</xpath>
</field>
</record>
</odoo>

View File

@@ -1,30 +1,27 @@
===================================== ==============================
hr_employee_stats_sheet_lunch_voucher hr_expense_report_merge_attachment
===================================== ==============================
Summary Merge attachments in expense report.
=======
Description
===========
Managed attachment types :
* PDF
* Images
Installation Installation
============ ============
Use Odoo normal module installation procedure to install Use Odoo normal module installation procedure to install
``hr_employee_stats_sheet_lunch_voucher``. ``hr_expense_report_merge_attachment``.
Known issues / Roadmap Known issues / Roadmap
====================== ======================
None yet. None yet.
Bug Tracker Bug Tracker
=========== ===========
Bugs are tracked on `our issues website <https://github.com/elabore-coop/hr_employee_stats_sheet_lunch_voucher/issues>`_. In case of Bugs are tracked on `our issues website <https://github.com/elabore-coop/hr-tools/issues>`_. In case of
trouble, please check there if your issue has already been trouble, please check there if your issue has already been
reported. If you spotted it first, help us smashing it by providing a reported. If you spotted it first, help us smashing it by providing a
detailed and welcomed feedback. detailed and welcomed feedback.
@@ -35,7 +32,7 @@ Credits
Contributors Contributors
------------ ------------
* `Elabore <mailto:laetitia.dacosta@elabore.coop>` * Clément Thomas
Funders Funders
------- -------
@@ -47,4 +44,4 @@ The development of this module has been financially supported by:
Maintainer Maintainer
---------- ----------
This module is maintained by Elabore. This module is maintained by Elabore.

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import controllers

View File

@@ -1,25 +1,27 @@
# Copyright 2025 Elabore () # Copyright 2023 Stéphan Sainléger (Elabore)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "timesheet_timesheet_analysis_report", "name": "hr_expense_report_merge_attachment",
"version": "16.0.1.0.0", "version": "14.0.0.0.0",
"author": "Elabore", "author": "Elabore",
"website": "https://elabore.coop", "website": "https://elabore.coop",
"maintainer": "Elabore", "maintainer": "Clément Thomas",
"license": "AGPL-3", "license": "AGPL-3",
"category": "HR", "category": "Tools",
"summary": "add a timesheet_id relation to timesheet.analysis.report model", "summary": "Merge attachments in expense report",
# any module necessary for this one to work correctly # any module necessary for this one to work correctly
"depends": [ "depends": [
"base","hr_timesheet", "hr_expense",
],
"qweb": [
], ],
"qweb": [],
"external_dependencies": { "external_dependencies": {
"python": [], "python": [],
}, },
# always loaded # always loaded
"data": [], "data": [
],
# only loaded in demonstration mode # only loaded in demonstration mode
"demo": [], "demo": [],
"js": [], "js": [],

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import main

View File

@@ -0,0 +1,85 @@
import odoo.addons.web.controllers.main as main
import ast
import base64
import io
from odoo.tools.pdf import OdooPdfFileReader, OdooPdfFileWriter
import PyPDF2
import logging
from odoo import http
from reportlab.pdfgen import canvas
from reportlab.lib.utils import ImageReader
from reportlab.lib.pagesizes import letter, A4
try:
from pillow_heif import register_heif_opener
register_heif_opener()
except ImportError:
pass
logger = logging.getLogger(__name__)
class Extension(main.ReportController):
@http.route(['/report/download'], type='http', auth="user")
def report_download(self, data, token, context=None):
"""
In case of hr expense sheet report : merge PDF with other attachments
"""
res = super(Extension,self).report_download(data, token, context)
if "hr_expense.report_expense_sheet" in ast.literal_eval(data)[0]: #check if we are generating expense sheet report pdf
writer = OdooPdfFileWriter() #Open a file writer to create new PDF
# Open main pdf and read it and write it page by page in new pdf
main_pdf_reader = OdooPdfFileReader(io.BytesIO(res.data), strict=False)
for n in range(main_pdf_reader.getNumPages()):
writer.addPage(main_pdf_reader.getPage(n))
# Parse data (last char after "/") to get id of current sheet
expense_sheet_id = int(ast.literal_eval(data)[0].split('/')[-1])
# Get ids of related expenses
expense_ids = [e.id for e in http.request.env['hr.expense.sheet'].browse(expense_sheet_id).expense_line_ids]
# Get related attachments
attachments = http.request.env['ir.attachment'].search([('res_id','in',expense_ids),('res_model','=','hr.expense')])
# Open each attachments, and write it page by page in new pdf
for att in attachments:
if att.mimetype == "application/pdf":
try:
attachment_reader = OdooPdfFileReader(io.BytesIO(base64.b64decode(att.datas)), strict=False)
for n in range(attachment_reader.getNumPages()):
writer.addPage(attachment_reader.getPage(n))
except PyPDF2.utils.PdfReadError: # Case of non-pdf attachments
logger.info('Attachment %s cannot be merged in expense report'%(att.name,))
elif 'image/' in att.mimetype:
try:
from PIL import Image as PilImage
raw = base64.b64decode(att.datas)
pil_img = PilImage.open(io.BytesIO(raw))
if pil_img.mode not in ('RGB', 'RGBA'):
pil_img = pil_img.convert('RGB')
jpeg_buffer = io.BytesIO()
pil_img.save(jpeg_buffer, format='JPEG')
jpeg_buffer.seek(0)
packet = io.BytesIO()
can = canvas.Canvas(packet)
img = ImageReader(jpeg_buffer)
can.drawImage(img, 0, 0, A4[0]*0.9, A4[1]*0.9, preserveAspectRatio=True)
can.save()
packet.seek(0)
attachment_reader = OdooPdfFileReader(packet)
writer.addPage(attachment_reader.getPage(0))
except Exception:
logger.info('Attachment %s cannot be merged in expense report', att.name)
# Write new pdf to res.data
buffer = io.BytesIO()
writer.write(buffer)
pdf_content = buffer.getvalue()
res.data = pdf_content
return res

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -0,0 +1,36 @@
# Copyright 2023 Stéphan Sainléger (Elabore)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "hr_expense_specific_journal",
"version": "14.0.1.0.0",
"author": "Elabore",
"website": "https://elabore.coop",
"maintainer": "Clément Thomas",
"license": "AGPL-3",
"category": "Tools",
"summary": "Allow user to only select expense journal in expenses",
# any module necessary for this one to work correctly
"depends": [
"hr_expense","account"
],
"qweb": [
],
"external_dependencies": {
"python": [],
},
# always loaded
"data": [
'views/account_journal_views.xml',
'views/hr_expense_sheet_views.xml'
],
# 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,
}

View File

@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_expense_specific_journal
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-11 07:29+0000\n"
"PO-Revision-Date: 2023-10-11 07:29+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: hr_expense_specific_journal
#: model:ir.model.fields,field_description:hr_expense_specific_journal.field_account_journal__display_name
msgid "Display Name"
msgstr "Afficher Nom"
#. module: hr_expense_specific_journal
#: model_terms:ir.ui.view,arch_db:hr_expense_specific_journal.view_account_journal_form_hr_expense_specific_journal_inherit
msgid "Expense journal"
msgstr "Journal des notes de frais"
#. module: hr_expense_specific_journal
#: model:ir.model.fields,field_description:hr_expense_specific_journal.field_account_journal__id
msgid "ID"
msgstr ""
#. module: hr_expense_specific_journal
#: model:ir.model.fields,field_description:hr_expense_specific_journal.field_account_journal__is_expense_journal
msgid "Is expense journal"
msgstr "Est un journal de notes de frais"
#. module: hr_expense_specific_journal
#: model:ir.model,name:hr_expense_specific_journal.model_account_journal
msgid "Journal"
msgstr ""
#. module: hr_expense_specific_journal
#: model:ir.model.fields,field_description:hr_expense_specific_journal.field_account_journal____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

View File

@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from . import account_journal
from . import hr_expense

View File

@@ -0,0 +1,6 @@
from odoo import models, fields
class AccountJournal(models.Model):
_inherit = 'account.journal'
is_expense_journal = fields.Boolean('Is expense journal')

View File

@@ -0,0 +1,13 @@
from odoo import models, fields, api
class HrExpenseSheet(models.Model):
_inherit = 'hr.expense.sheet'
@api.model
def _default_journal_id(self):
""" The journal is determining the company of the accounting entries generated from expense. We need to force journal company and expense sheet company to be the same. """
default_company_id = self.default_get(['company_id'])['company_id']
journal = self.env['account.journal'].search([('company_id', '=', default_company_id), ('is_expense_journal','=',True)], limit=1)
return journal.id
journal_id = fields.Many2one(default=_default_journal_id)

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_account_journal_form_hr_expense_specific_journal_inherit" model="ir.ui.view">
<field name="name">view.account.journal.form.hr.expense.specific.journal.inherit</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.view_account_journal_form" />
<field name="arch" type="xml">
<xpath expr="//group[@name='group_alias_edit']" position="after">
<group string="Expense journal">
<field name="is_expense_journal" />
</group>
</xpath>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="hr_expense_sheet_form_view_hr_expense_specific_journal_inherit" model="ir.ui.view">
<field name="name">hr.expense.sheet.form.hr.expense.specific.journal.inherit</field>
<field name="model">hr.expense.sheet</field>
<field name="inherit_id" ref="hr_expense.view_hr_expense_sheet_form"/>
<field name="arch" type="xml">
<field name="journal_id" position="attributes">
<attribute name="domain">[('is_expense_journal','=',True)]</attribute>
</field>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,80 @@
===================
HR Luncheon Voucher
===================
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github
:target: https://github.com/elabore-coop/hr-tools
:alt: elabore/hr-tools
|badge1| |badge2| |badge3|
This module allows the management of Luncheon Vouchers attribution and distribution.
Employees can indicate which days are not concerned by luncheon vouchers.
HR managers can ajust the number of luncheon vouchers to distribute, and follow each employee credit.
Installation
============
Use Odoo normal module installation procedure to install ``hr_luncheon_voucher``.
Configuration
=============
1. Go to ``Configuration > Technical > Calendar > Meeting Types`` and define the meeting categories which cancel the daily luncheon voucher distribution.
2. Go to ``Configuration > General Settings > Employees`` and define if employees need to work the whole day to get a luncheon voucher.
3. Go to ``Employees`` and define for each employee the default number of luncheon vouchers to distribute in each distribution campaign.
4. Go to ``Configuration > Technical > Resource > Working Times`` and create Working Times for each combination of attendance that you have in your company. Do not forget to indicate which period are effectively attended.
Use
===
- when an calendar event makes the luncheon voucher distribution cancelled (Off-site or free lunch for instance), add the corresponding category to the event.
- for each distribution period, the HR manager should:
- go in ``Employees`` tree view
- select all the employees concerned by luncheon vouchers distribution
- click on header button ``Generate luncheon vouchers allocation``
- Fill the wizard form
- a voucher allocation request is created for each employee
- HR manager confirms an allocation request when the figures are confirmed
- HR manager marks the requests as "Distributed" when the vouchers has been effectively distributed
- HR manager can correct the allocation requests with ``Back to draft`` button
- employees' luncheon voucher counters are updated considering the vouchers acquired, dued and distributed at each campaign.
**Attribution rules:**
- a luncheon voucher is acquired for a working day if:
- the employee worked on one or all the attendances of the day (depending if option ``Half working days cancel luncheon vouchers`` is True or not)
- there is no meeting which cancel the voucher during that day (``Site off`` or ``Free lunch`` meeting for instance)
- an attendance is considered as worked as long as there is no leave on the whole attendance time slot
Known issues / Roadmap
======================
None yet.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/elabore-coop/hr-tools/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
Contributors
------------
- Stéphan Sainléger <https://github.com/stephansainleger>
Funders
-------
The development of this module has been financially supported by:
- Elabore (https://elabore.coop)
- Amaco (https://amaco.org)
Maintainer
----------
This module is maintained by ELABORE.

View File

@@ -1 +1,2 @@
from . import models from . import models
from . import wizard

View File

@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
{
"name": "HR Luncheon Voucher",
"category": "Human Resources",
"version": "14.0.2.0.1",
"summary": "Manage luncheon vouchers credit and distribution",
"author": "Elabore",
"website": "https://elabore.coop/",
"installable": True,
"application": True,
"auto_install": False,
"depends": [
"base",
"calendar",
"hr",
"hr_effective_attendance_period",
"hr_holidays",
"resource",
],
"data": [
"security/ir.model.access.csv",
"views/event_type.xml",
"views/hr_employee_views.xml",
"views/hr_lv_allocation_views.xml",
"views/res_config_settings_views.xml",
"views/menus.xml",
"wizard/generate_lv_allocations_wizard.xml",
"data/event_type_data.xml",
],
"qweb": [],
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<odoo>
<data>
<record id="categ_meet_free_lunch" model="calendar.event.type">
<field name="name">Free lunch</field>
<field name="ref">categ_meet_free_lunch</field>
<field name="remove_luncheon_voucher">1</field>
</record>
<record id="categ_meet_offsite" model="calendar.event.type">
<field name="name">Off-site</field>
<field name="ref">categ_meet_offsite</field>
<field name="remove_luncheon_voucher">1</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,347 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_luncheon_voucher
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-28 12:49+0000\n"
"PO-Revision-Date: 2023-04-28 12:49+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: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.view_employee_form_lv
msgid "Acquired"
msgstr "Acquis"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__number_acquired_lv
msgid "Acquired Vouchers"
msgstr "Tickets Acquis"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_form
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_tree
msgid "Adjust distribution"
msgstr "Ajuster la distribution"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_form
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_tree
msgid "Back to draft"
msgstr "Brouillon"
#. module: hr_luncheon_voucher
#: model:ir.model,name:hr_luncheon_voucher.model_hr_employee_base
msgid "Basic Employee"
msgstr "Employé basique"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.lv_allocations_requests_wizard
msgid "Cancel"
msgstr "Annuler"
#. module: hr_luncheon_voucher
#: model:ir.model,name:hr_luncheon_voucher.model_res_company
msgid "Companies"
msgstr "Sociétés"
#. module: hr_luncheon_voucher
#: model:ir.model,name:hr_luncheon_voucher.model_res_config_settings
msgid "Config Settings"
msgstr "Paramètres de config"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_form
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_tree
msgid "Confirm"
msgstr "Confirmer"
#. module: hr_luncheon_voucher
#: model:ir.model.fields.selection,name:hr_luncheon_voucher.selection__hr_lv_allocation__state__confirmed
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_search
msgid "Confirmed"
msgstr "Confirmé"
#. module: hr_luncheon_voucher
#: model:ir.actions.act_window,name:hr_luncheon_voucher.lv_allocations_requests_wizard_action
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.lv_allocations_requests_wizard
msgid "Create Luncheon Vouchers allocations requests"
msgstr "Créer demandes d'allocation de Tickets Restaurants"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.lv_allocations_requests_wizard
msgid "Create allocations requests"
msgstr "Créer les demandes d'allocation"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_generate_lv_allocation_requests__create_uid
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__create_uid
msgid "Created by"
msgstr "Créé par"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_generate_lv_allocation_requests__create_date
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__create_date
msgid "Created on"
msgstr "Créé le"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee__default_monthly_lv
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_base__default_monthly_lv
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_public__default_monthly_lv
msgid "Default monthly distribution"
msgstr ""
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_calendar_event_type__display_name
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_generate_lv_allocation_requests__display_name
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_base__display_name
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__display_name
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_res_company__display_name
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_res_config_settings__display_name
msgid "Display Name"
msgstr "Nom affiché"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_form
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_tree
msgid "Distribute Vouchers"
msgstr "Tickets distribués"
#. module: hr_luncheon_voucher
#: model:ir.model.fields.selection,name:hr_luncheon_voucher.selection__hr_lv_allocation__state__distributed
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_search
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.view_employee_form_lv
msgid "Distributed"
msgstr "Distribué"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__number_distributed_lv
msgid "Distributed Vouchers"
msgstr "Tickets distribués"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee__distributed_lv
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_base__distributed_lv
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_public__distributed_lv
msgid "Distributed luncheon vouchers"
msgstr "Tickets resto distribués"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_generate_lv_allocation_requests__distrib_campaign_name
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__distrib_campaign_name
msgid "Distribution campaign"
msgstr "Campagne de distribution"
#. module: hr_luncheon_voucher
#: model:ir.model.fields.selection,name:hr_luncheon_voucher.selection__hr_lv_allocation__state__draft
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_search
msgid "Draft"
msgstr "Brouillon"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.view_employee_form_lv
msgid "Dued"
msgstr "Dû"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__number_dued_lv
msgid "Dued Vouchers"
msgstr "Tickets dûs"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__employee_id
msgid "Employee"
msgstr "Employé"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.res_config_settings_lv_form
msgid "Employee Luncheon Vouchers"
msgstr "Tickets Restaurant de l'employé"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_generate_lv_allocation_requests__date_to
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__date_to
msgid "End Date"
msgstr "Date de fin"
#. module: hr_luncheon_voucher
#: model:ir.model,name:hr_luncheon_voucher.model_calendar_event_type
msgid "Event Meeting Type"
msgstr "Type d'événement réunion"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.view_employee_tree_lv
msgid "Generate Luncheon Vouchers Allocations"
msgstr "Générer les allocations de Tickets Restaurants"
#. module: hr_luncheon_voucher
#: model:ir.model,name:hr_luncheon_voucher.model_generate_lv_allocation_requests
msgid "Generate Luncheon Vouchers Allocations Requests"
msgstr "Générer les demandes d'allocations de Tickets Restaurants"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_res_company__hr_half_day_cancels_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_res_config_settings__hr_half_day_cancels_voucher
msgid "Half working days cancel luncheon vouchers"
msgstr "Une demi-journée travaillée annule les tickets restaurants."
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_calendar_event_type__id
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_generate_lv_allocation_requests__id
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_base__id
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__id
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_res_company__id
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_res_config_settings__id
msgid "ID"
msgstr ""
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_calendar_event_type____last_update
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_generate_lv_allocation_requests____last_update
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_base____last_update
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation____last_update
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_res_company____last_update
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_res_config_settings____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_generate_lv_allocation_requests__write_uid
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__write_uid
msgid "Last Updated by"
msgstr "Dernière mise à jour par"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_generate_lv_allocation_requests__write_date
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__write_date
msgid "Last Updated on"
msgstr "Dernière mise à jour le"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.view_employee_form_lv
msgid "Luncheon Vouchers"
msgstr "Tickets Restaurants"
#. module: hr_luncheon_voucher
#: model:ir.model,name:hr_luncheon_voucher.model_hr_lv_allocation
msgid "Luncheon Vouchers Allocation"
msgstr "Allocation de Tickets Restaurants"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.res_config_settings_lv_form
msgid "Luncheon Vouchers Half-day Cancel"
msgstr "Annulation Tickets Restaurants sur une demi-journée"
#. module: hr_luncheon_voucher
#: model:ir.ui.menu,name:hr_luncheon_voucher.menu_hr_lv_allocations
msgid "Luncheon vouchers"
msgstr "Ticket restaurants"
#. module: hr_luncheon_voucher
#: model:ir.actions.act_window,name:hr_luncheon_voucher.act_lv_allocations
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_search
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_tree
msgid "Luncheon vouchers allocations"
msgstr "Allocations de Tickets restaurant"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_form
msgid "Luncheon vouchers calculation"
msgstr "Calculs des tickets restaurants"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee__lv_allocations_ids
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_base__lv_allocations_ids
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_public__lv_allocations_ids
msgid "Lv Allocations"
msgstr "Allocations TR"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__name
msgid "Name"
msgstr "Nom"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.lv_allocations_requests_wizard
msgid "Period to consider"
msgstr "Période du calcul"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_calendar_event_type__ref
msgid "Reference"
msgstr "Référence"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.view_employee_form_lv
msgid "Refresh Luncheon Vouchers"
msgstr "Rafraîchir les Tickets Restaurants"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee__dued_lv
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_base__dued_lv
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_public__dued_lv
msgid "Remaining luncheon vouchers"
msgstr ""
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_calendar_event_type__remove_luncheon_voucher
msgid "Remove luncheon voucher"
msgstr "Supprimer le ticket"
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.hr_lv_allocation_form
msgid "Request context"
msgstr "Contexte de la requête"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_generate_lv_allocation_requests__date_from
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__date_from
msgid "Start Date"
msgstr "Date de début"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__state
msgid "Status"
msgstr "État"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,help:hr_luncheon_voucher.field_hr_lv_allocation__state
msgid ""
"The status is set to 'Draft', when an allocation request is created. The "
"status is 'Confirmed', when an allocation request is confirmed by HR "
"manager. The status is 'Distributed', when the luncheon vouchers have been "
"distributed."
msgstr ""
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee__total_acquired_lv
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_base__total_acquired_lv
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_employee_public__total_acquired_lv
msgid "Total allocated luncheon vouchers"
msgstr ""
#. module: hr_luncheon_voucher
#: model_terms:ir.ui.view,arch_db:hr_luncheon_voucher.res_config_settings_lv_form
msgid ""
"Voucher is acquired only if the employee worked during all his\n"
" attendance."
msgstr ""
#. module: hr_luncheon_voucher
#: model:ir.model.fields,help:hr_luncheon_voucher.field_hr_lv_allocation__lv_balance
msgid ""
"Vouchers available after distribution. Dued vouchers - Distributed vouchers"
msgstr "Tickets disponibles après distribution. = Tickets dûs - tickets distribués"
#. module: hr_luncheon_voucher
#: model:ir.model.fields,field_description:hr_luncheon_voucher.field_hr_lv_allocation__lv_balance
msgid "Vouchers balance"
msgstr "Solde TR"

View File

@@ -0,0 +1,5 @@
from . import calendar_event_type
from . import hr_employee
from . import hr_lv_allocation
from . import res_company
from . import res_config_settings

View File

@@ -0,0 +1,17 @@
from odoo import fields, models
class MeetingType(models.Model):
_inherit = "calendar.event.type"
ref = fields.Char(
string="Reference",
copy=False,
store=True,
)
remove_luncheon_voucher = fields.Boolean(
string="Remove luncheon voucher",
copy=True,
store=True,
)

View File

@@ -0,0 +1,83 @@
from xml.dom.minicompat import EmptyNodeList
from odoo import fields, models, api
class HrEmployeeBase(models.AbstractModel):
_inherit = "hr.employee.base"
lv_allocations_ids = fields.One2many("hr.lv.allocation", "employee_id")
total_acquired_lv = fields.Integer(
string="Total allocated luncheon vouchers", store=True, copy=False
)
distributed_lv = fields.Integer(
string="Distributed luncheon vouchers", store=True, copy=False
)
dued_lv = fields.Integer(
string="Remaining luncheon vouchers", store=True, copy=False
)
default_monthly_lv = fields.Integer(
string="Default monthly distribution", store=True, copy=True
)
def refresh_lv_values(self):
for record in self:
record._compute_total_acquired_lv()
record._compute_distributed_lv()
record._compute_dued_lv()
def _compute_total_acquired_lv(self):
for record in self:
allocations = self.env["hr.lv.allocation"].search(
[("employee_id", "=", record.id), ("state", "=", ["confirmed", "distributed"])]
)
record.total_acquired_lv = sum(allocations.mapped("number_acquired_lv"))
def _compute_distributed_lv(self):
for record in self:
allocations = self.env["hr.lv.allocation"].search(
[("employee_id", "=", record.id), ("state", "=", "distributed")]
)
record.distributed_lv = sum(allocations.mapped("number_distributed_lv"))
def _compute_dued_lv(self):
for record in self:
record.dued_lv = record.total_acquired_lv - record.distributed_lv
def generate_mass_lv_allocation(self, values):
for record in self:
record.generate_lv_allocation(values)
def generate_lv_allocation(self, values):
self.ensure_one()
values["employee_id"] = self.id
values["name"] = values["distrib_campaign_name"] + " - " + self.name
self.env["hr.lv.allocation"].create(values)
def action_lv_allocations(self):
action = self.env["ir.actions.act_window"]._for_xml_id("hr_luncheon_voucher.act_lv_allocations")
action['context'] = {
'search_default_employee_id': self.id,
'default_employee_id': self.id,
}
action['domain'] = [('employee_id', '=', self.id)]
return action
def action_lv_allocations_requests_wizard(self):
action = self.env["ir.actions.act_window"]._for_xml_id(
"hr_luncheon_voucher.lv_allocations_requests_wizard_action"
)
ctx = dict(self.env.context)
ctx["active_ids"] = self.ids
action["context"] = ctx
return action
@api.model
def _name_search(self, name='', args=None, operator='ilike', limit=100, name_get_uid=None):
"""
On lv allocation, allow employee search on all companies
"""
if self.env.context.get('search_all_campanies'):
return super(HrEmployeeBase, self.sudo())._name_search(name, args, operator, limit, name_get_uid)
return super(HrEmployeeBase, self)._name_search(name, args, operator, limit, name_get_uid)

View File

@@ -0,0 +1,186 @@
from datetime import datetime, timedelta, time
from dateutil.rrule import rrule, DAILY
from pytz import UTC
from odoo import fields, models, api
class LuncheonVouchersAllocation(models.Model):
_name = "hr.lv.allocation"
_description = "Luncheon Vouchers Allocation"
name = fields.Char('Name')
distrib_campaign_name = fields.Char('Distribution campaign')
state = fields.Selection(
[
("draft", "Draft"),
("confirmed", "Confirmed"),
("distributed", "Distributed"),
],
string="Status",
readonly=True,
copy=False,
default="draft",
help="The status is set to 'Draft', when an allocation request is created. The status is 'Confirmed', when an allocation request is confirmed by HR manager. The status is 'Distributed', when the luncheon vouchers have been distributed.",
)
date_from = fields.Datetime(
string="Start Date",
store=True,
readonly=False,
copy=False,
states={
"confirmed": [("readonly", True)],
"distributed": [("readonly", True)],
},
)
date_to = fields.Datetime(
string="End Date",
store=True,
readonly=False,
copy=False,
states={
"confirmed": [("readonly", True)],
"distributed": [("readonly", True)],
},
)
employee_id = fields.Many2one(
"hr.employee",
store=True,
string="Employee",
index=True,
readonly=False,
ondelete="restrict",
states={
"confirmed": [("readonly", True)],
"distributed": [("readonly", True)],
},
)
number_acquired_lv = fields.Integer(
string="Acquired Vouchers",
store=True,
readonly=False,
states={
"confirmed": [("readonly", True)],
"distributed": [("readonly", True)],
},
)
number_dued_lv = fields.Integer(
string="Dued Vouchers",
store=True,
readonly=False,
states={
"confirmed": [("readonly", True)],
"distributed": [("readonly", True)],
},
)
number_distributed_lv = fields.Integer(
string="Distributed Vouchers",
store=True,
readonly=False,
states={
"confirmed": [("readonly", False)],
"distributed": [("readonly", True)],
},
)
lv_balance = fields.Integer('Vouchers balance', compute="_get_lv_balance", help="Vouchers available after distribution. Dued vouchers - Distributed vouchers")
@api.depends("number_dued_lv", "number_distributed_lv")
def _get_lv_balance(self):
for allocation in self:
allocation.lv_balance = allocation.number_dued_lv - allocation.number_distributed_lv
@api.model_create_multi
def create(self, values):
res = super(LuncheonVouchersAllocation, self).create(values)
res._calculate_number_acquired_lv()
res._calculate_number_dued_lv()
res._default_number_distributed_lv()
return res
@api.depends("employee_id")
def _default_number_distributed_lv(self):
for record in self:
record.number_distributed_lv = record.employee_id.default_monthly_lv
def _has_cancelling_voucher_event(self, day):
category_no_voucher_ids = self.env["calendar.event.type"].search([("remove_luncheon_voucher", "=", True)])
events = self.env["calendar.event"].search(
[
("categ_ids", "in", category_no_voucher_ids.ids),
("partner_ids", "in", self.employee_id.user_id.partner_id.id)
]
)
day_start = fields.Datetime.to_datetime(day.date())
day_end = fields.Datetime.to_datetime(day.date()) + timedelta(hours=24)
cancelling_events = events.filtered(lambda x: not((x.start < day_start) and (x.stop <= day_start)) and not((x.start >= day_end) and (x.stop > day_end)) )
if len(cancelling_events) > 0:
return True
else:
return False
def _calculate_number_acquired_lv(self):
nb_eligible_days = 0
dfrom = datetime.combine(fields.Date.from_string(self.date_from), time.min).replace(tzinfo=UTC)
dto = datetime.combine(fields.Date.from_string(self.date_to), time.max).replace(tzinfo=UTC)
period_days = rrule(DAILY, dfrom, until=dto)
calendar_resource = self.employee_id.resource_calendar_id
for day in period_days:
# Check if this days is a working day
if not calendar_resource.is_working_day(day):
continue
# The employee should work this day but...
if self.env.company.hr_half_day_cancels_voucher and not calendar_resource.is_full_working_day(day):
# The luncheon voucher is acquired only if the employee has worked the entire day
continue
# Check leaves
if not calendar_resource.is_worked_day(self.employee_id, day):
continue
# The employee has worked this day but...
if self.env.company.hr_half_day_cancels_voucher and not calendar_resource.all_attendances_worked(self.employee_id.resource_id, day):
# The luncheon voucher is acquired only if the employee has worked the entire day
continue
# Check there is no event cancelling the voucher
if self._has_cancelling_voucher_event(day):
continue
# All checks passed, the days is eligible for a voucher
nb_eligible_days += 1
self.number_acquired_lv = nb_eligible_days
def _calculate_number_dued_lv(self):
for record in self:
if record.state == "distributed":
record.number_dued_lv = record.employee_id.dued_lv
else:
record.number_dued_lv = (
record.employee_id.dued_lv + record.number_acquired_lv
)
def confirm_allocation(self):
for record in self:
if record.state == "draft":
record.state = "confirmed"
record.employee_id._compute_total_acquired_lv()
record.employee_id._compute_dued_lv()
def back_to_draft(self):
for record in self:
if record.state in ["confirmed","distributed"]:
record.state = "draft"
record.employee_id._compute_total_acquired_lv()
record.employee_id._compute_distributed_lv()
record.employee_id._compute_dued_lv()
def distribute_allocation(self):
for record in self:
if record.state == "confirmed":
record.state = "distributed"
record.employee_id._compute_distributed_lv()
record.employee_id._compute_dued_lv()
def adjust_distribution(self):
for record in self:
for record in self:
if record.state == "draft":
record.number_distributed_lv = record.employee_id.dued_lv + record.number_acquired_lv

View File

@@ -0,0 +1,7 @@
from odoo import fields, models
class Company(models.Model):
_inherit = 'res.company'
hr_half_day_cancels_voucher = fields.Boolean(string="Half working days cancel luncheon vouchers")

View File

@@ -0,0 +1,8 @@
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
hr_half_day_cancels_voucher = fields.Boolean(string="Half working days cancel luncheon vouchers", related="company_id.hr_half_day_cancels_voucher", readonly=False)

View File

@@ -0,0 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_lv_allocation_user,access_lv_allocation_user,model_hr_lv_allocation,hr.group_hr_user,1,0,0,0
access_lv_allocation_manager,access_lv_allocation_manager,model_hr_lv_allocation,hr.group_hr_manager,1,1,1,1
access_lv_allocation_wizard_user,access_lv_allocation_wizard_user,model_generate_lv_allocation_requests,hr.group_hr_user,1,0,0,0
access_lv_allocation_wizard_manager,access_lv_allocation_wizard_manager,model_generate_lv_allocation_requests,hr.group_hr_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_lv_allocation_user access_lv_allocation_user model_hr_lv_allocation hr.group_hr_user 1 0 0 0
3 access_lv_allocation_manager access_lv_allocation_manager model_hr_lv_allocation hr.group_hr_manager 1 1 1 1
4 access_lv_allocation_wizard_user access_lv_allocation_wizard_user model_generate_lv_allocation_requests hr.group_hr_user 1 0 0 0
5 access_lv_allocation_wizard_manager access_lv_allocation_wizard_manager model_generate_lv_allocation_requests hr.group_hr_manager 1 1 1 1

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_event_type_luncheonvoucher_tree" model="ir.ui.view">
<field name="name">event.type.luncheonvoucher</field>
<field name="model">calendar.event.type</field>
<field name="inherit_id" ref="calendar.view_calendar_event_type_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="remove_luncheon_voucher" />
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_employee_form_lv" model="ir.ui.view">
<field name="name">hr.employee.form.lv</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form" />
<field name="arch" type="xml">
<header position="inside">
<button type="object" name="refresh_lv_values" string="Refresh Luncheon Vouchers" class="btn-secundary" />
</header>
<xpath expr="//div[@name='button_box']" position="inside">
<button type="object" name="action_lv_allocations" class="oe_stat_button" icon="fa-ticket">
<field name="total_acquired_lv" widget="statinfo" string="Acquired" />
</button>
<button type="object" name="action_lv_allocations" class="oe_stat_button" icon="fa-ticket">
<field name="distributed_lv" widget="statinfo" string="Distributed" />
</button>
<button type="object" name="action_lv_allocations" class="oe_stat_button" icon="fa-ticket">
<field name="dued_lv" widget="statinfo" string="Dued" />
</button>
</xpath>
<xpath expr="//page[@name='hr_settings']/group" position="inside">
<group name="luncheon_vouchers" string="Luncheon Vouchers">
<field name="default_monthly_lv" />
<field name="lv_allocations_ids" />
</group>
</xpath>
</field>
</record>
<record id="view_employee_tree_lv" model="ir.ui.view">
<field name="name">view_employee_tree_lv</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_tree" />
<field name="arch" type="xml">
<xpath expr="//tree" position="inside">
<header>
<button type="object" name="action_lv_allocations_requests_wizard" string="Generate Luncheon Vouchers Allocations" class="btn-primary" />
</header>
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_lv_allocation_search" model="ir.ui.view">
<field name="name">hr.lv.allocation.search</field>
<field name="model">hr.lv.allocation</field>
<field name="arch" type="xml">
<search string="Luncheon vouchers allocations">
<field name="state" />
<field name="employee_id" context="{'search_all_campanies':True}" />
<field name="distrib_campaign_name" />
<filter name="draft" string="Draft" domain="[('state', '=', 'draft')]" />
<filter name="confirmed" string="Confirmed" domain="[('state', '=', 'confirmed')]" />
<filter name="distributed" string="Distributed"
domain="[('state', '=', 'distributed')]" />
</search>
</field>
</record>
<record id="hr_lv_allocation_tree" model="ir.ui.view">
<field name="name">hr.lv.allocation.tree</field>
<field name="model">hr.lv.allocation</field>
<field name="arch" type="xml">
<tree string="Luncheon vouchers allocations">
<header>
<button type="object" name="confirm_allocation" string="Confirm"
class="btn-primary" />
<button type="object" name="distribute_allocation" string="Distribute Vouchers"
class="btn-primary" />
<button type="object" name="back_to_draft" string="Back to draft"
class="btn-secundary" />
<button type="object" name="adjust_distribution" string="Adjust distribution"
class="btn-secundary" />
</header>
<field name="distrib_campaign_name" />
<field name="employee_id" />
<field name="state" />
<field name="date_from" widget="date" />
<field name="date_to" widget="date" />
<field name="number_acquired_lv" />
<field name="number_dued_lv" />
<field name="number_distributed_lv" />
<field name="lv_balance" />
</tree>
</field>
</record>
<record id="hr_lv_allocation_form" model="ir.ui.view">
<field name="name">hr.lv.allocation.form</field>
<field name="model">hr.lv.allocation</field>
<field name="arch" type="xml">
<form string="">
<header>
<button type="object" name="confirm_allocation" string="Confirm"
class="btn-primary" attrs="{'invisible': [('state', '!=', 'draft')]}" />
<button type="object" name="distribute_allocation" string="Distribute Vouchers"
class="btn-primary" attrs="{'invisible': [('state', '!=', 'confirmed')]}" />
<button type="object" name="back_to_draft" string="Back to draft"
class="btn-secundary" attrs="{'invisible': [('state', '=', 'draft')]}" />
<button type="object" name="adjust_distribution" string="Adjust distribution"
class="btn-secundary" attrs="{'invisible': [('state', '!=', 'draft')]}" />
</header>
<sheet>
<h1>
<field name="name" readonly="1" />
</h1>
<group string="Request context">
<field name="distrib_campaign_name" />
<field name="employee_id" />
<field name="state" />
<field name="date_from" widget="date" />
<field name="date_to" widget="date" />
</group>
<group string="Luncheon vouchers calculation">
<field name="number_acquired_lv" />
<field name="number_dued_lv" />
<field name="number_distributed_lv" />
</group>
</sheet>
</form>
</field>
</record>
<record id="act_lv_allocations" model="ir.actions.act_window">
<field name="name">Luncheon vouchers allocations</field>
<field name="res_model">hr.lv.allocation</field>
<field name="view_mode">tree,form</field>
</record>
</odoo>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="menu_hr_lv_allocations" action="act_lv_allocations" parent="hr.menu_hr_employee_payroll" sequence="1" name="Luncheon vouchers" />
</odoo>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_lv_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.lv</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="99" />
<field name="inherit_id" ref="hr.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@name='employee_rights_setting_container']/.." position="inside">
<h2>Employee Luncheon Vouchers</h2>
<div class="row mt16 o_settings_container" name="employee_lv_container">
<div class="col-12 col-lg-6 o_setting_box" id="employee_lv_halfday_cancel"
title="Luncheon Vouchers Half-day Cancel">
<div class="o_setting_left_pane">
<field name="hr_half_day_cancels_voucher" />
</div>
<div class="o_setting_right_pane">
<label for="hr_half_day_cancels_voucher" />
<div class="text-muted" name="hr_presence_options_advanced">
Voucher is acquired only if the employee worked during all his
attendance.
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1 @@
from . import generate_lv_allocations_wizard

View File

@@ -0,0 +1,30 @@
from odoo import fields, models
class GenerateLVAllocationRequests(models.TransientModel):
_name = "generate.lv.allocation.requests"
_description = "Generate Luncheon Vouchers Allocations Requests"
distrib_campaign_name = fields.Char('Distribution campaign', required=True)
date_from = fields.Datetime(
string="Start Date",
required=True
)
date_to = fields.Datetime(
string="End Date",
required=True
)
def generate_lv_allocations(self):
values = {}
values["distrib_campaign_name"] = self.distrib_campaign_name
values["date_from"] = self.date_from
values["date_to"] = self.date_to
employees = self.env["hr.employee"].search(
[
("id", "in", self.env.context.get("active_ids")),
]
)
employees.generate_mass_lv_allocation(values)
# Open lv allocation tree view
return self.env["ir.actions.act_window"]._for_xml_id("hr_luncheon_voucher.act_lv_allocations")

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="lv_allocations_requests_wizard" model="ir.ui.view">
<field name="name">lv.allocations.requests.wizard</field>
<field name="model">generate.lv.allocation.requests</field>
<field name="arch" type="xml">
<form string="Create Luncheon Vouchers allocations requests">
<group name="dates" string="Period to consider">
<group>
<field name="distrib_campaign_name" />
<field name="date_from" widget="date" />
<field name="date_to" widget="date" />
</group>
</group>
<footer>
<button string="Create allocations requests" name="generate_lv_allocations" type="object" class="btn-primary" />
<button string="Cancel" class="btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="lv_allocations_requests_wizard_action" model="ir.actions.act_window">
<field name="name">Create Luncheon Vouchers allocations requests</field>
<field name="res_model">generate.lv.allocation.requests</field>
<field name="view_mode">form</field>
<field name="view_id" ref="lv_allocations_requests_wizard" />
<field name="target">new</field>
</record>
</data>
</odoo>

View File

@@ -1,2 +0,0 @@
*.*~
*pyc

View File

@@ -1,54 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_negative_leave
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-10-31 08:25+0000\n"
"PO-Revision-Date: 2025-10-31 08:25+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: hr_negative_leave
#: model:ir.model.fields,field_description:hr_negative_leave.field_hr_leave_type__allows_negative
msgid "Allow Negative Leaves"
msgstr "Autoriser les demandes et les soldes de congés négatifs"
#. module: hr_negative_leave
#: model_terms:ir.ui.view,arch_db:hr_negative_leave.hr_leave_type_negative_leave
msgid "Allow negative"
msgstr "Autoriser les soldes négatifs"
#. module: hr_negative_leave
#: model:ir.model.fields,help:hr_negative_leave.field_hr_leave_type__allows_negative
msgid ""
"If checked, users request can exceed the allocated days and balance can go "
"in negative."
msgstr ""
#. module: hr_negative_leave
#: model:ir.model.fields,field_description:hr_negative_leave.field_hr_leave_type__remaining_leaves_allowing_negative
msgid "Remaining Leaves when Negative Allowed"
msgstr ""
#. module: hr_negative_leave
#: model:ir.model.fields,field_description:hr_negative_leave.field_hr_leave__smart_search
#: model:ir.model.fields,field_description:hr_negative_leave.field_hr_leave_type__smart_search
msgid "Smart Search"
msgstr ""
#. module: hr_negative_leave
#: model:ir.model,name:hr_negative_leave.model_hr_leave
msgid "Time Off"
msgstr "Congés"
#. module: hr_negative_leave
#: model:ir.model,name:hr_negative_leave.model_hr_leave_type
msgid "Time Off Type"
msgstr "Type de congés"

Some files were not shown because too many files have changed in this diff Show More