mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] project_acceptance: change on controllers and modal view available
H11043
This commit is contained in:
@@ -5,15 +5,19 @@ from odoo.addons.portal.controllers import mail
|
||||
|
||||
|
||||
class PortalChatter(mail.PortalChatter):
|
||||
|
||||
|
||||
|
||||
@http.route()
|
||||
def portal_chatter_post(self, res_model, res_id, message, attachment_ids='', attachment_tokens='', **kwargs):
|
||||
if request.httprequest.method == 'POST':
|
||||
task = request.env['project.task'].browse([res_id])
|
||||
# task.with_context('skip_detect_exceptions').write({'task_acceptance': 'feedback'})
|
||||
task.sudo().ignore_exception = True
|
||||
task.sudo().task_acceptance = 'feedback'
|
||||
task.sudo().ignore_exception = False
|
||||
# try:
|
||||
# task_sudo = self._document_check_access('project.task', res_id, access_token=access_token)
|
||||
# except (AccessError, MissingError):
|
||||
# return {'error': _('Invalid task.')}
|
||||
task.sudo().with_context(skip_detect_exceptions=True).write({'task_acceptance': 'feedback'})
|
||||
# task_sudo.with_context(skip_detect_exceptions=True).write({'task_acceptance': 'feedback'})
|
||||
# task_sudo.ignore_exception = True
|
||||
# task_sudo.task_acceptance = 'feedback'
|
||||
# task_sudo.ignore_exception = False
|
||||
|
||||
return super(PortalChatter, self).portal_chatter_post(res_model, res_id, message, attachment_ids=attachment_ids, attachment_tokens=attachment_tokens, **kwargs)
|
||||
|
||||
@@ -3,30 +3,37 @@ from odoo.http import request
|
||||
|
||||
from odoo.addons.portal.controllers import portal
|
||||
|
||||
|
||||
class CustomerPortal(portal.CustomerPortal):
|
||||
|
||||
@http.route('/my/task/<int:task_id>/accept', type='http', auth="user", website=True)
|
||||
|
||||
@http.route('/my/task/<int:task_id>/accept', type='http', auth="user", methods=['POST'], website=True)
|
||||
def portal_task_accept(self, task_id, access_token=None, **post):
|
||||
if request.httprequest.method == 'POST':
|
||||
task = request.env['project.task'].browse([task_id])
|
||||
# task.with_context('skip_detect_exceptions').write({'task_acceptance': 'accept'})
|
||||
task.sudo().ignore_exception = True
|
||||
task.sudo().task_acceptance = 'accept'
|
||||
task.sudo().ignore_exception = False
|
||||
|
||||
|
||||
@http.route(['/my/task/<int:task_id>/decline'], type='http', auth="user", website=True)
|
||||
|
||||
try:
|
||||
task_sudo = self._document_check_access('project.task', task_id, access_token=access_token)
|
||||
except (AccessError, MissingError):
|
||||
return {'error': _('Invalid task.')}
|
||||
|
||||
task_sudo.with_context(skip_detect_exceptions=True).write({'task_acceptance': 'accept'})
|
||||
# task_sudo.ignore_exception = True
|
||||
# task_sudo.task_acceptance = 'accept'
|
||||
# task_sudo.ignore_exception = False
|
||||
return request.redirect(task_sudo.get_portal_url())
|
||||
|
||||
@http.route(['/my/task/<int:task_id>/decline'], type='http', methods=['POST'], auth="user", website=True)
|
||||
def portal_task_decline(self, task_id, access_token=None, **post):
|
||||
if request.httprequest.method == 'POST':
|
||||
task = request.env['project.task'].browse([task_id])
|
||||
# task.with_context('skip_detect_exceptions').write({'task_acceptance': 'decline'})
|
||||
task.sudo().ignore_exception = True
|
||||
task.sudo().task_acceptance = 'decline'
|
||||
task.sudo().ignore_exception = False
|
||||
|
||||
|
||||
|
||||
|
||||
try:
|
||||
task_sudo = self._document_check_access('project.task', task_id, access_token=access_token)
|
||||
except (AccessError, MissingError):
|
||||
return {'error': _('Invalid task.')}
|
||||
|
||||
task_sudo.with_context(skip_detect_exceptions=True).write({'task_acceptance': 'decline'})
|
||||
# task_sudo.ignore_exception = True
|
||||
# task_sudo.task_acceptance = 'decline'
|
||||
# task_sudo.ignore_exception = False
|
||||
return request.redirect(task_sudo.get_portal_url())
|
||||
|
||||
|
||||
######################################################################
|
||||
# The next code is for modal views and to sign document for acceptance
|
||||
#####################################################################
|
||||
|
||||
Reference in New Issue
Block a user