diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-05-15 20:18:14 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-05-15 20:18:14 +0200 |
| commit | fa8a67ee5ff6b3bdc15d000bfda0c57350e01aa9 (patch) | |
| tree | 13f57e095568fb456803f5d967b9e582eacd933c /addons/project | |
| parent | 05ef2f24e08a06d586f9dc390878ecd3c069042f (diff) | |
| parent | 5a943390f2abf82883316052ad0eeb601b0194c3 (diff) | |
[MERGE] forward port branch 11.0 up to 5a943390f2a
Diffstat (limited to 'addons/project')
| -rw-r--r-- | addons/project/i18n/project.pot | 6 | ||||
| -rw-r--r-- | addons/project/models/project.py | 20 | ||||
| -rw-r--r-- | addons/project/views/project_views.xml | 10 |
3 files changed, 27 insertions, 9 deletions
diff --git a/addons/project/i18n/project.pot b/addons/project/i18n/project.pot index 5ed93bba242..ae8e38c46ce 100644 --- a/addons/project/i18n/project.pot +++ b/addons/project/i18n/project.pot @@ -1021,6 +1021,12 @@ msgid "Ending Date" msgstr "" #. module: project +#: code:addons/project/models/project.py:556 +#, python-format +msgid "Error! You cannot create recursive hierarchy of task(s)." +msgstr "" + +#. module: project #: sql_constraint:project.project:0 msgid "Error! project start-date must be lower than project end-date." msgstr "" diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 4ca2198b1fc..e02dcf8fac5 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -641,6 +641,12 @@ class Task(models.Model): default['remaining_hours'] = self.planned_hours return super(Task, self).copy(default) + @api.constrains('parent_id') + def _check_parent_id(self): + for task in self: + if not task._check_recursion(): + raise ValidationError(_('Error! You cannot create recursive hierarchy of task(s).')) + # Override view according to the company definition @api.model def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False): @@ -1002,6 +1008,20 @@ class Task(models.Model): 'type': 'ir.actions.act_window' } + def action_subtask(self): + action = self.env.ref('project.project_task_action_sub_task').read()[0] + ctx = self.env.context.copy() + ctx.update({ + 'default_parent_id': self.id, + 'default_project_id': self.env.context.get('project_id', self.project_id.id), + 'default_name': self.env.context.get('name', self.name) + ':', + 'default_partner_id': self.env.context.get('partner_id', self.partner_id.id), + 'search_default_project_id': self.env.context.get('project_id', self.project_id.id), + }) + action['context'] = ctx + action['domain'] = [('id', 'child_of', self.id), ('id', '!=', self.id)] + return action + # --------------------------------------------------- # Rating business # --------------------------------------------------- diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml index dd3d3e18201..41dad0fef65 100644 --- a/addons/project/views/project_views.xml +++ b/addons/project/views/project_views.xml @@ -84,14 +84,6 @@ <field name="name">Sub-tasks</field> <field name="res_model">project.task</field> <field name="view_mode">kanban,tree,form,calendar,pivot,graph</field> - <field name="domain">[('id', 'child_of', active_id), ('id', '!=', active_id)]</field> - <field name="context"> - { - 'default_parent_id' : active_id, - 'default_project_id' : project_id, - 'default_name' : name + ':', - } - </field> <field name="search_view_id" ref="project.view_task_search_form"/> </record> @@ -424,7 +416,7 @@ <sheet string="Task"> <div class="oe_button_box" name="button_box"> <button class="oe_stat_button" icon="fa-tasks" type="object" name="action_open_parent_task" string="Parent Task" attrs="{'invisible' : [('parent_id', '=', False)]}" groups="project.group_subtask_project"/> - <button id="subtask_stat_button" name="%(project_task_action_sub_task)d" type="action" class="oe_stat_button" icon="fa-tasks" + <button name="action_subtask" type="object" class="oe_stat_button" icon="fa-tasks" attrs="{'invisible' : [('parent_id', '!=', False)]}" context="{'project_id': project_id, 'name': name, 'parent_id': id}" groups="project.group_subtask_project"> <field string="Sub-tasks" name="subtask_count" widget="statinfo"/> |
