Skip to content

Commit

Permalink
[MIG] project_workload: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Sep 30, 2024
1 parent 552b59a commit e3077db
Show file tree
Hide file tree
Showing 20 changed files with 624 additions and 95 deletions.
74 changes: 74 additions & 0 deletions project_workload/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
================
Project Workload
================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4a176ece35168ce42257a5e9a7415205d47c52fdf0e5c5ebcd5986afc7b180c7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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-akretion%2Fak--odoo--incubator-lightgray.png?logo=github
:target: https://github.com/akretion/ak-odoo-incubator/tree/16.0/project_workload
:alt: akretion/ak-odoo-incubator

|badge1| |badge2| |badge3|

This module allow to manage load and capacity by project and cross project
Load is managed by week

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

TODO
- in case of manual workload assignation add a check on date

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

Bugs are tracked on `GitHub Issues <https://github.com/akretion/ak-odoo-incubator/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/akretion/ak-odoo-incubator/issues/new?body=module:%20project_workload%0Aversion:%2016.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
~~~~~~~

* Akretion

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

* `Akretion <https://www.akretion.com>`_:
* BEAU Sébastien <[email protected]>
* Florian Mounier <[email protected]>

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

This module is part of the `akretion/ak-odoo-incubator <https://github.com/akretion/ak-odoo-incubator/tree/16.0/project_workload>`_ project on GitHub.

You are welcome to contribute.
2 changes: 1 addition & 1 deletion project_workload/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Project Workload",
"summary": "Ressource Workload Management",
"version": "14.0.1.0.0",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"category": "Uncategorized",
"website": "https://github.com/akretion/ak-odoo-incubator",
Expand Down
32 changes: 17 additions & 15 deletions project_workload/models/project_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ProjectTask(models.Model):
"date_start",
"date_end",
"planned_hours",
"user_id",
"user_ids",
"config_workload_manually",
"use_workload",
)
Expand All @@ -44,12 +44,12 @@ def _compute_workload_ids(self):
continue
record.workload_ids = record._get_workload_sync()

def _prepare_workload(self, **extra):
def _prepare_workload(self, user, **extra):
return {
"date_start": self.date_start,
"date_end": self.date_end,
"hours": self.planned_hours,
"user_id": self.user_id.id,
"user_id": user.id,
**extra,
}

Expand All @@ -66,24 +66,26 @@ def _get_workload_sync(self):

def _get_new_workloads(self):
self.ensure_one()
# Handle only one workload in automatic
if not self.workload_ids:
return [self._prepare_workload()]
return []
# Handle only one workload per user in automatic
new_vals = []
for user in self.user_ids:
user_workload = self.workload_ids.filtered(lambda w: w.user_id == user)
if not user_workload:
new_vals.append(self._prepare_workload(user))

return new_vals

def _get_updated_workloads(self):
self.ensure_one()
# Remove other workloads and update the first workload values
if self.workload_ids:
return [(self.workload_ids[0], self._prepare_workload())]
return []
# Update the users workload values
for workload in self.workload_ids:
if workload.user_id in self.user_ids:
yield workload, self._prepare_workload(workload.user_id)

def _get_obsolete_workloads(self):
self.ensure_one()
# Remove other workloads and update the first workload values
if len(self.workload_ids) > 1:
return self.workload_ids[1:]
return []
# Remove other workloads
return self.workload_ids.filtered(lambda w: w.user_id not in self.user_ids)

@api.depends("workload_ids.unit_ids")
def _compute_workload_unit_ids(self):
Expand Down
Loading

0 comments on commit e3077db

Please sign in to comment.