summaryrefslogtreecommitdiff
path: root/addons/project/models/project.py
diff options
context:
space:
mode:
authorKevin Baptiste <kba@odoo.com>2020-03-04 14:48:17 +0000
committerYannick Tivisse <yti@odoo.com>2020-04-08 14:29:50 +0000
commit58a90952edb715dc89d46d953fb23be3158396da (patch)
treea67927e150b09e42e0db290b4481a8dfd0c055e4 /addons/project/models/project.py
parent6b41dbf6831517523d47ef31a48558613d86a741 (diff)
[IMP] project: improve usability (back2basics)
* Reword tasks in the sample project * Add a "Create and Edit" button on the project creation modal * Open the file chooser in "Set a cover image" if there are no images set * Correclty display the kanban state button on archived task * Add a button to list the tasks when deleting a project * Open file chooser for cover image: Automatically open the file chooser when setting a cover image on a task if there are no attachments to chose from. closes odoo/odoo#47306 Taskid: 2209133 Related: odoo/enterprise#9141 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/project/models/project.py')
-rw-r--r--addons/project/models/project.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/addons/project/models/project.py b/addons/project/models/project.py
index 09fef75a8a7..dea89f2c05e 100644
--- a/addons/project/models/project.py
+++ b/addons/project/models/project.py
@@ -5,7 +5,7 @@ import ast
from datetime import timedelta
from odoo import api, fields, models, tools, SUPERUSER_ID, _
-from odoo.exceptions import UserError, AccessError, ValidationError
+from odoo.exceptions import UserError, AccessError, ValidationError, RedirectWarning
from odoo.tools.misc import format_date
@@ -132,6 +132,10 @@ class Project(models.Model):
Create a new project</p>''')
})
action_data = action.read()[0]
+
+ action_config = self.env.ref('project.open_view_project_all_config', False)
+ if action_config:
+ action_config.sudo().write({'help': action.help})
# Reload the dashboard
return action_data
@@ -352,6 +356,22 @@ class Project(models.Model):
return res
+ def action_unlink(self):
+ wizard = self.env['project.delete.wizard'].create({
+ 'project_ids': self.ids
+ })
+
+ return {
+ 'name': _('Confirmation'),
+ 'view_mode': 'form',
+ 'res_model': 'project.delete.wizard',
+ 'views': [(self.env.ref('project.project_delete_wizard_form').id, 'form')],
+ 'type': 'ir.actions.act_window',
+ 'res_id': wizard.id,
+ 'target': 'new',
+ 'context': self.env.context,
+ }
+
def unlink(self):
# Check project is empty
for project in self.with_context(active_test=False):
@@ -507,9 +527,9 @@ class Task(models.Model):
domain="[('project_ids', '=', project_id)]", copy=False)
tag_ids = fields.Many2many('project.tags', string='Tags')
kanban_state = fields.Selection([
- ('normal', 'Grey'),
- ('done', 'Green'),
- ('blocked', 'Red')], string='Kanban State',
+ ('normal', 'In Progress'),
+ ('done', 'Ready'),
+ ('blocked', 'Blocked')], string='Kanban State',
copy=False, default='normal', required=True)
kanban_state_label = fields.Char(compute='_compute_kanban_state_label', string='Kanban State Label', tracking=True)
create_date = fields.Datetime("Created On", readonly=True, index=True)
@@ -943,6 +963,11 @@ class Task(models.Model):
return headers
def _message_post_after_hook(self, message, msg_vals):
+ if message.attachment_ids and not self.displayed_image_id:
+ image_attachments = message.attachment_ids.filtered(lambda a: a.mimetype == 'image')
+ if image_attachments:
+ self.displayed_image_id = image_attachments[0]
+
if self.email_from and not self.partner_id:
# we consider that posting a message with a specified recipient (not a follower, a specific one)
# on a document without customer means that it was created through the chatter using