diff --git a/hr_timesheet_predefined_description/README.rst b/hr_timesheet_predefined_description/README.rst new file mode 100644 index 0000000000..a20d08a445 --- /dev/null +++ b/hr_timesheet_predefined_description/README.rst @@ -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 `_. +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * 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 `__: + +|maintainer-juanjosesegui-tecnativa| + +This module is part of the `OCA/timesheet `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_timesheet_predefined_description/__init__.py b/hr_timesheet_predefined_description/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/hr_timesheet_predefined_description/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hr_timesheet_predefined_description/__manifest__.py b/hr_timesheet_predefined_description/__manifest__.py new file mode 100644 index 0000000000..aaa5837df3 --- /dev/null +++ b/hr_timesheet_predefined_description/__manifest__.py @@ -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"], +} diff --git a/hr_timesheet_predefined_description/demo/hr_timesheet_predefined_description_demo.xml b/hr_timesheet_predefined_description/demo/hr_timesheet_predefined_description_demo.xml new file mode 100644 index 0000000000..d8bf576089 --- /dev/null +++ b/hr_timesheet_predefined_description/demo/hr_timesheet_predefined_description_demo.xml @@ -0,0 +1,28 @@ + + + + + + Development Task + + + + + Bug Fixing + + + + + Meeting with Client + + + diff --git a/hr_timesheet_predefined_description/models/__init__.py b/hr_timesheet_predefined_description/models/__init__.py new file mode 100644 index 0000000000..ced40fe2cf --- /dev/null +++ b/hr_timesheet_predefined_description/models/__init__.py @@ -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 diff --git a/hr_timesheet_predefined_description/models/account_analytic_line.py b/hr_timesheet_predefined_description/models/account_analytic_line.py new file mode 100644 index 0000000000..ef1d5ae947 --- /dev/null +++ b/hr_timesheet_predefined_description/models/account_analytic_line.py @@ -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 diff --git a/hr_timesheet_predefined_description/models/hr_timesheet_predefined_description.py b/hr_timesheet_predefined_description/models/hr_timesheet_predefined_description.py new file mode 100644 index 0000000000..627b05a63b --- /dev/null +++ b/hr_timesheet_predefined_description/models/hr_timesheet_predefined_description.py @@ -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, + ) diff --git a/hr_timesheet_predefined_description/readme/CONFIGURE.rst b/hr_timesheet_predefined_description/readme/CONFIGURE.rst new file mode 100644 index 0000000000..bcfd4cd178 --- /dev/null +++ b/hr_timesheet_predefined_description/readme/CONFIGURE.rst @@ -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. diff --git a/hr_timesheet_predefined_description/readme/CONTRIBUTORS.rst b/hr_timesheet_predefined_description/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..27df9327aa --- /dev/null +++ b/hr_timesheet_predefined_description/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_: + + * Juan José Seguí + * Pedro M. Baeza diff --git a/hr_timesheet_predefined_description/readme/DESCRIPTION.rst b/hr_timesheet_predefined_description/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..1629564b82 --- /dev/null +++ b/hr_timesheet_predefined_description/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows you to manage predefined descriptions for timesheets in Odoo. diff --git a/hr_timesheet_predefined_description/readme/USAGE.rst b/hr_timesheet_predefined_description/readme/USAGE.rst new file mode 100644 index 0000000000..98745c5ffd --- /dev/null +++ b/hr_timesheet_predefined_description/readme/USAGE.rst @@ -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. diff --git a/hr_timesheet_predefined_description/security/ir.model.access.csv b/hr_timesheet_predefined_description/security/ir.model.access.csv new file mode 100644 index 0000000000..fb21a5041b --- /dev/null +++ b/hr_timesheet_predefined_description/security/ir.model.access.csv @@ -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 diff --git a/hr_timesheet_predefined_description/security/timesheet_predefined_description_security.xml b/hr_timesheet_predefined_description/security/timesheet_predefined_description_security.xml new file mode 100644 index 0000000000..56d915f063 --- /dev/null +++ b/hr_timesheet_predefined_description/security/timesheet_predefined_description_security.xml @@ -0,0 +1,8 @@ + + + Predefined Descriptions: multi-company access + + + [('company_id', 'in', company_ids + [False])] + + diff --git a/hr_timesheet_predefined_description/static/description/icon.png b/hr_timesheet_predefined_description/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/hr_timesheet_predefined_description/static/description/icon.png differ diff --git a/hr_timesheet_predefined_description/static/description/index.html b/hr_timesheet_predefined_description/static/description/index.html new file mode 100644 index 0000000000..0096350abf --- /dev/null +++ b/hr_timesheet_predefined_description/static/description/index.html @@ -0,0 +1,460 @@ + + + + + +HR Timesheet Predefined Description + + + +
+

HR Timesheet Predefined Description

+ + +

Beta License: AGPL-3 OCA/timesheet Translate me on Weblate Try me on Runboat

+

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

+

Table of contents

+ +
+

Configuration

+

Add Predefined Descriptions:

+
    +
  1. Go to Timesheets > Configuration > Predefined Descriptions.
  2. +
  3. Click on Create.
  4. +
  5. Enter the description name.
  6. +
  7. In a multi-company environment, check the company visibility.
  8. +
  9. Save.
  10. +
+

Modify Predefined Descriptions:

+
    +
  1. Go to Timesheets > Configuration > Predefined Descriptions.
  2. +
  3. Click on an existing description.
  4. +
  5. Type the new description.
  6. +
+

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

+
+
+

Usage

+

Create and Select Predefined Descriptions:

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

Override Descriptions if Necessary:

+
    +
  1. You can manually edit the description in the timesheet if needed.
  2. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Juan José Seguí
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

juanjosesegui-tecnativa

+

This module is part of the OCA/timesheet project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/hr_timesheet_predefined_description/tests/__init__.py b/hr_timesheet_predefined_description/tests/__init__.py new file mode 100644 index 0000000000..dd41d96822 --- /dev/null +++ b/hr_timesheet_predefined_description/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_account_analytic_line diff --git a/hr_timesheet_predefined_description/tests/test_account_analytic_line.py b/hr_timesheet_predefined_description/tests/test_account_analytic_line.py new file mode 100644 index 0000000000..e846e4d409 --- /dev/null +++ b/hr_timesheet_predefined_description/tests/test_account_analytic_line.py @@ -0,0 +1,47 @@ +# 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.tests import Form, common + + +class TestAccountAnalyticLine(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestAccountAnalyticLine, cls).setUpClass() + cls.AccountAnalyticAccount = cls.env["account.analytic.account"] + cls.PredefinedDescription = cls.env["timesheet.predefined.description"] + cls.AccountAnalyticLine = cls.env["account.analytic.line"] + cls.description = "Test Predefined Description" + cls.predefined_description = cls.PredefinedDescription.create( + {"name": cls.description} + ) + cls.analytic_account = cls.AccountAnalyticAccount.create( + {"name": "Test Account"} + ) + cls.analytic_line = cls.AccountAnalyticLine.create( + { + "name": "Original Description", + "account_id": cls.analytic_account.id, + } + ) + + def test_onchange_predefined_description(self): + with Form(self.analytic_line) as form: + form.predefined_description_id = self.predefined_description + self.assertEqual(form.name, self.description) + + def test_create_predefined_description(self): + line = self.analytic_line.create( + { + "account_id": self.analytic_account.id, + "predefined_description_id": self.predefined_description.id, + }, + ) + self.assertEqual(line.name, self.description) + + def test_write_predefined_description(self): + self.analytic_line.write( + {"predefined_description_id": self.predefined_description.id} + ) + self.assertEqual(self.analytic_line.name, self.description) diff --git a/hr_timesheet_predefined_description/views/account_analytic_line_views.xml b/hr_timesheet_predefined_description/views/account_analytic_line_views.xml new file mode 100644 index 0000000000..a251c2cfd0 --- /dev/null +++ b/hr_timesheet_predefined_description/views/account_analytic_line_views.xml @@ -0,0 +1,34 @@ + + + account.analytic.line.form.inherit + account.analytic.line + + + + + + + + + account.analytic.line + + + + + + + + + project.task.form.inherit.predefined_description + project.task + + + + + + + + diff --git a/hr_timesheet_predefined_description/views/timesheet_predefined_description_views.xml b/hr_timesheet_predefined_description/views/timesheet_predefined_description_views.xml new file mode 100644 index 0000000000..530c3495ef --- /dev/null +++ b/hr_timesheet_predefined_description/views/timesheet_predefined_description_views.xml @@ -0,0 +1,27 @@ + + + timesheet.predefined.description.tree + timesheet.predefined.description + + + + + + + + + + Predefined Descriptions + timesheet.predefined.description + tree + + + + + + diff --git a/setup/hr_timesheet_predefined_description/odoo/addons/hr_timesheet_predefined_description b/setup/hr_timesheet_predefined_description/odoo/addons/hr_timesheet_predefined_description new file mode 120000 index 0000000000..3e628edd6a --- /dev/null +++ b/setup/hr_timesheet_predefined_description/odoo/addons/hr_timesheet_predefined_description @@ -0,0 +1 @@ +../../../../hr_timesheet_predefined_description \ No newline at end of file diff --git a/setup/hr_timesheet_predefined_description/setup.py b/setup/hr_timesheet_predefined_description/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/hr_timesheet_predefined_description/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)