[IMP] project_acceptance: change on controllers and modal view available

H11043
This commit is contained in:
Leo Pinedo
2022-10-07 20:27:35 +00:00
parent b01f62a202
commit 1f03fd2e7f
7 changed files with 103 additions and 80 deletions

View File

@@ -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)

View File

@@ -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
#####################################################################