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
|
||||
#####################################################################
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M256 512c141.4 0 256-114.6 256-256S397.4 0 256 0S0 114.6 0 256S114.6 512 256 512zM192 160H320c17.7 0 32 14.3 32 32V320c0 17.7-14.3 32-32 32H192c-17.7 0-32-14.3-32-32V192c0-17.7 14.3-32 32-32z"/></svg>
|
||||
|
Before Width: | Height: | Size: 439 B |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M256 32C114.6 32 .0272 125.1 .0272 240c0 47.63 19.91 91.25 52.91 126.2c-14.88 39.5-45.87 72.88-46.37 73.25c-6.625 7-8.375 17.25-4.625 26C5.818 474.2 14.38 480 24 480c61.5 0 109.1-25.75 139.1-46.25C191.1 442.8 223.3 448 256 448c141.4 0 255.1-93.13 255.1-208S397.4 32 256 32zM256.1 400c-26.75 0-53.12-4.125-78.38-12.12l-22.75-7.125l-19.5 13.75c-14.25 10.12-33.88 21.38-57.5 29c7.375-12.12 14.37-25.75 19.88-40.25l10.62-28l-20.62-21.87C69.82 314.1 48.07 282.2 48.07 240c0-88.25 93.25-160 208-160s208 71.75 208 160S370.8 400 256.1 400z"/></svg>
|
||||
|
Before Width: | Height: | Size: 779 B |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zM337 209L209 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L303 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"/></svg>
|
||||
|
Before Width: | Height: | Size: 496 B |
@@ -0,0 +1,32 @@
|
||||
odoo.define('project_acceptance.AcceptanceFormController', function (required) {
|
||||
"use stric";
|
||||
var FormController = require('web.FormController');
|
||||
var core = require('web.core');
|
||||
var QWeb = core.qweb;
|
||||
var _t = core._t;
|
||||
var AcceptanceFormController = FormController.extend({
|
||||
events: _.extend({}, FormController.prototype.events, {
|
||||
'click .o_account_followup_manual_action_button': '_onManualAction',
|
||||
}),
|
||||
_onManualAction: function (){
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
// odoo.define('project_acceptance.ProjectAcceptanceButton', function(require) {
|
||||
// 'use strict';
|
||||
|
||||
// const ProjectAcceptanceButton = require('point_of_sale.ProjectAcceptanceButton');
|
||||
// const Registries = require('point_of_sale.Registries');
|
||||
|
||||
// const FormProjectAcceptanceButton = ProjectAcceptanceButton =>
|
||||
// class extends ProjectAcceptanceButton {
|
||||
|
||||
// };
|
||||
|
||||
// Registries.Component.extend(ProjectAcceptanceButton, FormProjectAcceptanceButton);
|
||||
|
||||
// return ProjectAcceptanceButton;
|
||||
// });
|
||||
@@ -4,92 +4,75 @@
|
||||
<template id="portal_my_task_inherit" inherit_id="project.portal_my_task">
|
||||
<xpath expr="//div[@class='mt32']" position="before">
|
||||
|
||||
<!-- ###################################################################### -->
|
||||
<!-- The comment code is for modal views and to sign document for acceptance -->
|
||||
<!-- ###################################################################### -->
|
||||
|
||||
<!-- modal relative to the actions accept -->
|
||||
<!-- <div role="dialog" class="modal fade" id="modalaccept">
|
||||
<div role="dialog" class="modal fade" id="modalaccept">
|
||||
<div class="modal-dialog">
|
||||
<form id="accept" method="POST" t-att-data-order-id="task.id" t-att-data-token="task.access_token" class="js_accept_json modal-content js_website_submit_form">
|
||||
<form id="project_accept_modal" method="POST" t-att-action="task.get_portal_url(suffix='/accept')" enctype="multipart/form-data" class="modal-content">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
|
||||
|
||||
<header class="modal-header">
|
||||
<h4 class="modal-title">Validate Task</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||||
</header>
|
||||
<main class="modal-body" id="sign-dialog">
|
||||
|
||||
<main class="modal-body" id="accept-dialog">
|
||||
<p>
|
||||
<span>By signing this proposal, I agree to the task description:</span>
|
||||
<span>I agree to the task description:</span>
|
||||
<ul>
|
||||
<li><span>Accepted on the behalf of:</span> <b t-field="task.partner_id.commercial_partner_id"/></li>
|
||||
</ul>
|
||||
</p>
|
||||
<t t-call="portal.signature_form">
|
||||
<t t-set="call_url" t-value="task.get_portal_url(suffix='/accept')"/>
|
||||
<t t-set="default_name" t-value="task.partner_id.name"/>
|
||||
</t>
|
||||
</main>
|
||||
|
||||
<footer class="modal-footer">
|
||||
<button type="submit" t-att-id="task.id" class="btn btn-primary"><i class="fa fa-check"></i> Accept</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
</footer>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<!-- modal relative to the action reject -->
|
||||
<!-- <div role="dialog" class="modal fade" id="modaldecline">
|
||||
<div role="dialog" class="modal fade" id="modaldecline">
|
||||
<div class="modal-dialog">
|
||||
<form id="decline" method="POST" t-attf-action="/my/task/#{task.id}/decline?access_token=#{task.access_token}" class="modal-content">
|
||||
<form id="project_decline_modal" method="POST" t-att-action="task.get_portal_url(suffix='/decline')" enctype="multipart/form-data" class="modal-content">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
|
||||
|
||||
<header class="modal-header">
|
||||
<h4 class="modal-title">Decline This Task</h4>
|
||||
<h4 class="modal-title">Validate Task</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||||
</header>
|
||||
<main class="modal-body">
|
||||
|
||||
<main class="modal-body" id="sign-dialog">
|
||||
<p>
|
||||
Tell us why you are refusing this task, this will help us improve our services.
|
||||
<span>I agree to the task description:</span>
|
||||
<ul>
|
||||
<li><span>Declined on the behalf of:</span> <b t-field="task.partner_id.commercial_partner_id"/></li>
|
||||
</ul>
|
||||
</p>
|
||||
<textarea rows="4" name="decline_message" required="" placeholder="Your feedback..." class="form-control" />
|
||||
</main>
|
||||
|
||||
<footer class="modal-footer">
|
||||
<button type="submit" t-att-id="task.id" class="btn btn-danger"><i class="fa fa-times"></i> Decline</button>
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" t-att-id="task.id" class="btn btn-primary"><i class="fa fa-check"></i> Decline</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
</footer>
|
||||
</form>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- Message on head for task cancelled state -->
|
||||
<!-- <div t-if="task.stage_id.name == 'cancelled'" class="alert alert-danger alert-dismissable d-print-none" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="close">×</button>
|
||||
<strong>This task has been canceled.</strong> <a role="button" href="#discussion"><i class="fa fa-comment"/> Contact us to get.</a>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<div t-if="task.stage_id.requires_acceptance">
|
||||
<div class="row justify-content-center text-center d-print-none pt-1 pb-4">
|
||||
<div class="col-sm-auto mt8">
|
||||
<form id="accept" method="POST" t-attf-action="/my/task/#{task.id}/accept" enctype="multipart/form-data">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
|
||||
<button class="btn btn-primary" t-attf-href="#" style="color: #ffffff"><i class="fa fa-check"/> Accept</button>
|
||||
<!-- Modal button -->
|
||||
<!-- <a role="button" class="btn btn-primary" data-toggle="modal" data-target="#modalaccept" href="#" style="color: #ffffff"><i class="fa fa-check"/> Accepted</a> -->
|
||||
</form>
|
||||
</div>
|
||||
<button class="btn btn-primary" data-toggle="modal" data-target="#modalaccept" t-attf-href="#" style="color: #ffffff"><i class="fa fa-check"/> Accept</button>
|
||||
</div>
|
||||
<div class="col-sm-auto mt8">
|
||||
<form id="decline" method="POST" t-attf-action="/my/task/#{task.id}/decline" enctype="multipart/form-data">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
|
||||
<button class="btn btn-danger" t-attf-href="#" style="color: #ffffff"> <i class="fa fa-stop-circle"/> Declined</button>
|
||||
<!-- Modal button -->
|
||||
<!-- <a role="button" class="btn btn-danger" data-toggle="modal" data-target="#modaldecline" href="#" style="color: #ffffff"> <i class="fa fa-stop-circle"/> Declined</a> -->
|
||||
</form>
|
||||
<button class="btn btn-danger" data-toggle="modal" data-target="#modaldecline" t-attf-href="#" style="color: #ffffff"> <i class="fa fa-stop-circle"/> Decline</button>
|
||||
</div>
|
||||
<div class="col-sm-auto mt8">
|
||||
<a role="button" class="btn btn-warning" href="#discussion" style="color: #ffffff"><i class="fa fa-comment"/> Feedback</a>
|
||||
<!-- Modal button -->
|
||||
<!-- <form id="decline" method="POST" t-attf-action="/my/task/#{task.id}/feedback" enctype="multipart/form-data">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
|
||||
<a t-attf-href="#discussion">
|
||||
<button class="btn btn-warning" style="color: #ffffff"><i class="fa fa-comment"/> Feedback</button>
|
||||
</a>
|
||||
</form> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user