From dda5c757880e32e394280dcc9d72b0b9d8bd68d7 Mon Sep 17 00:00:00 2001 From: "Aung Ko Ko Lin (Quartile)" <45355704+AungKoKoLin1997@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:09:23 +0630 Subject: [PATCH 1/8] [16.0][3685][ADD] hr_timesheet_unpropagate_project (#35) Co-authored-by: Yoshi Tashiro --- hr_timesheet_unpropagate_project/README.rst | 57 +++ hr_timesheet_unpropagate_project/__init__.py | 1 + .../__manifest__.py | 12 + .../models/__init__.py | 2 + .../models/hr_timesheet.py | 16 + .../models/project_task.py | 18 + .../readme/DESCRIPTION.rst | 6 + .../static/description/index.html | 411 ++++++++++++++++++ 8 files changed, 523 insertions(+) create mode 100644 hr_timesheet_unpropagate_project/README.rst create mode 100644 hr_timesheet_unpropagate_project/__init__.py create mode 100644 hr_timesheet_unpropagate_project/__manifest__.py create mode 100644 hr_timesheet_unpropagate_project/models/__init__.py create mode 100644 hr_timesheet_unpropagate_project/models/hr_timesheet.py create mode 100644 hr_timesheet_unpropagate_project/models/project_task.py create mode 100644 hr_timesheet_unpropagate_project/readme/DESCRIPTION.rst create mode 100644 hr_timesheet_unpropagate_project/static/description/index.html diff --git a/hr_timesheet_unpropagate_project/README.rst b/hr_timesheet_unpropagate_project/README.rst new file mode 100644 index 0000000..f30face --- /dev/null +++ b/hr_timesheet_unpropagate_project/README.rst @@ -0,0 +1,57 @@ +================================ +HR Timesheet Unpropagate Project +================================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-qrtl%2Fqrtl--custom-lightgray.png?logo=github + :target: https://github.com/qrtl/qrtl-custom/tree/16.0/hr_timesheet_unpropagate_project + :alt: qrtl/qrtl-custom + +|badge1| |badge2| |badge3| + +This module changes the behavior of standard Odoo to ensure that when you reassign a +task to a different project, any timesheets linked to that task are not automatically +updated. + +This can be useful in situations where your operation assumes that timesheets may be +linked to different projects than those of their tasks. + +**Table of contents** + +.. contents:: + :local: + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Quartile Limited + +Maintainers +~~~~~~~~~~~ + +This module is part of the `qrtl/qrtl-custom `_ project on GitHub. + +You are welcome to contribute. diff --git a/hr_timesheet_unpropagate_project/__init__.py b/hr_timesheet_unpropagate_project/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/hr_timesheet_unpropagate_project/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hr_timesheet_unpropagate_project/__manifest__.py b/hr_timesheet_unpropagate_project/__manifest__.py new file mode 100644 index 0000000..04ffbdf --- /dev/null +++ b/hr_timesheet_unpropagate_project/__manifest__.py @@ -0,0 +1,12 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "HR Timesheet Unpropagate Project", + "category": "Timesheet", + "version": "16.0.1.0.0", + "author": "Quartile Limited", + "website": "https://www.quartile.co", + "license": "AGPL-3", + "depends": ["hr_timesheet"], + "installable": True, +} diff --git a/hr_timesheet_unpropagate_project/models/__init__.py b/hr_timesheet_unpropagate_project/models/__init__.py new file mode 100644 index 0000000..270efed --- /dev/null +++ b/hr_timesheet_unpropagate_project/models/__init__.py @@ -0,0 +1,2 @@ +from . import project_task +from . import hr_timesheet diff --git a/hr_timesheet_unpropagate_project/models/hr_timesheet.py b/hr_timesheet_unpropagate_project/models/hr_timesheet.py new file mode 100644 index 0000000..d65a0de --- /dev/null +++ b/hr_timesheet_unpropagate_project/models/hr_timesheet.py @@ -0,0 +1,16 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class AccountAnalyticLine(models.Model): + _inherit = "account.analytic.line" + + def _compute_project_id(self): + model = self._context.get("params", {}).get("model") + if model and model == "project.task": + # Avoid updating the project of existing timesheet records when project + # assignment is changed in the task. + return + super()._compute_project_id() diff --git a/hr_timesheet_unpropagate_project/models/project_task.py b/hr_timesheet_unpropagate_project/models/project_task.py new file mode 100644 index 0000000..12318ab --- /dev/null +++ b/hr_timesheet_unpropagate_project/models/project_task.py @@ -0,0 +1,18 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class ProjectTask(models.Model): + _inherit = "project.task" + + def _get_timesheet(self): + if self._context.get("task_write"): + # To avoid updating the project of existing timesheet records. + return self.env["account.analytic.line"] + return super()._get_timesheet() + + def write(self, values): + self = self.with_context(task_write=True) + return super().write(values) diff --git a/hr_timesheet_unpropagate_project/readme/DESCRIPTION.rst b/hr_timesheet_unpropagate_project/readme/DESCRIPTION.rst new file mode 100644 index 0000000..a1dcfce --- /dev/null +++ b/hr_timesheet_unpropagate_project/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module changes the behavior of standard Odoo to ensure that when you reassign a +task to a different project, any timesheets linked to that task are not automatically +updated. + +This can be useful in situations where your operation assumes that timesheets may be +linked to different projects than those of their tasks. diff --git a/hr_timesheet_unpropagate_project/static/description/index.html b/hr_timesheet_unpropagate_project/static/description/index.html new file mode 100644 index 0000000..d1f33fb --- /dev/null +++ b/hr_timesheet_unpropagate_project/static/description/index.html @@ -0,0 +1,411 @@ + + + + + + +HR Timesheet Unpropagate Project + + + +
+

HR Timesheet Unpropagate Project

+ + +

Beta License: AGPL-3 qrtl/qrtl-custom

+

This module changes the behavior of standard Odoo to ensure that when you reassign a +task to a different project, any timesheets linked to that task are not automatically +updated.

+

This can be useful in situations where your operation assumes that timesheets may be +linked to different projects than those of their tasks.

+

Table of contents

+ +
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Quartile Limited
  • +
+
+
+

Maintainers

+

This module is part of the qrtl/qrtl-custom project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + From ec94e61ae5fc4a8f60467bff43a65c97f331deed Mon Sep 17 00:00:00 2001 From: "Yoshi Tashiro (Quartile)" Date: Sat, 9 Sep 2023 12:59:18 +0900 Subject: [PATCH 2/8] [3685][FIX] hr_timesheet_unpropagate_project: _compute_project_id() (#36) Before this commit, the issue of project propagation from updating task's project was still happening when user opens the task form via timesheet records. This commit fixes the issue by not relying on the context value. --- .../models/hr_timesheet.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hr_timesheet_unpropagate_project/models/hr_timesheet.py b/hr_timesheet_unpropagate_project/models/hr_timesheet.py index d65a0de..d3d9a5a 100644 --- a/hr_timesheet_unpropagate_project/models/hr_timesheet.py +++ b/hr_timesheet_unpropagate_project/models/hr_timesheet.py @@ -8,9 +8,9 @@ class AccountAnalyticLine(models.Model): _inherit = "account.analytic.line" def _compute_project_id(self): - model = self._context.get("params", {}).get("model") - if model and model == "project.task": - # Avoid updating the project of existing timesheet records when project - # assignment is changed in the task. - return - super()._compute_project_id() + # Avoid updating the project of existing timesheet records which are already + # validated or not owned by the current user. + self = self.filtered( + lambda x: not x.validated and x.employee_id.user_id == self.env.user + ) + return super()._compute_project_id() From 66ac4c4321052ad79665812677db392dd026537f Mon Sep 17 00:00:00 2001 From: "Aung Ko Ko Lin (Quartile)" <45355704+AungKoKoLin1997@users.noreply.github.com> Date: Tue, 3 Oct 2023 19:42:48 +0630 Subject: [PATCH 3/8] [3829][UPD] dotfiles (#38) --- hr_timesheet_unpropagate_project/README.rst | 9 ++++-- .../static/description/index.html | 30 ++++++++++--------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/hr_timesheet_unpropagate_project/README.rst b/hr_timesheet_unpropagate_project/README.rst index f30face..333beba 100644 --- a/hr_timesheet_unpropagate_project/README.rst +++ b/hr_timesheet_unpropagate_project/README.rst @@ -2,10 +2,13 @@ HR Timesheet Unpropagate Project ================================ -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:02186f3de6b5866cd2b8a9942cbdc85eb64c228ea30ee13170689feadeafec63 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -17,7 +20,7 @@ HR Timesheet Unpropagate Project :target: https://github.com/qrtl/qrtl-custom/tree/16.0/hr_timesheet_unpropagate_project :alt: qrtl/qrtl-custom -|badge1| |badge2| |badge3| +|badge1| |badge2| |badge3| This module changes the behavior of standard Odoo to ensure that when you reassign a task to a different project, any timesheets linked to that task are not automatically @@ -36,7 +39,7 @@ 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 smashing it by providing a detailed and welcomed +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. diff --git a/hr_timesheet_unpropagate_project/static/description/index.html b/hr_timesheet_unpropagate_project/static/description/index.html index d1f33fb..aaea572 100644 --- a/hr_timesheet_unpropagate_project/static/description/index.html +++ b/hr_timesheet_unpropagate_project/static/description/index.html @@ -1,20 +1,20 @@ - + - + HR Timesheet Unpropagate Project -
-

HR Timesheet Unpropagate Project

+
+ + +Odoo Community Association + +
+

HR Timesheet Unpropagate Project

-

Beta License: AGPL-3 qrtl/qrtl-custom

+

Beta License: AGPL-3 qrtl/qrtl-custom

This module changes the behavior of standard Odoo to ensure that when you reassign a task to a different project, any timesheets linked to that task are not automatically updated.

@@ -387,27 +393,28 @@

HR Timesheet Unpropagate Project

-

Bug Tracker

+

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.

+feedback.

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Quartile Limited
-

Maintainers

-

This module is part of the qrtl/qrtl-custom project on GitHub.

+

Maintainers

+

This module is part of the qrtl/qrtl-custom project on GitHub.

You are welcome to contribute.

+
From 39bced5b2c1cd2f3b56fde42fa8ddd1f6f4a25cb Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Wed, 10 Dec 2025 07:37:58 +0000 Subject: [PATCH 7/8] [MIG] hr_timesheet_unpropagate_project: Migration to 19.0 --- hr_timesheet_unpropagate_project/README.rst | 2 +- .../__manifest__.py | 6 +++--- .../models/__init__.py | 1 - .../models/project_task.py | 18 ------------------ .../static/description/index.html | 2 +- 5 files changed, 5 insertions(+), 24 deletions(-) delete mode 100644 hr_timesheet_unpropagate_project/models/project_task.py diff --git a/hr_timesheet_unpropagate_project/README.rst b/hr_timesheet_unpropagate_project/README.rst index ec69f76..e631c63 100644 --- a/hr_timesheet_unpropagate_project/README.rst +++ b/hr_timesheet_unpropagate_project/README.rst @@ -55,7 +55,7 @@ Credits Authors ------- -* Quartile Limited +* Quartile Maintainers ----------- diff --git a/hr_timesheet_unpropagate_project/__manifest__.py b/hr_timesheet_unpropagate_project/__manifest__.py index 04ffbdf..176c246 100644 --- a/hr_timesheet_unpropagate_project/__manifest__.py +++ b/hr_timesheet_unpropagate_project/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright 2023 Quartile Limited +# Copyright 2023 Quartile (https:/www.quartile.co) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "HR Timesheet Unpropagate Project", "category": "Timesheet", - "version": "16.0.1.0.0", - "author": "Quartile Limited", + "version": "19.0.1.0.0", + "author": "Quartile", "website": "https://www.quartile.co", "license": "AGPL-3", "depends": ["hr_timesheet"], diff --git a/hr_timesheet_unpropagate_project/models/__init__.py b/hr_timesheet_unpropagate_project/models/__init__.py index 270efed..1bc3ba3 100644 --- a/hr_timesheet_unpropagate_project/models/__init__.py +++ b/hr_timesheet_unpropagate_project/models/__init__.py @@ -1,2 +1 @@ -from . import project_task from . import hr_timesheet diff --git a/hr_timesheet_unpropagate_project/models/project_task.py b/hr_timesheet_unpropagate_project/models/project_task.py deleted file mode 100644 index 12318ab..0000000 --- a/hr_timesheet_unpropagate_project/models/project_task.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2023 Quartile Limited -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - -from odoo import models - - -class ProjectTask(models.Model): - _inherit = "project.task" - - def _get_timesheet(self): - if self._context.get("task_write"): - # To avoid updating the project of existing timesheet records. - return self.env["account.analytic.line"] - return super()._get_timesheet() - - def write(self, values): - self = self.with_context(task_write=True) - return super().write(values) diff --git a/hr_timesheet_unpropagate_project/static/description/index.html b/hr_timesheet_unpropagate_project/static/description/index.html index 13c723f..ef8afba 100644 --- a/hr_timesheet_unpropagate_project/static/description/index.html +++ b/hr_timesheet_unpropagate_project/static/description/index.html @@ -405,7 +405,7 @@

Credits

Authors

    -
  • Quartile Limited
  • +
  • Quartile
From b2dd189361577439a996e105050b3902323aca74 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Mon, 22 Jun 2026 10:46:00 +0000 Subject: [PATCH 8/8] [FIX] hr_timesheet_unpropagate_project: add manifest summary and maintainers --- hr_timesheet_unpropagate_project/__manifest__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hr_timesheet_unpropagate_project/__manifest__.py b/hr_timesheet_unpropagate_project/__manifest__.py index 176c246..9a6646d 100644 --- a/hr_timesheet_unpropagate_project/__manifest__.py +++ b/hr_timesheet_unpropagate_project/__manifest__.py @@ -2,11 +2,13 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "HR Timesheet Unpropagate Project", + "summary": "Keep the project of validated or others' timesheet lines unchanged", "category": "Timesheet", "version": "19.0.1.0.0", "author": "Quartile", "website": "https://www.quartile.co", "license": "AGPL-3", + "maintainers": ["AungKoKoLin1997"], "depends": ["hr_timesheet"], "installable": True, }