Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][ADD] hr_timesheet_predefined_description: Add predefined descriptions for timesheets #709

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions hr_timesheet_predefined_description/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
===================================
HR Timesheet Predefined Description
===================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:fccad56802cca66a08690e8b5d366ea9f87aece7ef61a6cb27593287378ab4c9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Ftimesheet-lightgray.png?logo=github
:target: https://github.com/OCA/timesheet/tree/14.0/hr_timesheet_predefined_description
:alt: OCA/timesheet
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/timesheet-14-0/timesheet-14-0-hr_timesheet_predefined_description
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows you to manage predefined descriptions for timesheets in Odoo.

**Table of contents**

.. contents::
:local:

Configuration
=============

**Add Predefined Descriptions:**

#. Go to *Timesheets* > *Configuration* > *Predefined Descriptions*.
#. Click on *Create*.
#. Enter the description name.
#. In a multi-company environment, check the company visibility.
#. Save.

**Modify Predefined Descriptions:**

#. Go to *Timesheets* > *Configuration* > *Predefined Descriptions*.
#. Click on an existing description.
#. Type the new description.

NOTE: These changes are not retro-actively applied to existing timesheets.

Usage
=====

**Create and Select Predefined Descriptions:**

#. When entering or editing a timesheet, simply select a predefined description from the
Predefined Description dropdown.
#. The Description field will be automatically filled based on the selected predefined
description.

**Override Descriptions if Necessary:**

#. You can manually edit the description in the timesheet if needed.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/timesheet/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`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**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* Juan José Seguí
* Pedro M. Baeza

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-juanjosesegui-tecnativa| image:: https://github.com/juanjosesegui-tecnativa.png?size=40px
:target: https://github.com/juanjosesegui-tecnativa
:alt: juanjosesegui-tecnativa

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-juanjosesegui-tecnativa|

This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/14.0/hr_timesheet_predefined_description>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions hr_timesheet_predefined_description/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
26 changes: 26 additions & 0 deletions hr_timesheet_predefined_description/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2024 Tecnativa - Juan José Seguí
# Copyright 2024 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "HR Timesheet Predefined Description",
"version": "14.0.1.0.0",
"category": "Timesheet",
"summary": "Predefined descriptions for timesheet entries",
"license": "AGPL-3",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/timesheet",
"installable": True,
"auto_install": False,
"depends": ["hr_timesheet"],
"data": [
"security/ir.model.access.csv",
"security/timesheet_predefined_description_security.xml",
"views/account_analytic_line_views.xml",
"views/timesheet_predefined_description_views.xml",
],
"demo": [
"demo/hr_timesheet_predefined_description_demo.xml",
],
"maintainers": ["juanjosesegui-tecnativa"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data noupdate="1">
<!-- Predefined Description 1 -->
<record
id="timesheet_predefined_description_1"
model="timesheet.predefined.description"
>
<field name="name">Development Task</field>
</record>

<!-- Predefined Description 2 -->
<record
id="timesheet_predefined_description_2"
model="timesheet.predefined.description"
>
<field name="name">Bug Fixing</field>
</record>

<!-- Predefined Description 3 -->
<record
id="timesheet_predefined_description_3"
model="timesheet.predefined.description"
>
<field name="name">Meeting with Client</field>
</record>
</data>
</odoo>
4 changes: 4 additions & 0 deletions hr_timesheet_predefined_description/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import hr_timesheet_predefined_description
from . import account_analytic_line
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2024 Tecnativa - Juan José Seguí
# Copyright 2024 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"

predefined_description_id = fields.Many2one(
comodel_name="timesheet.predefined.description", string="Predefined Description"
)

@api.model
def _adjust_name_from_predefined_description(self, vals):
"""Set description on the analytic line if no valid description is provided in
the dictionary vals and there's a predefined description.
"""
if "predefined_description_id" in vals and (vals.get("name") or "/") == "/":
description = self.env["timesheet.predefined.description"].browse(
vals["predefined_description_id"]
)
vals["name"] = description.name

@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
self._adjust_name_from_predefined_description(vals)
return super().create(vals_list)

def write(self, vals):
self._adjust_name_from_predefined_description(vals)
return super().write(vals)

@api.onchange("predefined_description_id")
def _onchange_predefined_description(self):
if self.predefined_description_id:
self.name = self.predefined_description_id.name
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Tecnativa - Juan José Seguí
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class TimesheetPredefinedDescription(models.Model):
_name = "timesheet.predefined.description"
_description = "Predefined Description for Timesheets"

name = fields.Char(string="Description", required=True)
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
default=lambda self: self.env.company,
)
15 changes: 15 additions & 0 deletions hr_timesheet_predefined_description/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**Add Predefined Descriptions:**

#. Go to *Timesheets* > *Configuration* > *Predefined Descriptions*.
#. Click on *Create*.
#. Enter the description name.
#. In a multi-company environment, check the company visibility.
#. Save.

**Modify Predefined Descriptions:**

#. Go to *Timesheets* > *Configuration* > *Predefined Descriptions*.
#. Click on an existing description.
#. Type the new description.

NOTE: These changes are not retro-actively applied to existing timesheets.
4 changes: 4 additions & 0 deletions hr_timesheet_predefined_description/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Juan José Seguí
* Pedro M. Baeza
1 change: 1 addition & 0 deletions hr_timesheet_predefined_description/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows you to manage predefined descriptions for timesheets in Odoo.
10 changes: 10 additions & 0 deletions hr_timesheet_predefined_description/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**Create and Select Predefined Descriptions:**

#. When entering or editing a timesheet, simply select a predefined description from the
Predefined Description dropdown.
#. The Description field will be automatically filled based on the selected predefined
description.

**Override Descriptions if Necessary:**

#. You can manually edit the description in the timesheet if needed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_timesheet_predefined_description_user,timesheet.predefined.description.user,model_timesheet_predefined_description,hr_timesheet.group_hr_timesheet_user,1,0,0,0
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 number Diff line number Diff line change
@@ -0,0 +1,8 @@
<odoo>
<record id="timesheet_predefined_description_rule" model="ir.rule">
<field name="name">Predefined Descriptions: multi-company access</field>
<field name="model_id" ref="model_timesheet_predefined_description" />
<field name="global" eval="True" />
<field name="domain_force">[('company_id', 'in', company_ids + [False])]</field>
</record>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading