Skip to content

Commit

Permalink
Merge pull request #1 from tarteo/16.0-add-project_scrum-patch
Browse files Browse the repository at this point in the history
Move task to separate file and make project.sprint.project_id optional
  • Loading branch information
adasatorres authored Nov 18, 2024
2 parents 8fcedea + f83addc commit 029e63c
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 91 deletions.
1 change: 1 addition & 0 deletions project_scrum/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"data": [
"security/ir.model.access.csv",
"views/project_sprint_views.xml",
"views/project_task_views.xml",
"views/project_views.xml",
"data/ir_cron_data.xml",
],
Expand Down
1 change: 1 addition & 0 deletions project_scrum/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import project_sprint
from . import project
from . import project_task
37 changes: 6 additions & 31 deletions project_scrum/models/project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo import _, fields, models


class ProjectProject(models.Model):
Expand All @@ -22,8 +21,11 @@ def _compute_backlog_count(self):
)

def _compute_sprint_count(self):
unassigned_sprint_count = self.env["project.sprint"].search(
[("project_id", "=", False)], count=True
)
for project in self:
project.sprint_count = len(project.sprint_ids)
project.sprint_count = len(project.sprint_ids) + unassigned_sprint_count

def action_sprints(self):
self.ensure_one()
Expand All @@ -32,7 +34,7 @@ def action_sprints(self):
"type": "ir.actions.act_window",
"res_model": "project.sprint",
"view_mode": "tree,form,timeline",
"domain": [("project_id", "=", self.id)],
"domain": ["|", ("project_id", "=", self.id), ("project_id", "=", False)],
"context": {"default_project_id": self.id},
}

Expand Down Expand Up @@ -61,30 +63,3 @@ def action_sprint_timeline(self):
"domain": [("project_id", "=", self.id), ("sprint_id", "!=", False)],
"context": {"default_project_id": self.id, "no_create": True},
}


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

sprint_id = fields.Many2one(
comodel_name="project.sprint",
string="Sprint",
track_visibility="onchange",
)

sprint_state = fields.Selection(
related="sprint_id.state", string="Sprint State", store=True
)

@api.constrains("user_ids")
def _check_user_ids(self):
for task in self:
if task.user_ids and task.sprint_id:
if not task.user_ids <= task.sprint_id.user_ids:
raise ValidationError(
_("The assignees must be part of the sprint.")
)

@api.onchange("sprint_id")
def _onchange_sprint_id(self):
self.user_ids = False
1 change: 0 additions & 1 deletion project_scrum/models/project_sprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class ProjectSprint(models.Model):
comodel_name="project.project",
string="Project",
track_visibility="onchange",
required=True,
)
task_ids = fields.One2many(
comodel_name="project.task",
Expand Down
30 changes: 30 additions & 0 deletions project_scrum/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


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

sprint_id = fields.Many2one(
comodel_name="project.sprint",
string="Sprint",
track_visibility="onchange",
domain="['|', ('project_id', '=', False), ('project_id', '=', project_id)]",
)

sprint_state = fields.Selection(
related="sprint_id.state", string="Sprint State", store=True
)

@api.constrains("user_ids")
def _check_user_ids(self):
for task in self:
if task.user_ids and task.sprint_id:
if not task.user_ids <= task.sprint_id.user_ids:
raise ValidationError(
_("The assignees must be part of the sprint.")
)

@api.onchange("sprint_id")
def _onchange_sprint_id(self):
self.user_ids = False
11 changes: 7 additions & 4 deletions project_scrum/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -420,7 +421,9 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
1 change: 1 addition & 0 deletions project_scrum/views/project_sprint_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<field
name="date_end"
attrs="{'readonly' : [('date_option', '!=', 'custom')]}"
force_save="1"
/>
</group>
<field name="description" />
Expand Down
59 changes: 59 additions & 0 deletions project_scrum/views/project_task_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="project_task_inherit_form_view" model="ir.ui.view">
<field name="name">project.task.inherit.form.view</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2" />
<field name="arch" type="xml">
<xpath expr="//field[@name='project_id']" position="after">
<field name="sprint_id" />
</xpath>
</field>
</record>
<record id="project_task_inherit_tree_view" model="ir.ui.view">
<field name="name">project.task.inherit.tree.view</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_tree2" />
<field name="arch" type="xml">
<xpath expr="//field[@name='project_id']" position="after">
<field name="sprint_id" />
</xpath>
</field>
</record>
<record id="project_task_inherit_search_view" model="ir.ui.view">
<field name="name">project.task.inherit.search.view</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_search_form" />
<field name="arch" type="xml">
<xpath expr="//group" position="before">
<separator />
<filter
name="sprint_in_progress_task"
string="Sprint In Progress"
domain="[('sprint_state', '=', 'in_progress')]"
/>
</xpath>
<xpath expr="//group" position="inside">
<filter
name="sprint_id"
string="Sprint"
context="{'group_by':'sprint_id'}"
/>
</xpath>
</field>
</record>
<record id="view_task_timeline" model="ir.ui.view">
<field name="model">project.task</field>
<field name="type">timeline</field>
<field name="inherit_id" ref="project_timeline.project_task_timeline" />
<field name="arch" type="xml">
<xpath expr="//timeline" position="attributes">
<attribute name="default_group_by">sprint_id</attribute>
<attribute name="event_open_popup">False</attribute>
<attribute name="dependency_arrows">False</attribute>
</xpath>

</field>
</record>

</odoo>
55 changes: 0 additions & 55 deletions project_scrum/views/project_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,59 +64,4 @@
</xpath>
</field>
</record>
<record id="project_task_inherit_form_view" model="ir.ui.view">
<field name="name">project.task.inherit.form.view</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2" />
<field name="arch" type="xml">
<xpath expr="//field[@name='project_id']" position="after">
<field name="sprint_id" />
</xpath>
</field>
</record>
<record id="project_task_inherit_tree_view" model="ir.ui.view">
<field name="name">project.task.inherit.tree.view</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_tree2" />
<field name="arch" type="xml">
<xpath expr="//field[@name='project_id']" position="after">
<field name="sprint_id" />
</xpath>
</field>
</record>
<record id="project_task_inherit_search_view" model="ir.ui.view">
<field name="name">project.task.inherit.search.view</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_search_form" />
<field name="arch" type="xml">
<xpath expr="//group" position="before">
<separator />
<filter
name="sprint_in_progress_task"
string="Sprint In Progress"
domain="[('sprint_state', '=', 'in_progress')]"
/>
</xpath>
<xpath expr="//group" position="inside">
<filter
name="sprint_id"
string="Sprint"
context="{'group_by':'sprint_id'}"
/>
</xpath>
</field>
</record>
<record id="view_task_timeline" model="ir.ui.view">
<field name="model">project.task</field>
<field name="type">timeline</field>
<field name="inherit_id" ref="project_timeline.project_task_timeline" />
<field name="arch" type="xml">
<xpath expr="//timeline" position="attributes">
<attribute name="default_group_by">sprint_id</attribute>
<attribute name="event_open_popup">False</attribute>
<attribute name="dependency_arrows">False</attribute>
</xpath>

</field>
</record>
</odoo>

0 comments on commit 029e63c

Please sign in to comment.