Skip to content

Commit 3715956

Browse files
[ADD] hr_timesheet_predefined_description: Add predefined descriptions for timesheets
TT50619 Co-Authored-By: Pedro M. Baeza <[email protected]>
1 parent d416cc4 commit 3715956

21 files changed

+853
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
===================================
2+
HR Timesheet Predefined Description
3+
===================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:fccad56802cca66a08690e8b5d366ea9f87aece7ef61a6cb27593287378ab4c9
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/14.0/hr_timesheet_predefined_description
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-14-0/timesheet-14-0-hr_timesheet_predefined_description
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=14.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows you to manage predefined descriptions for timesheets in Odoo.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Configuration
39+
=============
40+
41+
**Add Predefined Descriptions:**
42+
43+
#. Go to *Timesheets* > *Configuration* > *Predefined Descriptions*.
44+
#. Click on *Create*.
45+
#. Enter the description name.
46+
#. In a multi-company environment, check the company visibility.
47+
#. Save.
48+
49+
**Modify Predefined Descriptions:**
50+
51+
#. Go to *Timesheets* > *Configuration* > *Predefined Descriptions*.
52+
#. Click on an existing description.
53+
#. Type the new description.
54+
55+
NOTE: These changes are not retro-actively applied to existing timesheets.
56+
57+
Usage
58+
=====
59+
60+
**Create and Select Predefined Descriptions:**
61+
62+
#. When entering or editing a timesheet, simply select a predefined description from the
63+
Predefined Description dropdown.
64+
#. The Description field will be automatically filled based on the selected predefined
65+
description.
66+
67+
**Override Descriptions if Necessary:**
68+
69+
#. You can manually edit the description in the timesheet if needed.
70+
71+
Bug Tracker
72+
===========
73+
74+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/timesheet/issues>`_.
75+
In case of trouble, please check there if your issue has already been reported.
76+
If you spotted it first, help us to smash it by providing a detailed and welcomed
77+
`feedback <https://github.com/OCA/timesheet/issues/new?body=module:%20hr_timesheet_predefined_description%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
78+
79+
Do not contact contributors directly about support or help with technical issues.
80+
81+
Credits
82+
=======
83+
84+
Authors
85+
~~~~~~~
86+
87+
* Tecnativa
88+
89+
Contributors
90+
~~~~~~~~~~~~
91+
92+
* `Tecnativa <https://www.tecnativa.com>`_:
93+
94+
* Juan José Seguí
95+
* Pedro M. Baeza
96+
97+
Maintainers
98+
~~~~~~~~~~~
99+
100+
This module is maintained by the OCA.
101+
102+
.. image:: https://odoo-community.org/logo.png
103+
:alt: Odoo Community Association
104+
:target: https://odoo-community.org
105+
106+
OCA, or the Odoo Community Association, is a nonprofit organization whose
107+
mission is to support the collaborative development of Odoo features and
108+
promote its widespread use.
109+
110+
.. |maintainer-juanjosesegui-tecnativa| image:: https://github.com/juanjosesegui-tecnativa.png?size=40px
111+
:target: https://github.com/juanjosesegui-tecnativa
112+
:alt: juanjosesegui-tecnativa
113+
114+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
115+
116+
|maintainer-juanjosesegui-tecnativa|
117+
118+
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/14.0/hr_timesheet_predefined_description>`_ project on GitHub.
119+
120+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2024 Tecnativa - Juan José Seguí
2+
# Copyright 2024 Tecnativa - Pedro M. Baeza
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
{
6+
"name": "HR Timesheet Predefined Description",
7+
"version": "14.0.1.0.0",
8+
"category": "Timesheet",
9+
"summary": "Predefined descriptions for timesheet entries",
10+
"license": "AGPL-3",
11+
"author": "Tecnativa, Odoo Community Association (OCA)",
12+
"website": "https://github.com/OCA/timesheet",
13+
"installable": True,
14+
"auto_install": False,
15+
"depends": ["hr_timesheet"],
16+
"data": [
17+
"security/ir.model.access.csv",
18+
"security/timesheet_predefined_description_security.xml",
19+
"views/account_analytic_line_views.xml",
20+
"views/timesheet_predefined_description_views.xml",
21+
],
22+
"demo": [
23+
"demo/hr_timesheet_predefined_description_demo.xml",
24+
],
25+
"maintainers": ["juanjosesegui-tecnativa"],
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<odoo>
3+
<data noupdate="1">
4+
<!-- Predefined Description 1 -->
5+
<record
6+
id="timesheet_predefined_description_1"
7+
model="timesheet.predefined.description"
8+
>
9+
<field name="name">Development Task</field>
10+
</record>
11+
12+
<!-- Predefined Description 2 -->
13+
<record
14+
id="timesheet_predefined_description_2"
15+
model="timesheet.predefined.description"
16+
>
17+
<field name="name">Bug Fixing</field>
18+
</record>
19+
20+
<!-- Predefined Description 3 -->
21+
<record
22+
id="timesheet_predefined_description_3"
23+
model="timesheet.predefined.description"
24+
>
25+
<field name="name">Meeting with Client</field>
26+
</record>
27+
</data>
28+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import hr_timesheet_predefined_description
4+
from . import account_analytic_line
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2024 Tecnativa - Juan José Seguí
2+
# Copyright 2024 Tecnativa - Pedro M. Baeza
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
from odoo import api, fields, models
6+
7+
8+
class AccountAnalyticLine(models.Model):
9+
_inherit = "account.analytic.line"
10+
11+
predefined_description_id = fields.Many2one(
12+
comodel_name="timesheet.predefined.description", string="Predefined Description"
13+
)
14+
15+
@api.model
16+
def _adjust_name_from_predefined_description(self, vals):
17+
"""Set description on the analytic line if no valid description is provided in
18+
the dictionary vals and there's a predefined description.
19+
"""
20+
if "predefined_description_id" in vals and (vals.get("name") or "/") == "/":
21+
description = self.env["timesheet.predefined.description"].browse(
22+
vals["predefined_description_id"]
23+
)
24+
vals["name"] = description.name
25+
26+
@api.model_create_multi
27+
def create(self, vals_list):
28+
for vals in vals_list:
29+
self._adjust_name_from_predefined_description(vals)
30+
return super().create(vals_list)
31+
32+
def write(self, vals):
33+
self._adjust_name_from_predefined_description(vals)
34+
return super().write(vals)
35+
36+
@api.onchange("predefined_description_id")
37+
def _onchange_predefined_description(self):
38+
if self.predefined_description_id:
39+
self.name = self.predefined_description_id.name
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2024 Tecnativa - Juan José Seguí
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class TimesheetPredefinedDescription(models.Model):
8+
_name = "timesheet.predefined.description"
9+
_description = "Predefined Description for Timesheets"
10+
11+
name = fields.Char(string="Description", required=True)
12+
company_id = fields.Many2one(
13+
comodel_name="res.company",
14+
string="Company",
15+
default=lambda self: self.env.company,
16+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
**Add Predefined Descriptions:**
2+
3+
#. Go to *Timesheets* > *Configuration* > *Predefined Descriptions*.
4+
#. Click on *Create*.
5+
#. Enter the description name.
6+
#. In a multi-company environment, check the company visibility.
7+
#. Save.
8+
9+
**Modify Predefined Descriptions:**
10+
11+
#. Go to *Timesheets* > *Configuration* > *Predefined Descriptions*.
12+
#. Click on an existing description.
13+
#. Type the new description.
14+
15+
NOTE: These changes are not retro-actively applied to existing timesheets.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* `Tecnativa <https://www.tecnativa.com>`_:
2+
3+
* Juan José Seguí
4+
* Pedro M. Baeza
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module allows you to manage predefined descriptions for timesheets in Odoo.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**Create and Select Predefined Descriptions:**
2+
3+
#. When entering or editing a timesheet, simply select a predefined description from the
4+
Predefined Description dropdown.
5+
#. The Description field will be automatically filled based on the selected predefined
6+
description.
7+
8+
**Override Descriptions if Necessary:**
9+
10+
#. You can manually edit the description in the timesheet if needed.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
access_timesheet_predefined_description_user,timesheet.predefined.description.user,model_timesheet_predefined_description,hr_timesheet.group_hr_timesheet_user,1,0,0,0
3+
access_timesheet_predefined_description_admin,timesheet.predefined.description.admin,model_timesheet_predefined_description,hr_timesheet.group_timesheet_manager,1,1,1,1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<odoo>
2+
<record id="timesheet_predefined_description_rule" model="ir.rule">
3+
<field name="name">Predefined Descriptions: multi-company access</field>
4+
<field name="model_id" ref="model_timesheet_predefined_description" />
5+
<field name="global" eval="True" />
6+
<field name="domain_force">[('company_id', 'in', company_ids + [False])]</field>
7+
</record>
8+
</odoo>
Loading

0 commit comments

Comments
 (0)