diff --git a/hr_timesheet_name_customer/README.rst b/hr_timesheet_name_customer/README.rst new file mode 100644 index 0000000000..3a563af632 --- /dev/null +++ b/hr_timesheet_name_customer/README.rst @@ -0,0 +1,118 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================== +Timesheet Description Customer +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ddb3b4ce95637877dc62ac4a21cfef0021f6ad8da4aaf6d34f3a9b26ad050b46 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github + :target: https://github.com/OCA/timesheet/tree/19.0/hr_timesheet_name_customer + :alt: OCA/timesheet +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/timesheet-19-0/timesheet-19-0-hr_timesheet_name_customer + :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=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds additional field "Description Customer" which is used +for customer timesheet reports. It also shows the "Description Customer" +instead of the "Description" field in the customer portal. By default +this field will be populated from the "Description" field of the +timesheet. + +New report "Timesheet Customer" is added to print timesheets with +"Customer Description" instead of the "Description" field. + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +Sometimes you might need to add different description for customer +timesheets while keeping the original description for internal use. Eg +your team records timesheets in English but your customer prefers to see +timesheets in French. + +Configuration +============= + +No configuration is required. + +Usage +===== + +New field "Description Customer" is added to the timesheet list and form +views. This field is visible only for "Timesheets/Administrator" group. +If this field is not set, the "Description" field value will be +automatically copied to it. + +To print report with "Description Customer" instead of "Description" +field: + +1. Select timesheets you want to print +2. Click "Print / Timesheets Customer" + +Changelog +========= + +16.0.1.0.0 (2023-02-26) +----------------------- + +- [ADD] Initial release for Odoo 16. + (`#568 `__) + +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 +------- + +* Cetmix + +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/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_name_customer/__init__.py b/hr_timesheet_name_customer/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/hr_timesheet_name_customer/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hr_timesheet_name_customer/__manifest__.py b/hr_timesheet_name_customer/__manifest__.py new file mode 100644 index 0000000000..25d62d6862 --- /dev/null +++ b/hr_timesheet_name_customer/__manifest__.py @@ -0,0 +1,17 @@ +{ + "name": "Timesheet Description Customer", + "summary": "Add 'Description Customer' field for timesheets", + "version": "19.0.1.0.0", + "category": "Timesheet", + "website": "https://github.com/OCA/timesheet", + "author": "Odoo Community Association (OCA), Cetmix", + "license": "LGPL-3", + "application": False, + "installable": True, + "depends": ["hr_timesheet"], + "data": [ + "views/hr_timesheet_name_customer_views.xml", + "report/name_customer_template.xml", + "views/project_portal_templates.xml", + ], +} diff --git a/hr_timesheet_name_customer/i18n/es.po b/hr_timesheet_name_customer/i18n/es.po new file mode 100644 index 0000000000..e376f6dd54 --- /dev/null +++ b/hr_timesheet_name_customer/i18n/es.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_timesheet_name_customer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-09-03 05:14+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.name_customer_table +msgid "Description" +msgstr "Descripción" + +#. module: hr_timesheet_name_customer +#: model:ir.model,name:hr_timesheet_name_customer.model_account_analytic_line +msgid "Analytic Line" +msgstr "Línea Analítica" + +#. module: hr_timesheet_name_customer +#: model:ir.model.fields,field_description:hr_timesheet_name_customer.field_account_analytic_line__name_customer +msgid "Customer Description" +msgstr "Descripción del Cliente" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "Project" +msgstr "Proyecto" + +#. module: hr_timesheet_name_customer +#: model:ir.actions.report,name:hr_timesheet_name_customer.timesheet_report_name_custom +msgid "Timesheet Customer" +msgstr "Hoja de horas del cliente" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "Timesheets" +msgstr "Hojas de Tiempo" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "for the" +msgstr "para la/el" diff --git a/hr_timesheet_name_customer/i18n/fr.po b/hr_timesheet_name_customer/i18n/fr.po new file mode 100644 index 0000000000..50cfd0d1cf --- /dev/null +++ b/hr_timesheet_name_customer/i18n/fr.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_timesheet_name_customer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-06 13:36+0000\n" +"Last-Translator: Rémi \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.name_customer_table +msgid "Description" +msgstr "Description" + +#. module: hr_timesheet_name_customer +#: model:ir.model,name:hr_timesheet_name_customer.model_account_analytic_line +msgid "Analytic Line" +msgstr "Ligne Analytique" + +#. module: hr_timesheet_name_customer +#: model:ir.model.fields,field_description:hr_timesheet_name_customer.field_account_analytic_line__name_customer +msgid "Customer Description" +msgstr "Description Client" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "Project" +msgstr "Projet" + +#. module: hr_timesheet_name_customer +#: model:ir.actions.report,name:hr_timesheet_name_customer.timesheet_report_name_custom +msgid "Timesheet Customer" +msgstr "Feuille de temps client" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "Timesheets" +msgstr "Feuilles de temps" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "for the" +msgstr "pour le" diff --git a/hr_timesheet_name_customer/i18n/hr_timesheet_name_customer.pot b/hr_timesheet_name_customer/i18n/hr_timesheet_name_customer.pot new file mode 100644 index 0000000000..0a29221d9c --- /dev/null +++ b/hr_timesheet_name_customer/i18n/hr_timesheet_name_customer.pot @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_timesheet_name_customer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \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_timesheet_name_customer +#: model:ir.model,name:hr_timesheet_name_customer.model_account_analytic_line +msgid "Analytic Line" +msgstr "" + +#. module: hr_timesheet_name_customer +#: model:ir.model.fields,field_description:hr_timesheet_name_customer.field_account_analytic_line__name_customer +msgid "Customer Description" +msgstr "" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "Project" +msgstr "" + +#. module: hr_timesheet_name_customer +#: model:ir.actions.report,name:hr_timesheet_name_customer.timesheet_report_name_custom +msgid "Timesheet Customer" +msgstr "" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "Timesheets" +msgstr "" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "for the" +msgstr "" diff --git a/hr_timesheet_name_customer/i18n/it.po b/hr_timesheet_name_customer/i18n/it.po new file mode 100644 index 0000000000..6c058682ec --- /dev/null +++ b/hr_timesheet_name_customer/i18n/it.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_timesheet_name_customer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-03-14 15:37+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.name_customer_table +msgid "Description" +msgstr "Descrizione" + +#. module: hr_timesheet_name_customer +#: model:ir.model,name:hr_timesheet_name_customer.model_account_analytic_line +msgid "Analytic Line" +msgstr "Riga analitica" + +#. module: hr_timesheet_name_customer +#: model:ir.model.fields,field_description:hr_timesheet_name_customer.field_account_analytic_line__name_customer +msgid "Customer Description" +msgstr "Descrizione cliente" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "Project" +msgstr "Progetto" + +#. module: hr_timesheet_name_customer +#: model:ir.actions.report,name:hr_timesheet_name_customer.timesheet_report_name_custom +msgid "Timesheet Customer" +msgstr "Foglio ore cliente" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "Timesheets" +msgstr "Fogli ore" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "for the" +msgstr "per il" diff --git a/hr_timesheet_name_customer/i18n/pt_BR.po b/hr_timesheet_name_customer/i18n/pt_BR.po new file mode 100644 index 0000000000..df9a439e34 --- /dev/null +++ b/hr_timesheet_name_customer/i18n/pt_BR.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_timesheet_name_customer +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-27 21:25+0000\n" +"Last-Translator: Adriano Prado \n" +"Language-Team: none\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.name_customer_table +msgid "Description" +msgstr "Descrição" + +#. module: hr_timesheet_name_customer +#: model:ir.model,name:hr_timesheet_name_customer.model_account_analytic_line +msgid "Analytic Line" +msgstr "Linha Analítica" + +#. module: hr_timesheet_name_customer +#: model:ir.model.fields,field_description:hr_timesheet_name_customer.field_account_analytic_line__name_customer +msgid "Customer Description" +msgstr "Descrição Cliente" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "Project" +msgstr "Projeto" + +#. module: hr_timesheet_name_customer +#: model:ir.actions.report,name:hr_timesheet_name_customer.timesheet_report_name_custom +msgid "Timesheet Customer" +msgstr "Apontamentos de Horas do Cliente" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "Timesheets" +msgstr "Apontamentos de horas" + +#. module: hr_timesheet_name_customer +#: model_terms:ir.ui.view,arch_db:hr_timesheet_name_customer.report_timesheet_custom +msgid "for the" +msgstr "para o" diff --git a/hr_timesheet_name_customer/models/__init__.py b/hr_timesheet_name_customer/models/__init__.py new file mode 100644 index 0000000000..0aa7ac196f --- /dev/null +++ b/hr_timesheet_name_customer/models/__init__.py @@ -0,0 +1 @@ +from . import hr_timesheet_name_customer diff --git a/hr_timesheet_name_customer/models/hr_timesheet_name_customer.py b/hr_timesheet_name_customer/models/hr_timesheet_name_customer.py new file mode 100644 index 0000000000..70c06beeea --- /dev/null +++ b/hr_timesheet_name_customer/models/hr_timesheet_name_customer.py @@ -0,0 +1,19 @@ +# Copyright 2023-nowdays Cetmix OU (https://cetmix.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo import api, fields, models + + +class NameCustomer(models.Model): + _inherit = "account.analytic.line" + + name_customer = fields.Char( + string="Customer Description", + compute="_compute_name_customer", + store=True, + readonly=False, + ) + + @api.depends("name") + def _compute_name_customer(self): + for rec in self.filtered(lambda r: r.name and r.name != "/"): + rec.name_customer = rec.name diff --git a/hr_timesheet_name_customer/pyproject.toml b/hr_timesheet_name_customer/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/hr_timesheet_name_customer/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_timesheet_name_customer/readme/CONFIGURE.md b/hr_timesheet_name_customer/readme/CONFIGURE.md new file mode 100644 index 0000000000..718c4a6561 --- /dev/null +++ b/hr_timesheet_name_customer/readme/CONFIGURE.md @@ -0,0 +1 @@ +No configuration is required. diff --git a/hr_timesheet_name_customer/readme/CONTEXT.md b/hr_timesheet_name_customer/readme/CONTEXT.md new file mode 100644 index 0000000000..7d9996a9d0 --- /dev/null +++ b/hr_timesheet_name_customer/readme/CONTEXT.md @@ -0,0 +1,4 @@ +Sometimes you might need to add different description for customer +timesheets while keeping the original description for internal use. Eg +your team records timesheets in English but your customer prefers to see +timesheets in French. diff --git a/hr_timesheet_name_customer/readme/DESCRIPTION.md b/hr_timesheet_name_customer/readme/DESCRIPTION.md new file mode 100644 index 0000000000..45e5cdc1a9 --- /dev/null +++ b/hr_timesheet_name_customer/readme/DESCRIPTION.md @@ -0,0 +1,8 @@ +This module adds additional field "Description Customer" which is used +for customer timesheet reports. It also shows the "Description Customer" +instead of the "Description" field in the customer portal. By default +this field will be populated from the "Description" field of the +timesheet. + +New report "Timesheet Customer" is added to print timesheets with +"Customer Description" instead of the "Description" field. diff --git a/hr_timesheet_name_customer/readme/HISTORY.md b/hr_timesheet_name_customer/readme/HISTORY.md new file mode 100644 index 0000000000..9cb1262858 --- /dev/null +++ b/hr_timesheet_name_customer/readme/HISTORY.md @@ -0,0 +1,4 @@ +## 16.0.1.0.0 (2023-02-26) + +- \[ADD\] Initial release for Odoo 16. + ([\#568](https://github.com/OCA/timesheet/pull/568)) diff --git a/hr_timesheet_name_customer/readme/USAGE.md b/hr_timesheet_name_customer/readme/USAGE.md new file mode 100644 index 0000000000..e0a619291e --- /dev/null +++ b/hr_timesheet_name_customer/readme/USAGE.md @@ -0,0 +1,10 @@ +New field "Description Customer" is added to the timesheet list and form +views. This field is visible only for "Timesheets/Administrator" group. +If this field is not set, the "Description" field value will be +automatically copied to it. + +To print report with "Description Customer" instead of "Description" +field: + +1. Select timesheets you want to print +2. Click "Print / Timesheets Customer" diff --git a/hr_timesheet_name_customer/report/name_customer_template.xml b/hr_timesheet_name_customer/report/name_customer_template.xml new file mode 100644 index 0000000000..36fb09a9e5 --- /dev/null +++ b/hr_timesheet_name_customer/report/name_customer_template.xml @@ -0,0 +1,67 @@ + + + + + + + + + Timesheet Customer + account.analytic.line + qweb-pdf + hr_timesheet_name_customer.report_timesheet_custom + report_timesheet_custom + + report + + diff --git a/hr_timesheet_name_customer/static/description/icon.png b/hr_timesheet_name_customer/static/description/icon.png new file mode 100644 index 0000000000..1dcc49c24f Binary files /dev/null and b/hr_timesheet_name_customer/static/description/icon.png differ diff --git a/hr_timesheet_name_customer/static/description/index.html b/hr_timesheet_name_customer/static/description/index.html new file mode 100644 index 0000000000..af8fea7f5c --- /dev/null +++ b/hr_timesheet_name_customer/static/description/index.html @@ -0,0 +1,469 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Timesheet Description Customer

+ +

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

+

This module adds additional field “Description Customer” which is used +for customer timesheet reports. It also shows the “Description Customer” +instead of the “Description” field in the customer portal. By default +this field will be populated from the “Description” field of the +timesheet.

+

New report “Timesheet Customer” is added to print timesheets with +“Customer Description” instead of the “Description” field.

+

Table of contents

+ +
+

Use Cases / Context

+

Sometimes you might need to add different description for customer +timesheets while keeping the original description for internal use. Eg +your team records timesheets in English but your customer prefers to see +timesheets in French.

+
+
+

Configuration

+

No configuration is required.

+
+
+

Usage

+

New field “Description Customer” is added to the timesheet list and form +views. This field is visible only for “Timesheets/Administrator” group. +If this field is not set, the “Description” field value will be +automatically copied to it.

+

To print report with “Description Customer” instead of “Description” +field:

+
    +
  1. Select timesheets you want to print
  2. +
  3. Click “Print / Timesheets Customer”
  4. +
+
+
+

Changelog

+
+

16.0.1.0.0 (2023-02-26)

+
    +
  • [ADD] Initial release for Odoo 16. +(#568)
  • +
+
+
+
+

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

+
    +
  • Cetmix
  • +
+
+
+

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/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_name_customer/tests/__init__.py b/hr_timesheet_name_customer/tests/__init__.py new file mode 100644 index 0000000000..41567ecdfe --- /dev/null +++ b/hr_timesheet_name_customer/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_name_customer +from . import common diff --git a/hr_timesheet_name_customer/tests/common.py b/hr_timesheet_name_customer/tests/common.py new file mode 100644 index 0000000000..a0f97573ad --- /dev/null +++ b/hr_timesheet_name_customer/tests/common.py @@ -0,0 +1,75 @@ +# Copyright 2023-nowdays Cetmix OU (https://cetmix.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo.tests.common import TransactionCase + + +class TestCommonNameCustomer(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + # customer partner + cls.partner = cls.env["res.partner"].create( + { + "name": "Customer For Analytic Account", + "email": "customer@task.com", + "phone": "42", + } + ) + + cls.analytic_plan = cls.env["account.analytic.plan"].create( + { + "name": "Plan Test", + } + ) + cls.analytic_account = cls.env["account.analytic.account"].create( + { + "name": "Analytic Account for Test Customer", + "partner_id": cls.partner.id, + "plan_id": cls.analytic_plan.id, + "code": "TEST", + } + ) + + # project and tasks + cls.project_customer = cls.env["project.project"].create( + { + "name": "Project X", + "allow_timesheets": True, + "partner_id": cls.partner.id, + } + ) + cls.task1 = cls.env["project.task"].create( + { + "name": "Task One", + "priority": "0", + "project_id": cls.project_customer.id, + "partner_id": cls.partner.id, + } + ) + cls.task2 = cls.env["project.task"].create( + { + "name": "Task Two", + "priority": "1", + "project_id": cls.project_customer.id, + } + ) + # users + cls.user_employee = cls.env["res.users"].create( + { + "name": "User Employee", + "login": "user_employee", + "email": "useremployee@test.com", + "group_ids": [ + (6, 0, [cls.env.ref("hr_timesheet.group_hr_timesheet_user").id]) + ], + } + ) + + # employees + cls.empl_employee = cls.env["hr.employee"].create( + { + "name": "User Empl Employee", + "user_id": cls.user_employee.id, + } + ) diff --git a/hr_timesheet_name_customer/tests/test_name_customer.py b/hr_timesheet_name_customer/tests/test_name_customer.py new file mode 100644 index 0000000000..f100802c1d --- /dev/null +++ b/hr_timesheet_name_customer/tests/test_name_customer.py @@ -0,0 +1,57 @@ +# Copyright 2023-nowdays Cetmix OU (https://cetmix.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from .common import TestCommonNameCustomer + + +class TestTimesheet(TestCommonNameCustomer): + def test_01_create_default(self): + """Test unset Customer Description: check name equality""" + Timesheet = self.env["account.analytic.line"] + timesheet = Timesheet.with_user(self.user_employee).create( + { + "project_id": self.project_customer.id, + "task_id": self.task1.id, + "name": "my first timesheet", + } + ) + self.assertEqual(timesheet.name_customer, "my first timesheet") + + def test_02_update_recompute(self): + """Test if name_customer recomputes when name changes""" + Timesheet = self.env["account.analytic.line"] + timesheet = Timesheet.with_user(self.user_employee).create( + { + "project_id": self.project_customer.id, + "task_id": self.task1.id, + "name": "initial", + } + ) + timesheet.name = "updated" + # Force recompute if necessary + timesheet._compute_name_customer() + self.assertEqual(timesheet.name_customer, "updated") + + def test_03_explicit_value(self): + """Test when Customer Description is explicitly set""" + Timesheet = self.env["account.analytic.line"] + timesheet = Timesheet.with_user(self.user_employee).create( + { + "project_id": self.project_customer.id, + "task_id": self.task2.id, + "name": "technical name", + "name_customer": "customer friendly name", + } + ) + self.assertEqual(timesheet.name_customer, "customer friendly name") + + def test_04_empty_name(self): + """Test with empty name""" + Timesheet = self.env["account.analytic.line"] + timesheet = Timesheet.with_user(self.user_employee).create( + { + "project_id": self.project_customer.id, + "task_id": self.task1.id, + "name": False, + } + ) + self.assertFalse(timesheet.name_customer) diff --git a/hr_timesheet_name_customer/views/hr_timesheet_name_customer_views.xml b/hr_timesheet_name_customer/views/hr_timesheet_name_customer_views.xml new file mode 100644 index 0000000000..ffe9210469 --- /dev/null +++ b/hr_timesheet_name_customer/views/hr_timesheet_name_customer_views.xml @@ -0,0 +1,17 @@ + + + + Name Customer + account.analytic.line + + + + + + + + diff --git a/hr_timesheet_name_customer/views/project_portal_templates.xml b/hr_timesheet_name_customer/views/project_portal_templates.xml new file mode 100644 index 0000000000..8e752e1631 --- /dev/null +++ b/hr_timesheet_name_customer/views/project_portal_templates.xml @@ -0,0 +1,28 @@ + + + + + +