Skip to content

Commit c861fb9

Browse files
yostashironobuQuartile
authored andcommitted
[ADD] hr_timesheet_sheet_prefill
1 parent 0122a7b commit c861fb9

15 files changed

Lines changed: 853 additions & 0 deletions

File tree

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
==========================
2+
HR Timesheet Sheet Prefill
3+
==========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:528bfd6a247f96983c9fb00731880be5135c94a4e7f79343b3988326f14bc219
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github
20+
:target: https://github.com/OCA/timesheet/tree/18.0/hr_timesheet_sheet_prefill
21+
:alt: OCA/timesheet
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/timesheet-18-0/timesheet-18-0-hr_timesheet_sheet_prefill
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds a "Prefill from Previous Period" button to the
32+
timesheet sheet form. When clicked, it copies the project/task
33+
combinations from the employee's most recent confirmed or approved
34+
timesheet sheet, creating empty placeholder lines for the current
35+
period.
36+
37+
**Table of contents**
38+
39+
.. contents::
40+
:local:
41+
42+
Use Cases / Context
43+
===================
44+
45+
This module depends on **HR Timesheet Sheet** (``hr_timesheet_sheet``),
46+
which provides the timesheet sheet model and workflow (draft, confirmed,
47+
approved).
48+
49+
It is designed for environments where employees work on a recurring set
50+
of projects and tasks across timesheet periods, reducing the manual
51+
effort of re-entering the same project/task lines each period.
52+
53+
Usage
54+
=====
55+
56+
1. Open a timesheet sheet in **new** or **draft** state.
57+
2. Click the **Prefill from Previous Period** button.
58+
3. The module looks up the employee's most recent confirmed or approved
59+
timesheet sheet and copies its project/task combinations as empty
60+
(zero-hour) lines into the current sheet.
61+
62+
Project/task combinations that already exist in the current sheet are
63+
skipped, so pressing the button multiple times will not create
64+
duplicates.
65+
66+
Bug Tracker
67+
===========
68+
69+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/timesheet/issues>`_.
70+
In case of trouble, please check there if your issue has already been reported.
71+
If you spotted it first, help us to smash it by providing a detailed and welcomed
72+
`feedback <https://github.com/OCA/timesheet/issues/new?body=module:%20hr_timesheet_sheet_prefill%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
73+
74+
Do not contact contributors directly about support or help with technical issues.
75+
76+
Credits
77+
=======
78+
79+
Authors
80+
-------
81+
82+
* Quartile
83+
84+
Contributors
85+
------------
86+
87+
- `Quartile <https://www.quartile.co>`__:
88+
89+
- Yoshi Tashiro
90+
- Aung Ko Ko Lin
91+
92+
Maintainers
93+
-----------
94+
95+
This module is maintained by the OCA.
96+
97+
.. image:: https://odoo-community.org/logo.png
98+
:alt: Odoo Community Association
99+
:target: https://odoo-community.org
100+
101+
OCA, or the Odoo Community Association, is a nonprofit organization whose
102+
mission is to support the collaborative development of Odoo features and
103+
promote its widespread use.
104+
105+
.. |maintainer-yostashiro| image:: https://github.com/yostashiro.png?size=40px
106+
:target: https://github.com/yostashiro
107+
:alt: yostashiro
108+
.. |maintainer-aungkokolin1997| image:: https://github.com/aungkokolin1997.png?size=40px
109+
:target: https://github.com/aungkokolin1997
110+
:alt: aungkokolin1997
111+
112+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
113+
114+
|maintainer-yostashiro| |maintainer-aungkokolin1997|
115+
116+
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/18.0/hr_timesheet_sheet_prefill>`_ project on GitHub.
117+
118+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2026 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "HR Timesheet Sheet Prefill",
5+
"version": "18.0.1.0.0",
6+
"category": "Human Resources",
7+
"summary": "Prefill timesheet sheet lines from the previous period",
8+
"license": "AGPL-3",
9+
"author": "Quartile, Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/timesheet",
11+
"installable": True,
12+
"depends": ["hr_timesheet_sheet"],
13+
"data": [
14+
"views/hr_timesheet_sheet_views.xml",
15+
],
16+
"maintainers": ["yostashiro", "aungkokolin1997"],
17+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * hr_timesheet_sheet_prefill
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 18.0+e\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2026-02-25 05:47+0000\n"
10+
"PO-Revision-Date: 2026-02-25 05:47+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: hr_timesheet_sheet_prefill
19+
#. odoo-python
20+
#: code:addons/hr_timesheet_sheet_prefill/models/hr_timesheet_sheet.py:0
21+
msgid "All project/task combinations from the previous period already exist."
22+
msgstr "前期間のプロジェクト/タスクの組み合わせはすべて既に存在しています。"
23+
24+
#. module: hr_timesheet_sheet_prefill
25+
#. odoo-python
26+
#: code:addons/hr_timesheet_sheet_prefill/models/hr_timesheet_sheet.py:0
27+
msgid "No previous confirmed or approved timesheet sheet found."
28+
msgstr "前期間の確認済みまたは承認済みのタイムシートレポートが見つかりませんでした。"
29+
30+
#. module: hr_timesheet_sheet_prefill
31+
#: model_terms:ir.ui.view,arch_db:hr_timesheet_sheet_prefill.hr_timesheet_sheet_form
32+
msgid "Prefill from Previous Period"
33+
msgstr "前期間から明細行を作成"
34+
35+
#. module: hr_timesheet_sheet_prefill
36+
#: model:ir.model,name:hr_timesheet_sheet_prefill.model_hr_timesheet_sheet
37+
msgid "Timesheet Sheet"
38+
msgstr "タイムシート"
39+
40+
#. module: hr_timesheet_sheet_prefill
41+
#. odoo-python
42+
#: code:addons/hr_timesheet_sheet_prefill/models/hr_timesheet_sheet.py:0
43+
msgid "You can only prefill a draft timesheet sheet."
44+
msgstr "ドラフトのタイムシートレポートのみ仮入力できます。"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import hr_timesheet_sheet
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2026 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import _, models
5+
from odoo.exceptions import UserError
6+
7+
8+
class Sheet(models.Model):
9+
_inherit = "hr_timesheet.sheet"
10+
11+
def action_prefill_from_previous(self):
12+
self.ensure_one()
13+
if self.state not in ("new", "draft"):
14+
raise UserError(_("You can only prefill a draft timesheet sheet."))
15+
previous_sheet = self.env["hr_timesheet.sheet"].search(
16+
[
17+
("employee_id", "=", self.employee_id.id),
18+
("id", "!=", self.id),
19+
("date_end", "<", self.date_start),
20+
("state", "in", ("confirm", "done")),
21+
],
22+
order="date_end desc",
23+
limit=1,
24+
)
25+
if not previous_sheet:
26+
raise UserError(
27+
_("No previous confirmed or approved timesheet sheet found.")
28+
)
29+
existing_keys = {(line.project_id, line.task_id) for line in self.timesheet_ids}
30+
unique_combos = {
31+
(line.project_id, line.task_id) for line in previous_sheet.timesheet_ids
32+
}
33+
lines_to_create = unique_combos - existing_keys
34+
if not lines_to_create:
35+
raise UserError(
36+
_(
37+
"All project/task combinations from the previous period already "
38+
"exist.",
39+
)
40+
)
41+
for project, task in lines_to_create:
42+
vals = self._prepare_empty_analytic_line(project=project, task=task)
43+
self.env["account.analytic.line"]._sheet_create(vals)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This module depends on **HR Timesheet Sheet** (`hr_timesheet_sheet`), which provides
2+
the timesheet sheet model and workflow (draft, confirmed, approved).
3+
4+
It is designed for environments where employees work on a recurring set of projects and
5+
tasks across timesheet periods, reducing the manual effort of re-entering the same
6+
project/task lines each period.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- [Quartile](https://www.quartile.co):
2+
- Yoshi Tashiro
3+
- Aung Ko Ko Lin
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This module adds a "Prefill from Previous Period" button to the timesheet sheet form.
2+
When clicked, it copies the project/task combinations from the employee's most recent
3+
confirmed or approved timesheet sheet, creating empty placeholder lines for the current
4+
period.

0 commit comments

Comments
 (0)