Skip to content

Commit

Permalink
[ADD] Add module project_task_date_compute (avanzosc#286)
Browse files Browse the repository at this point in the history
Co-authored-by: Ana Juaristi <[email protected]>
  • Loading branch information
unaiberis and anajuaristi authored Jul 2, 2024
1 parent da474a1 commit a3ceea7
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 0 deletions.
29 changes: 29 additions & 0 deletions project_task_date_compute/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

================================
Compute Task Start and End Dates
================================

* Compute the start and end dates of tasks.
* This modules uses timesheet_ids to compute the start and end dates.

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

Bugs are tracked on `GitHub Issues
<https://github.com/avanzosc/project-addons/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

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

Credits
=======

Contributors
------------

* Unai Beristain <[email protected]>
* Ana Juaristi <[email protected]>
1 change: 1 addition & 0 deletions project_task_date_compute/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions project_task_date_compute/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Unai Beristain - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Compute Task Start and End Dates",
"summary": "Module to compute task start and end dates based on time entries and stage",
"website": "https://github.com/avanzosc/project-addons",
"license": "AGPL-3",
"author": "AvanzOSC",
"version": "14.0.1.0.0",
"depends": ["base", "project", "hr_timesheet"],
"data": [
"views/project_task_views.xml",
],
"installable": True,
"auto_install": False,
}
1 change: 1 addition & 0 deletions project_task_date_compute/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import project_task
23 changes: 23 additions & 0 deletions project_task_date_compute/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from odoo import api, fields, models


class ProjectTask(models.Model):
_inherit = "project.task"

start_date = fields.Date(
string="Start Date", compute="_compute_start_date", store=True
)
end_date = fields.Date(string="End Date", compute="_compute_end_date", store=True)

@api.depends("timesheet_ids.date")
def _compute_start_date(self):
for task in self:
task.start_date = min(task.timesheet_ids.mapped("date"), default=False)

@api.depends("timesheet_ids.date", "stage_id")
def _compute_end_date(self):
for task in self:
if task.stage_id.fold:
task.end_date = max(task.timesheet_ids.mapped("date"), default=False)
else:
task.end_date = False
27 changes: 27 additions & 0 deletions project_task_date_compute/views/project_task_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_project_task_tree_inherit" model="ir.ui.view">
<field name="name">project.task.tree.inherit</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_tree2" />
<field name="arch" type="xml">
<xpath expr="//tree" position="inside">
<field name="create_date" />
</xpath>
</field>
</record>

<record id="view_project_task_form_inherit" model="ir.ui.view">
<field name="name">project.task.form.inherit</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2" />
<field name="arch" type="xml">
<xpath expr="//page[@name='extra_info']/group[1]/group[1]" position="after">
<group>
<field name="start_date" />
<field name="end_date" />
</group>
</xpath>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/project_task_date_compute/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit a3ceea7

Please sign in to comment.