[IMP] various: action buttons in notifications
Main addons updated : - crm: Conversion and Won / Lost actions - hr_holidays: Approve / Refuse for hr users / officers - project: Assign / New (task and issues) - forum, website_project_issue, website_portal_sale: go to the website view
This commit is contained in:
+33
-1
@@ -5,8 +5,8 @@ from datetime import datetime, timedelta, date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import logging
|
||||
from operator import itemgetter
|
||||
from werkzeug import url_encode
|
||||
|
||||
import openerp
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp import tools, api
|
||||
from openerp.addons.base.res.res_partner import format_address
|
||||
@@ -935,6 +935,38 @@ Update your business card, phone book, social media,... Send an email right now
|
||||
return 'crm.mt_lead_stage'
|
||||
return super(crm_lead, self)._track_subtype(cr, uid, ids, init_values, context=context)
|
||||
|
||||
def _notification_group_recipients(self, cr, uid, ids, message, recipients, done_ids, group_data, context=None):
|
||||
""" Override the mail.thread method to handle salesman recipients.
|
||||
Indeed those will have specific action in their notification emails. """
|
||||
group_sale_salesman = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'base.group_sale_salesman')
|
||||
for recipient in recipients:
|
||||
if recipient.id in done_ids:
|
||||
continue
|
||||
if recipient.user_ids and group_sale_salesman in recipient.user_ids[0].groups_id.ids:
|
||||
group_data['group_sale_salesman'] |= recipient
|
||||
done_ids.add(recipient.id)
|
||||
return super(crm_lead, self)._notification_group_recipients(cr, uid, ids, message, recipients, done_ids, group_data, context=context)
|
||||
|
||||
def _notification_get_recipient_groups(self, cr, uid, ids, message, recipients, context=None):
|
||||
res = super(crm_lead, self)._notification_get_recipient_groups(cr, uid, ids, message, recipients, context=context)
|
||||
|
||||
won_action = self._notification_link_helper(cr, uid, ids, 'method', context=context, method='case_mark_won')
|
||||
lost_action = self._notification_link_helper(cr, uid, ids, 'method', context=context, method='case_mark_lost')
|
||||
convert_action = self._notification_link_helper(cr, uid, ids, 'method', context=context, method='convert_opportunity')
|
||||
|
||||
lead = self.browse(cr, uid, ids[0], context=context)
|
||||
if lead.type == 'lead':
|
||||
res['group_sale_salesman'] = {
|
||||
'actions': [{'url': convert_action, 'title': 'Convert to opportunity'}]
|
||||
}
|
||||
else:
|
||||
res['group_sale_salesman'] = {
|
||||
'actions': [
|
||||
{'url': won_action, 'title': 'Won'},
|
||||
{'url': lost_action, 'title': 'Lost'}]
|
||||
}
|
||||
return res
|
||||
|
||||
@api.cr_uid_context
|
||||
def message_get_reply_to(self, cr, uid, ids, default=None, context=None):
|
||||
""" Override to get the reply_to of the parent project. """
|
||||
|
||||
@@ -154,6 +154,38 @@ class hr_expense_expense(osv.osv):
|
||||
return 'hr_expense.mt_expense_refused'
|
||||
return super(hr_expense_expense, self)._track_subtype(cr, uid, ids, init_values, context=context)
|
||||
|
||||
def _notification_group_recipients(self, cr, uid, ids, message, recipients, done_ids, group_data, context=None):
|
||||
""" Override because HR users / officers can approve / refuse expenses
|
||||
directly form their notification email. """
|
||||
group_hr_user = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'base.group_hr_user')
|
||||
for recipient in recipients:
|
||||
if recipient.id in done_ids:
|
||||
continue
|
||||
if recipient.user_ids and group_hr_user in recipient.user_ids[0].groups_id.ids:
|
||||
group_data['group_hr_user'] |= recipient
|
||||
done_ids.add(recipient.id)
|
||||
return super(hr_expense_expense, self)._notification_group_recipients(cr, uid, ids, message, recipients, done_ids, group_data, context=context)
|
||||
|
||||
def _notification_get_recipient_groups(self, cr, uid, ids, message, recipients, context=None):
|
||||
""" Override because HR users / officers can approve / refuse expenses
|
||||
directly form their notification email. """
|
||||
res = super(hr_expense_expense, self)._notification_get_recipient_groups(cr, uid, ids, message, recipients, context=context)
|
||||
|
||||
app_action = self._notification_link_helper(cr, uid, ids, 'workflow', context=context, signal='validate')
|
||||
ref_action = self._notification_link_helper(cr, uid, ids, 'workflow', context=context, signal='refuse')
|
||||
|
||||
expense = self.browse(cr, uid, ids[0], context=context)
|
||||
actions = []
|
||||
if expense.state == 'confirm':
|
||||
actions.append({'url': app_action, 'title': _('Approve')})
|
||||
if expense.state in ['confirm', 'accepted']:
|
||||
actions.append({'url': ref_action, 'title': _('Refuse')})
|
||||
|
||||
res['group_hr_user'] = {
|
||||
'actions': actions
|
||||
}
|
||||
return res
|
||||
|
||||
def account_move_get(self, cr, uid, expense_id, context=None):
|
||||
'''
|
||||
This method prepare the creation of the account move related to the given expense.
|
||||
|
||||
@@ -11,6 +11,7 @@ import logging
|
||||
import math
|
||||
import time
|
||||
from operator import attrgetter
|
||||
from werkzeug import url_encode
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
@@ -487,6 +488,37 @@ class hr_holidays(osv.osv):
|
||||
return 'hr_holidays.mt_holidays_refused'
|
||||
return super(hr_holidays, self)._track_subtype(cr, uid, ids, init_values, context=context)
|
||||
|
||||
def _notification_group_recipients(self, cr, uid, ids, message, recipients, done_ids, group_data, context=None):
|
||||
""" Override the mail.thread method to handle HR users and officers
|
||||
recipients. Indeed those will have specific action in their notification
|
||||
emails. """
|
||||
group_hr_user = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'base.group_hr_user')
|
||||
for recipient in recipients:
|
||||
if recipient.id in done_ids:
|
||||
continue
|
||||
if recipient.user_ids and group_hr_user in recipient.user_ids[0].groups_id.ids:
|
||||
group_data['group_hr_user'] |= recipient
|
||||
done_ids.add(recipient.id)
|
||||
return super(hr_holidays, self)._notification_group_recipients(cr, uid, ids, message, recipients, done_ids, group_data, context=context)
|
||||
|
||||
def _notification_get_recipient_groups(self, cr, uid, ids, message, recipients, context=None):
|
||||
res = super(hr_holidays, self)._notification_get_recipient_groups(cr, uid, ids, message, recipients, context=context)
|
||||
|
||||
app_action = '/mail/workflow?%s' % url_encode({'model': self._name, 'res_id': ids[0], 'signal': 'validate'})
|
||||
ref_action = '/mail/workflow?%s' % url_encode({'model': self._name, 'res_id': ids[0], 'signal': 'refuse'})
|
||||
|
||||
holiday = self.browse(cr, uid, ids[0], context=context)
|
||||
actions = []
|
||||
if holiday.state == 'confirm':
|
||||
actions.append({'url': app_action, 'title': 'Approve'})
|
||||
if holiday.state in ['confirm', 'validate', 'validate1']:
|
||||
actions.append({'url': ref_action, 'title': 'Refuse'})
|
||||
|
||||
res['group_hr_user'] = {
|
||||
'actions': actions
|
||||
}
|
||||
return res
|
||||
|
||||
|
||||
class resource_calendar_leaves(osv.osv):
|
||||
_inherit = "resource.calendar.leaves"
|
||||
|
||||
+8
-1
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp import _, SUPERUSER_ID
|
||||
from openerp.osv import osv, fields
|
||||
from openerp.tools import html2plaintext
|
||||
|
||||
@@ -156,6 +156,13 @@ class note_note(osv.osv):
|
||||
return super(note_note, self).read_group(cr, uid, domain, fields, groupby,
|
||||
offset=offset, limit=limit, context=context, orderby=orderby,lazy=lazy)
|
||||
|
||||
def _notification_get_recipient_groups(self, cr, uid, ids, message, recipients, context=None):
|
||||
res = super(note_note, self)._notification_get_recipient_groups(cr, uid, ids, message, recipients, context=context)
|
||||
res['user'] = {
|
||||
'actions': [{'url': self._notification_link_helper(cr, uid, ids, 'new', context=context), 'title': _('New Note')}]
|
||||
}
|
||||
return res
|
||||
|
||||
|
||||
class res_users(osv.Model):
|
||||
_name = 'res.users'
|
||||
|
||||
@@ -752,6 +752,37 @@ class task(osv.osv):
|
||||
return 'project.mt_task_stage'
|
||||
return super(task, self)._track_subtype(cr, uid, ids, init_values, context=context)
|
||||
|
||||
def _notification_group_recipients(self, cr, uid, ids, message, recipients, done_ids, group_data, context=None):
|
||||
""" Override the mail.thread method to handle project users and officers
|
||||
recipients. Indeed those will have specific action in their notification
|
||||
emails: creating tasks, assigning it. """
|
||||
group_project_user = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'project.group_project_user')
|
||||
for recipient in recipients:
|
||||
if recipient.id in done_ids:
|
||||
continue
|
||||
if recipient.user_ids and group_project_user in recipient.user_ids[0].groups_id.ids:
|
||||
group_data['group_project_user'] |= recipient
|
||||
done_ids.add(recipient.id)
|
||||
return super(task, self)._notification_group_recipients(cr, uid, ids, message, recipients, done_ids, group_data, context=context)
|
||||
|
||||
def _notification_get_recipient_groups(self, cr, uid, ids, message, recipients, context=None):
|
||||
res = super(task, self)._notification_get_recipient_groups(cr, uid, ids, message, recipients, context=context)
|
||||
|
||||
take_action = self._notification_link_helper(cr, uid, ids, 'assign', context=context)
|
||||
new_action = self._notification_link_helper(cr, uid, ids, 'new', context=context, view_xmlid='project.action_view_task')
|
||||
|
||||
task_record = self.browse(cr, uid, ids[0], context=context)
|
||||
actions = []
|
||||
if not task_record.user_id:
|
||||
actions.append({'url': take_action, 'title': _('I take it')})
|
||||
else:
|
||||
actions.append({'url': new_action, 'title': _('New Task')})
|
||||
|
||||
res['group_project_user'] = {
|
||||
'actions': actions
|
||||
}
|
||||
return res
|
||||
|
||||
@api.cr_uid_context
|
||||
def message_get_reply_to(self, cr, uid, ids, default=None, context=None):
|
||||
""" Override to get the reply_to of the parent project. """
|
||||
|
||||
@@ -316,6 +316,38 @@ class project_issue(osv.Model):
|
||||
return 'project_issue.mt_issue_stage'
|
||||
return super(project_issue, self)._track_subtype(cr, uid, ids, init_values, context=context)
|
||||
|
||||
def _notification_group_recipients(self, cr, uid, ids, message, recipients, done_ids, group_data, context=None):
|
||||
""" Override the mail.thread method to handle project users and officers
|
||||
recipients. Indeed those will have specific action in their notification
|
||||
emails: creating tasks, assigning it. """
|
||||
group_project_user = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'project.group_project_user')
|
||||
for recipient in recipients:
|
||||
if recipient.id in done_ids:
|
||||
continue
|
||||
if recipient.user_ids and group_project_user in recipient.user_ids[0].groups_id.ids:
|
||||
group_data['group_project_user'] |= recipient
|
||||
done_ids.add(recipient.id)
|
||||
return super(project_issue, self)._notification_group_recipients(cr, uid, ids, message, recipients, done_ids, group_data, context=context)
|
||||
|
||||
def _notification_get_recipient_groups(self, cr, uid, ids, message, recipients, context=None):
|
||||
res = super(project_issue, self)._notification_get_recipient_groups(cr, uid, ids, message, recipients, context=context)
|
||||
|
||||
new_action_id = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'project_issue.project_issue_categ_act0')
|
||||
take_action = self._notification_link_helper(cr, uid, ids, 'assign', context=context)
|
||||
new_action = self._notification_link_helper(cr, uid, ids, 'new', context=context, view_id=new_action_id)
|
||||
|
||||
task_record = self.browse(cr, uid, ids[0], context=context)
|
||||
actions = []
|
||||
if not task_record.user_id:
|
||||
actions.append({'url': take_action, 'title': _('I take it')})
|
||||
else:
|
||||
actions.append({'url': new_action, 'title': _('New Issue')})
|
||||
|
||||
res['group_project_user'] = {
|
||||
'actions': actions
|
||||
}
|
||||
return res
|
||||
|
||||
@api.cr_uid_context
|
||||
def message_get_reply_to(self, cr, uid, ids, default=None, context=None):
|
||||
""" Override to get the reply_to of the parent project. """
|
||||
|
||||
@@ -245,6 +245,27 @@ class BlogPost(osv.Model):
|
||||
self._check_for_publication(cr, uid, ids, vals, context=context)
|
||||
return result
|
||||
|
||||
def get_access_action(self, cr, uid, id, context=None):
|
||||
""" Override method that generated the link to access the document. Instead
|
||||
of the classic form view, redirect to the post on the website directly """
|
||||
post = self.browse(cr, uid, id, context=context)
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': '/blog/%s/post/%s' % (post.blog_id.id, post.id),
|
||||
'target': 'self',
|
||||
'res_id': self.id,
|
||||
}
|
||||
|
||||
def _notification_get_recipient_groups(self, cr, uid, ids, message, recipients, context=None):
|
||||
""" Override to set the access button: everyone can see an access button
|
||||
on their notification email. It will lead on the website view of the
|
||||
post. """
|
||||
res = super(BlogPost, self)._notification_get_recipient_groups(cr, uid, ids, message, recipients, context=context)
|
||||
access_action = self._notification_link_helper('view', model=message.model, res_id=message.res_id)
|
||||
for category, data in res.iteritems():
|
||||
res[category]['button_access'] = {'url': access_action, 'title': _('View Blog Post')}
|
||||
return res
|
||||
|
||||
|
||||
class Website(osv.Model):
|
||||
_inherit = "website"
|
||||
|
||||
@@ -626,6 +626,17 @@ class Post(models.Model):
|
||||
'res_id': self.id,
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def _notification_get_recipient_groups(self, message, recipients):
|
||||
""" Override to set the access button: everyone can see an access button
|
||||
on their notification email. It will lead on the website view of the
|
||||
post. """
|
||||
res = super(Post, self)._notification_get_recipient_groups(message, recipients)
|
||||
access_action = self._notification_link_helper('view', model=message.model, res_id=message.res_id)
|
||||
for category, data in res.iteritems():
|
||||
res[category]['button_access'] = {'url': access_action, 'title': '%s %s' % (_('View'), self.post_type)}
|
||||
return res
|
||||
|
||||
@api.cr_uid_ids_context
|
||||
def message_post(self, cr, uid, thread_id, message_type='notification', subtype=None, context=None, **kwargs):
|
||||
if thread_id and message_type == 'comment': # user comments have a restriction on karma
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import controllers
|
||||
import models
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import sale_order
|
||||
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from openerp import api, models
|
||||
|
||||
|
||||
class sale_order(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
@api.one
|
||||
def get_access_action(self):
|
||||
""" Override method that generated the link to access the document. Instead
|
||||
of the classic form view, redirect to the online quote if exists. """
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': '/my/orders/%s' % self.id,
|
||||
'target': 'self',
|
||||
'res_id': self.id,
|
||||
}
|
||||
@@ -2,3 +2,4 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import controllers
|
||||
import models
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import project_issue
|
||||
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from openerp import _, api, models
|
||||
|
||||
|
||||
class Issue(models.Model):
|
||||
_name = "project.issue"
|
||||
_inherit = ['project.issue']
|
||||
|
||||
@api.one
|
||||
def get_access_action(self):
|
||||
""" Override method that generated the link to access the document. Instead
|
||||
of the classic form view, redirect to the post on the website directly """
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': '/my/issues/%s' % self.id,
|
||||
'target': 'self',
|
||||
'res_id': self.id,
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def _notification_get_recipient_groups(self, message, recipients):
|
||||
""" Override to set the access button: everyone can see an access button
|
||||
on their notification email. It will lead on the website view of the
|
||||
post. """
|
||||
res = super(Issue, self)._notification_get_recipient_groups(message, recipients)
|
||||
access_action = self._notification_link_helper('view', model=message.model, res_id=message.res_id)
|
||||
for category, data in res.iteritems():
|
||||
res[category]['button_access'] = {'url': access_action, 'title': _('View Issue')}
|
||||
return res
|
||||
Reference in New Issue
Block a user