_name = "project.issue"
_description = "Project Issue"
_order = "priority, create_date desc"
- _inherit = ['mail.thread']
+ _inherit = ['ir.needaction_mixin', 'mail.thread']
def _compute_day(self, cr, uid, ids, fields, args, context=None):
"""
select=True, help='Sales team to which Case belongs to.\
Define Responsible user and Email account for mail gateway.'),
'partner_id': fields.many2one('res.partner', 'Partner', select=1),
- 'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
- domain="[('partner_id','=',partner_id)]"),
'company_id': fields.many2one('res.company', 'Company'),
'description': fields.text('Description'),
'state': fields.selection([('draft', 'New'), ('open', 'In Progress'), ('cancel', 'Cancelled'), ('done', 'Done'),('pending', 'Pending'), ], 'State', size=16, readonly=True,
_defaults = {
'active': 1,
'partner_id': crm.crm_case._get_default_partner,
- 'partner_address_id': crm.crm_case._get_default_partner_address,
'email_from': crm.crm_case._get_default_email,
'state': 'draft',
'section_id': crm.crm_case._get_section,
return self.set_priority(cr, uid, ids, '3')
def convert_issue_task(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
+
case_obj = self.pool.get('project.issue')
data_obj = self.pool.get('ir.model.data')
task_obj = self.pool.get('project.task')
-
-
- if context is None:
- context = {}
-
+
result = data_obj._get_id(cr, uid, 'project', 'view_task_search_form')
res = data_obj.read(cr, uid, result, ['res_id'])
id2 = data_obj._get_id(cr, uid, 'project', 'view_task_form2')
'task_id': new_task_id,
'state':'pending'
}
- self.convert_to_task_send_note(cr, uid, ids, context)
- cases = self.browse(cr, uid, ids)
- self.case_pending_send_note(cr, uid, ids, context)
- case_obj.write(cr, uid, [bug.id], vals)
+ self.convert_to_task_send_note(cr, uid, [bug.id], context=context)
+ case_obj.write(cr, uid, [bug.id], vals, context=context)
+ self.case_pending_send_note(cr, uid, [bug.id], context=context)
return {
'name': _('Tasks'),
def convert_to_bug(self, cr, uid, ids, context=None):
return self._convert(cr, uid, ids, 'bug_categ', context=context)
- def prev_type(self, cr, uid, ids, context=None):
- for task in self.browse(cr, uid, ids):
- typeid = task.type_id.id
- types = map(lambda x:x.id, task.project_id and task.project_id.type_ids or [])
- if types:
- if typeid and typeid in types:
- index = types.index(typeid)
- self.write(cr, uid, [task.id], {'type_id': index and types[index-1] or False})
- return True
-
def next_type(self, cr, uid, ids, context=None):
for task in self.browse(cr, uid, ids):
typeid = task.type_id.id
self.write(cr, uid, [task.id], {'type_id': types[index+1]})
return True
+ def prev_type(self, cr, uid, ids, context=None):
+ for task in self.browse(cr, uid, ids):
+ typeid = task.type_id.id
+ types = map(lambda x:x.id, task.project_id and task.project_id.type_ids or [])
+ if types:
+ if typeid and typeid in types:
+ index = types.index(typeid)
+ self.write(cr, uid, [task.id], {'type_id': index and types[index-1] or False})
+ return True
+
def write(self, cr, uid, ids, vals, context=None):
#Update last action date every time the user change the stage, the state or send a new email
logged_fields = ['type_id', 'state', 'message_ids']
if any([field in vals for field in logged_fields]):
vals['date_action_last'] = time.strftime('%Y-%m-%d %H:%M:%S')
- if 'type_id' in vals and vals['type_id']:
+ if vals.get('type_id', False):
stage = self.pool.get('project.task.type').browse(cr, uid, vals['type_id'], context=context)
- self.message_append_note(cr, uid, ids, _('System notification'),
- _("changed stage to <b>%s</b>.") % stage.name, type='notification')
+ self.message_append_note(cr, uid, ids, body=_("Stage changed to <b>%s</b>.") % stage.name, context=context)
return super(project_issue, self).write(cr, uid, ids, vals, context)
def onchange_task_id(self, cr, uid, ids, task_id, context=None):
task = self.pool.get('project.task').browse(cr, uid, task_id, context=context)
return {'value':{'user_id': task.user_id.id,}}
- def case_open_send_note(self, cr, uid, ids, context=None):
- for id in ids:
- message = _("has been <b>opened</b>.")
- self.message_append_note(cr, uid, [id],'System Notification', message, context=context)
- return True
-
- def case_close_send_note(self, cr, uid, ids, context=None):
- for id in ids:
- message = _("has been <b>closed</b>.")
- self.message_append_note(cr, uid, [id],'System Notification', message, context=context)
- return True
-
-
- def convert_to_task_send_note(self, cr, uid, ids, context=None):
- for id in ids:
- message = _("has been <b>converted</b> in to task.")
- self.message_append_note(cr, uid, [id], 'System notification', message, context=context)
- return True
-
- def get_needaction_user_ids(self, cr, uid, ids, context=None):
- result = dict.fromkeys(ids, [])
- for obj in self.browse(cr, uid, ids, context=context):
- if obj.state == 'draft' and obj.user_id:
- result[obj.id] = [obj.user_id.id]
- if obj.project_id.user_id:
- result[obj.id] = [obj.project_id.user_id.id]
- return result
-
- def message_get_subscribers(self, cr, uid, ids, context=None):
- sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context);
- for obj in self.browse(cr, uid, ids, context=context):
- if obj.user_id:
- sub_ids.append(obj.user_id.id)
- return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
-
- def case_escalate_send_note(self, cr, uid, ids, context=None):
- for obj in self.browse(cr, uid, ids, context=context):
- if obj.project_id:
- message = _("has been <b>escalated</b> to <em>'%s'</em>.") % (obj.project_id.name)
- obj.message_append_note('' ,message, type='notification', context=context)
- else:
- message = _("has been <b>escalated</b>.")
- obj.message_append_note('' ,message, type='notification', context=context)
- return True
-
- def create_send_note(self, cr, uid, ids, context=None):
- for id in ids:
- message = _("has been <b>created</b>.")
- self.message_append_note(cr, uid, [id], _('System notification'),
- message, type='notification', context=context)
- return True
-
- def case_pending_send_note(self, cr, uid, ids, context=None):
- for id in ids:
- message = _("has been <b>pending<b>.")
- self.message_append_note(cr, uid, [id], 'System Notification', message, context=context)
- return True
-
- def case_reset_send_note(self, cr, uid, ids, context=None):
- for id in ids:
- message =_("has been set as <b>new<b>.")
- self.message_append_note(cr, uid, [id],'System Notification', message, context=context)
- return True
-
- def case_cancel_send_note(self, cr, uid, ids, context=None):
- for id in ids:
- message = _("has been <b>cancelled<b>.")
- self.message_append_note(cr, uid, [id],'System Notification', message, context=context)
- return True
-
def case_reset(self, cr, uid, ids, context=None):
"""Resets case as draft
"""
res = super(project_issue, self).case_reset(cr, uid, ids, context)
self.write(cr, uid, ids, {'date_open': False, 'date_closed': False})
- self.case_reset_send_note(cr, uid, ids, context)
- return res
-
- def case_pending(self, cr, uid, ids, context=None):
- """Marks case as pending"""
- res = super(project_issue, self).case_pending(cr, uid, ids, context)
- self.write(cr, uid, ids, context)
- return res
-
- def case_cancel(self, cr, uid, ids, context=None):
- """Overrides cancel for crm_case for setting probability
- """
- res = super(project_issue, self).case_cancel(cr, uid, ids, context)
- self.write(cr, uid, ids, context)
return res
def create(self, cr, uid, vals, context=None):
return obj_id
def case_open(self, cr, uid, ids, context=None):
- """
- @param self: The object pointer
- @param cr: the current row, from the database cursor,
- @param uid: the current user’s ID for security checks,
- @param ids: List of case's Ids
- """
-
res = super(project_issue, self).case_open(cr, uid, ids, context)
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S'), 'user_id' : uid})
return res
- def case_close(self, cr, uid, ids, context=None):
- """
- @param self: The object pointer
- @param cr: the current row, from the database cursor,
- @param uid: the current user’s ID for security checks,
- @param ids: List of case's Ids
- """
-
- res = super(project_issue, self).case_close(cr, uid, ids, context)
- return res
-
def case_escalate(self, cr, uid, ids, context=None):
- """Escalates case to top level
- @param self: The object pointer
- @param cr: the current row, from the database cursor,
- @param uid: the current user’s ID for security checks,
- @param ids: List of case Ids
- """
cases = self.browse(cr, uid, ids)
for case in cases:
data = {'state' : 'draft'}
else:
raise osv.except_osv(_('Warning !'), _('You cannot escalate this issue.\nThe relevant Project has not configured the Escalation Project!'))
self.write(cr, uid, [case.id], data)
- self.case_escalate_send_note(cr, uid, ids, context=context)
+ self.case_escalate_send_note(cr, uid, [case.id], context)
return True
def message_new(self, cr, uid, msg, custom_values=None, context=None):
default['name'] = issue['name'] + _(' (copy)')
return super(project_issue, self).copy(cr, uid, id, default=default,
context=context)
+
+ # -------------------------------------------------------
+ # OpenChatter methods and notifications
+ # -------------------------------------------------------
+
+ def get_needaction_user_ids(self, cr, uid, ids, context=None):
+ result = dict.fromkeys(ids, [])
+ for obj in self.browse(cr, uid, ids, context=context):
+ if obj.state == 'draft' and obj.user_id:
+ result[obj.id] = [obj.user_id.id]
+ return result
+
+ def message_get_subscribers(self, cr, uid, ids, context=None):
+ sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context);
+ for obj in self.browse(cr, uid, ids, context=context):
+ if obj.user_id:
+ sub_ids.append(obj.user_id.id)
+ return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
+
+ def case_get_note_msg_prefix(self, cr, uid, id, context=None):
+ return 'Project issue '
+
+ def convert_to_task_send_note(self, cr, uid, ids, context=None):
+ message = _("Project issue has been <b>converted</b> in to task.")
+ return self.message_append_note(cr, uid, ids, body=message, context=context)
+
+ def create_send_note(self, cr, uid, ids, context=None):
+ message = _("Project issue has been <b>created</b>.")
+ return self.message_append_note(cr, uid, ids, body=message, context=context)
+
+ def case_escalate_send_note(self, cr, uid, ids, context=None):
+ for obj in self.browse(cr, uid, ids, context=context):
+ if obj.project_id:
+ message = _("has been <b>escalated</b> to <em>'%s'</em>.") % (obj.project_id.name)
+ obj.message_append_note(body=message, context=context)
+ else:
+ message = _("has been <b>escalated</b>.")
+ obj.message_append_note(body=message, context=context)
+ return True
project_issue()