mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[MIG] project_task_line: 17.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
'name': 'Project Task Lines',
|
'name': 'Project Task Lines',
|
||||||
'version': '16.0.1.0.0',
|
'version': '17.0.1.0.0',
|
||||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||||
'website': 'https://hibou.io/',
|
'website': 'https://hibou.io/',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
|||||||
14
project_task_line/migrations/17.0.1.0.0/pre-migration.py
Normal file
14
project_task_line/migrations/17.0.1.0.0/pre-migration.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
def migrate(cr, installed_version):
|
||||||
|
cr.execute(
|
||||||
|
"""
|
||||||
|
ALTER TABLE project_task_line
|
||||||
|
ADD COLUMN IF NOT EXISTS state VARCHAR
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
cr.execute(
|
||||||
|
"""
|
||||||
|
UPDATE project_task_line
|
||||||
|
SET state = kanban_state
|
||||||
|
WHERE kanban_state IN ('done', 'blocked')
|
||||||
|
""",
|
||||||
|
)
|
||||||
@@ -5,32 +5,6 @@ class ProjectTask(models.Model):
|
|||||||
_inherit = 'project.task'
|
_inherit = 'project.task'
|
||||||
|
|
||||||
line_ids = fields.One2many('project.task.line', 'task_id', string='Todo List')
|
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.is_closed))
|
|
||||||
|
|
||||||
def action_subtask(self):
|
|
||||||
action = self.env.ref('project.action_view_all_task').sudo().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):
|
class ProjectTaskLine(models.Model):
|
||||||
@@ -40,19 +14,19 @@ class ProjectTaskLine(models.Model):
|
|||||||
|
|
||||||
task_id = fields.Many2one('project.task', required=True)
|
task_id = fields.Many2one('project.task', required=True)
|
||||||
name = fields.Char(string='Name')
|
name = fields.Char(string='Name')
|
||||||
user_id = fields.Many2one('res.users', string='User')
|
user_id = fields.Many2one(
|
||||||
|
'res.users', string='Completed By',
|
||||||
|
context={'active_test': False},
|
||||||
|
compute='_compute_user_id',
|
||||||
|
store=True, readonly=False, precompute=True,
|
||||||
|
)
|
||||||
sequence = fields.Integer(string='Sequence')
|
sequence = fields.Integer(string='Sequence')
|
||||||
kanban_state = fields.Selection([
|
state = fields.Selection([
|
||||||
('normal', ''),
|
|
||||||
('done', 'Done'),
|
('done', 'Done'),
|
||||||
('blocked', 'Blocked')], string='State',
|
('blocked', 'Blocked'),
|
||||||
copy=False, default='normal', required=True,
|
], string='State', copy=False)
|
||||||
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')
|
@api.depends('state')
|
||||||
def _onchange_kanban_state(self):
|
def _compute_user_id(self):
|
||||||
if self.kanban_state == 'done':
|
for line in self.filtered(lambda l: l.state == 'done' and not l.user_id):
|
||||||
self.user_id = self.env.user
|
line.user_id = self.env.user
|
||||||
|
|||||||
@@ -5,20 +5,17 @@
|
|||||||
<field name="model">project.task</field>
|
<field name="model">project.task</field>
|
||||||
<field name="inherit_id" ref="project.view_task_form2" />
|
<field name="inherit_id" ref="project.view_task_form2" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//div[@name='button_box']" position="inside">
|
<xpath expr="//button[@name='%(project.project_task_action_sub_task)d']" position="attributes">
|
||||||
<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}">
|
<attribute name="context">{'default_name': name + ':', 'default_user_ids': user_ids, 'default_project_id': project_id, 'default_milestone_id': milestone_id, 'subtask_action': True}</attribute>
|
||||||
<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>
|
||||||
<xpath expr="//page[@name='description_page']" position="after">
|
<xpath expr="//page[@name='description_page']" position="after">
|
||||||
<page name="task_lines" string="Todo List">
|
<page name="task_lines" string="Todo List">
|
||||||
<field name="line_ids" widget="one2many_list" context="{'default_task_id': id}">
|
<field name="line_ids" context="{'default_task_id': active_id}">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="sequence" widget="handle"/>
|
<field name="sequence" widget="handle"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="kanban_state" widget="selection" string="Status"/>
|
<field name="state" widget="selection"/>
|
||||||
<field name="user_id" string="Completed by" options="{'no_create': True, 'no_create_edit': True, 'no_open': True}"/>
|
<field name="user_id" widget="many2one_avatar_user" domain="[('share', '=', False), ('active', '=', True)]"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
|
|||||||
Reference in New Issue
Block a user