diff --git a/hr_leave_type_code/README.rst b/hr_leave_type_code/README.rst new file mode 100644 index 00000000..7ecbbec4 --- /dev/null +++ b/hr_leave_type_code/README.rst @@ -0,0 +1,87 @@ +================== +HR Leave Type Code +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:00a5a4fe09bb38183e526c95d2c5b1c104c0ef8128c5569ed2f897b29d9445c5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fhr--holidays-lightgray.png?logo=github + :target: https://github.com/OCA/hr-holidays/tree/16.0/hr_leave_type_code + :alt: OCA/hr-holidays +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/hr-holidays-16-0/hr-holidays-16-0-hr_leave_type_code + :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/hr-holidays&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a code field on leave types. + +Additionally, the display name of leave types is calculated as "CODE - Name" if the leave type has a code. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Navigate to *Time Off > Configuration > Time Off Types*. +#. Select a leave +#. Add a code + +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 +~~~~~~~ + +* PyTech SRL + +Contributors +~~~~~~~~~~~~ + +* `Pytech SRL `__: + + * Alessandro Uffreduzzi + +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. + +This module is part of the `OCA/hr-holidays `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_leave_type_code/__init__.py b/hr_leave_type_code/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/hr_leave_type_code/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hr_leave_type_code/__manifest__.py b/hr_leave_type_code/__manifest__.py new file mode 100644 index 00000000..8e5f9fb6 --- /dev/null +++ b/hr_leave_type_code/__manifest__.py @@ -0,0 +1,15 @@ +{ + "name": "HR Leave Type Code", + "version": "16.0.1.0.0", + "category": "Human Resources", + "summary": "Add a code field to HR Leaves", + "website": "https://github.com/OCA/hr-holidays", + "author": "PyTech SRL, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["hr_holidays"], + "data": [ + "views/hr_leave_type.xml", + ], + "demo": [], +} diff --git a/hr_leave_type_code/i18n/it.po b/hr_leave_type_code/i18n/it.po new file mode 100644 index 00000000..4302521c --- /dev/null +++ b/hr_leave_type_code/i18n/it.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_leave_type_code +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-05 13:52+0000\n" +"PO-Revision-Date: 2023-07-05 13:52+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_leave_type_code +#: model:ir.model.fields,field_description:hr_leave_type_code.field_hr_leave_type__code +msgid "Code" +msgstr "Codice" + +#. module: hr_leave_type_code +#: model:ir.model.fields,field_description:hr_leave_type_code.field_hr_leave_type__smart_search +msgid "Smart Search" +msgstr "Ricerca intelligente" + +#. module: hr_leave_type_code +#: model:ir.model.constraint,message:hr_leave_type_code.constraint_hr_leave_type_code_uniq +msgid "The code must be unique per company!" +msgstr "Il codice deve essere univoco per azienda." + +#. module: hr_leave_type_code +#: model:ir.model,name:hr_leave_type_code.model_hr_leave_type +msgid "Time Off Type" +msgstr "Tipologia ferie" diff --git a/hr_leave_type_code/models/__init__.py b/hr_leave_type_code/models/__init__.py new file mode 100644 index 00000000..07799087 --- /dev/null +++ b/hr_leave_type_code/models/__init__.py @@ -0,0 +1 @@ +from . import hr_leave_type diff --git a/hr_leave_type_code/models/hr_leave_type.py b/hr_leave_type_code/models/hr_leave_type.py new file mode 100644 index 00000000..dc14f0a7 --- /dev/null +++ b/hr_leave_type_code/models/hr_leave_type.py @@ -0,0 +1,26 @@ +from odoo import fields, models + + +class HolidaysType(models.Model): + _inherit = "hr.leave.type" + + code = fields.Char() + + def name_get(self): + if self.requested_name_get(): + return super().name_get() + + return [ + (record.id, f"{record.code} - {record.name}") + if record.code + else (record.id, f"{record.name}") + for record in self + ] + + _sql_constraints = [ + ( + "code_uniq", + "UNIQUE(code, company_id)", + "The code must be unique per company!", + ) + ] diff --git a/hr_leave_type_code/readme/CONTRIBUTORS.rst b/hr_leave_type_code/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..f59dd232 --- /dev/null +++ b/hr_leave_type_code/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Pytech SRL `__: + + * Alessandro Uffreduzzi diff --git a/hr_leave_type_code/readme/DESCRIPTION.rst b/hr_leave_type_code/readme/DESCRIPTION.rst new file mode 100644 index 00000000..d33e9228 --- /dev/null +++ b/hr_leave_type_code/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module adds a code field on leave types. + +Additionally, the display name of leave types is calculated as "CODE - Name" if the leave type has a code. diff --git a/hr_leave_type_code/readme/USAGE.rst b/hr_leave_type_code/readme/USAGE.rst new file mode 100644 index 00000000..fe72a50c --- /dev/null +++ b/hr_leave_type_code/readme/USAGE.rst @@ -0,0 +1,3 @@ +#. Navigate to *Time Off > Configuration > Time Off Types*. +#. Select a leave +#. Add a code diff --git a/hr_leave_type_code/static/description/index.html b/hr_leave_type_code/static/description/index.html new file mode 100644 index 00000000..18199c7a --- /dev/null +++ b/hr_leave_type_code/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +HR Leave Type Code + + + +
+

HR Leave Type Code

+ + +

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

+

This module adds a code field on leave types.

+

Additionally, the display name of leave types is calculated as “CODE - Name” if the leave type has a code.

+

Table of contents

+ +
+

Usage

+
    +
  1. Navigate to Time Off > Configuration > Time Off Types.
  2. +
  3. Select a leave
  4. +
  5. Add a code
  6. +
+
+
+

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

+
    +
  • PyTech SRL
  • +
+
+
+

Contributors

+ +
+
+

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.

+

This module is part of the OCA/hr-holidays project on GitHub.

+

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

+
+
+
+ + diff --git a/hr_leave_type_code/tests/__init__.py b/hr_leave_type_code/tests/__init__.py new file mode 100644 index 00000000..cd9dfd48 --- /dev/null +++ b/hr_leave_type_code/tests/__init__.py @@ -0,0 +1 @@ +from . import test_hr_leave_type_code diff --git a/hr_leave_type_code/tests/test_hr_leave_type_code.py b/hr_leave_type_code/tests/test_hr_leave_type_code.py new file mode 100644 index 00000000..8c8f6d0b --- /dev/null +++ b/hr_leave_type_code/tests/test_hr_leave_type_code.py @@ -0,0 +1,19 @@ +from odoo.tests.common import TransactionCase + + +class TestHolidaysType(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.HrLeaveType = cls.env["hr.leave.type"] + + def test_name_get_no_code(self): + name = "test" + leave = self.HrLeaveType.create({"name": name}) + self.assertEqual(leave.display_name, name) + + def test_name_get_code(self): + name = "test" + code = "123" + leave = self.HrLeaveType.create({"name": name, "code": code}) + self.assertEqual(leave.display_name, f"{code} - {name}") diff --git a/hr_leave_type_code/views/hr_leave_type.xml b/hr_leave_type_code/views/hr_leave_type.xml new file mode 100644 index 00000000..ef14652c --- /dev/null +++ b/hr_leave_type_code/views/hr_leave_type.xml @@ -0,0 +1,41 @@ + + + + + hr.leave.type.filter + hr.leave.type + + + + + + + + + + hr.leave.type.form + hr.leave.type + + + + + + + + + + + + hr.leave.type.kanban + hr.leave.type + + + + + - + + + + + + diff --git a/setup/hr_leave_type_code/odoo/addons/hr_leave_type_code b/setup/hr_leave_type_code/odoo/addons/hr_leave_type_code new file mode 120000 index 00000000..df9f10f5 --- /dev/null +++ b/setup/hr_leave_type_code/odoo/addons/hr_leave_type_code @@ -0,0 +1 @@ +../../../../hr_leave_type_code \ No newline at end of file diff --git a/setup/hr_leave_type_code/setup.py b/setup/hr_leave_type_code/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/hr_leave_type_code/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)