mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Merge branch 'mig/15.0/project_task_line' into '15.0-test'
mig/15.0/project_task_line into 15.0-test See merge request hibou-io/hibou-odoo/suite!1260
This commit is contained in:
1
project_task_line/__init__.py
Normal file
1
project_task_line/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
21
project_task_line/__manifest__.py
Normal file
21
project_task_line/__manifest__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
'name': 'Project Task Lines',
|
||||
'version': '15.0.1.0.0',
|
||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||
'website': 'https://hibou.io/',
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Tools',
|
||||
'complexity': 'easy',
|
||||
'description': """
|
||||
Adds "todo" lines onto Project Tasks, and improves sub-tasks.
|
||||
""",
|
||||
'depends': [
|
||||
'project',
|
||||
],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'views/project_views.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
}
|
||||
1
project_task_line/models/__init__.py
Normal file
1
project_task_line/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import project
|
||||
58
project_task_line/models/project.py
Normal file
58
project_task_line/models/project.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ProjectTask(models.Model):
|
||||
_inherit = 'project.task'
|
||||
|
||||
line_ids = fields.One2many('project.task.line', 'task_id', string='Todo List')
|
||||
subtask_count_done = fields.Integer(compute='_compute_subtask_count', string="Sub-task Done count")
|
||||
|
||||
@api.depends('child_ids')
|
||||
def _compute_subtask_count(self):
|
||||
for task in self:
|
||||
subtasks = task._get_all_subtasks()
|
||||
task.subtask_count = len(subtasks)
|
||||
task.subtask_count_done = len(subtasks.filtered(lambda t: t.stage_id.is_closed))
|
||||
|
||||
def action_subtask(self):
|
||||
action = self.env.ref('project.action_view_all_task').read()[0]
|
||||
|
||||
# display all subtasks of current task
|
||||
action['domain'] = [('id', 'child_of', self.id), ('id', '!=', self.id)]
|
||||
|
||||
ctx = dict(self.env.context)
|
||||
ctx = {k: v for k, v in ctx.items() if not k.startswith('search_default_')}
|
||||
ctx.update({
|
||||
'default_name': self.env.context.get('name', self.name) + ':',
|
||||
'default_parent_id': self.id, # will give default subtask field in `default_get`
|
||||
'default_company_id': self.env.company.id,
|
||||
})
|
||||
|
||||
action['context'] = ctx
|
||||
|
||||
return action
|
||||
|
||||
|
||||
class ProjectTaskLine(models.Model):
|
||||
_name = 'project.task.line'
|
||||
_description = 'Task Todos'
|
||||
_order = 'sequence, id asc'
|
||||
|
||||
task_id = fields.Many2one('project.task', required=True)
|
||||
name = fields.Char(string='Name')
|
||||
user_id = fields.Many2one('res.users', string='User')
|
||||
sequence = fields.Integer(string='Sequence')
|
||||
kanban_state = fields.Selection([
|
||||
('normal', ''),
|
||||
('done', 'Done'),
|
||||
('blocked', 'Blocked')], string='State',
|
||||
copy=False, default='normal', required=True,
|
||||
help="A task's kanban state indicates special situations affecting it:\n"
|
||||
" * Blank is the default situation\n"
|
||||
" * Blocked indicates something is preventing the progress of this task\n"
|
||||
" * Done indicates the task is complete")
|
||||
|
||||
@api.onchange('kanban_state')
|
||||
def _onchange_kanban_state(self):
|
||||
if self.kanban_state == 'done':
|
||||
self.user_id = self.env.user
|
||||
3
project_task_line/security/ir.model.access.csv
Normal file
3
project_task_line/security/ir.model.access.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_project_task_line","access_project_task_line","model_project_task_line","base.group_user",1,1,1,1
|
||||
"access_project_task_line_public","access_project_task_line public","model_project_task_line","base.group_public",1,0,0,0
|
||||
|
28
project_task_line/views/project_views.xml
Normal file
28
project_task_line/views/project_views.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="view_task_form2_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="//div[@name='button_box']" position="inside">
|
||||
<button name="action_subtask" type="object" class="oe_stat_button" icon="fa-tasks" attrs="{'invisible' : ['|', ('allow_subtasks', '=', False), ('id', '=', False)]}" context="{'default_user_ids': user_ids, 'default_parent_id': id, 'default_project_id': project_id}">
|
||||
<span class="o_stat_value"><field name="subtask_count_done" widget="statinfo" nolabel="1"/> / <field name="subtask_count" widget="statinfo" nolabel="1"/></span>
|
||||
<span class="o_stat_text">Sub-Tasks</span>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='description_page']" position="after">
|
||||
<page name="task_lines" string="Todo List">
|
||||
<field name="line_ids" widget="one2many_list" context="{'default_task_id': id}">
|
||||
<tree editable="bottom">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="name"/>
|
||||
<field name="kanban_state" widget="selection" string="Status"/>
|
||||
<field name="user_id" string="Completed by" options="{'no_create': True, 'no_create_edit': True, 'no_open': True}"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user