[WIP] project_acceptance: changes by functionality of buttons

H11043
This commit is contained in:
Leo Pinedo
2022-09-30 00:52:41 +00:00
parent 04cfe42d55
commit 3d60d0d17e
12 changed files with 276 additions and 8 deletions

View File

@@ -18,6 +18,16 @@
"args": ["shell", "--no-xmlrpc"], "args": ["shell", "--no-xmlrpc"],
"console": "integratedTerminal" "console": "integratedTerminal"
}, },
{
"name": "Odoo: INIT 'sale'",
"type": "python",
"request": "launch",
"program": "/opt/odoo/hibou-suite/odoo-run.py",
"args": ["-i", "sale",
"-u", "sale",
"--stop-after-init"],
"console": "integratedTerminal"
},
{ {
"name": "Odoo: TEST 'sale'", "name": "Odoo: TEST 'sale'",
"type": "python", "type": "python",
@@ -28,6 +38,16 @@
"--test-enable", "--no-xmlrpc", "--stop-after-init"], "--test-enable", "--no-xmlrpc", "--stop-after-init"],
"console": "integratedTerminal" "console": "integratedTerminal"
}, },
{
"name": "Odoo: INIT 'project_acceptance'",
"type": "python",
"request": "launch",
"program": "/opt/odoo/hibou-suite/odoo-run.py",
"args": ["-i", "project_acceptance",
"-u", "project_acceptance",
"--stop-after-init"],
"console": "integratedTerminal"
},
{ {
"name": "Odoo: INIT 'hr_commission'", "name": "Odoo: INIT 'hr_commission'",
"type": "python", "type": "python",

View File

@@ -1 +1,2 @@
from . import controllers
from . import models from . import models

View File

@@ -9,10 +9,15 @@
'description': """ """, 'description': """ """,
'depends': [ 'depends': [
'project', 'project',
# 'project_exception',
], ],
'data': [ 'data': [
'data/mail_template_data.xml', 'data/mail_template_data.xml',
# 'report/project_report.xml',
# 'report/project_report_template.xml',
# 'security/project_acceptance_security.xml',
'views/project_portal_templates.xml', 'views/project_portal_templates.xml',
'views/project_views.xml',
], ],
'installable': True, 'installable': True,
'auto_install': False, 'auto_install': False,

View File

@@ -0,0 +1 @@
from . import portal

View File

@@ -0,0 +1,93 @@
import binascii
from odoo import fields, http, SUPERUSER_ID, _
from odoo.exceptions import AccessError, MissingError, ValidationError
from odoo.http import request
from odoo.addons.portal.controllers.mail import _message_post_helper
from odoo.addons.portal.controllers import portal
from odoo.addons.portal.controllers.portal import pager as portal_pager, get_records_pager
class CustomerPortal(portal.CustomerPortal):
@http.route(['/my/task/<int:task_id>/modaccept'], type='json', auth="public", website=True)
def portal_quote_accept(self, task_id, access_token=None, name=None, signature=None):
pass
@http.route(['/my/task/<int:task_id>/decline'], type='http', auth="public", methods=['POST'], website=True)
def decline(self, task_id, access_token=None, **post):
pass
# @http.route(['/my/task/<int:task_id>'], type='http', auth="public", website=True)
# def portal_my_task(self, task_id, access_token=None, **kw):
# try:
# task_sudo = self._document_check_access('project.task', task_id, access_token)
# except (AccessError, MissingError):
# return request.redirect('/my')
# # ensure attachment are accessible with access token inside template
# for attachment in task_sudo.attachment_ids:
# attachment.generate_access_token()
# values = self._task_get_page_view_values(task_sudo, access_token, **kw)
# # return request.render("project.portal_my_task", values)
# return request.render('project_acceptance.portal_my_task_inherit', values)
# @http.route(['/my/task/<int:task_id>/modaccept'], type='json', auth="public", website=True)
# def portal_quote_accept(self, task_id, access_token=None, name=None, signature=None):
# # get from query string if not on json param
# access_token = access_token or request.httprequest.args.get('access_token')
# try:
# task_sudo = self._document_check_access('project.task', task_id, access_token=access_token)
# except (AccessError, MissingError):
# return {'error': _('Invalid order.')}
# if not task_sudo.has_to_be_signed():
# return {'error': _('The task is not in a state requiring customer signature.')}
# if not signature:
# return {'error': _('Signature is missing.')}
# try:
# task_sudo.write({
# 'signed_by': name,
# 'signed_on': fields.Datetime.now(),
# 'signature': signature,
# })
# request.env.cr.commit()
# except (TypeError, binascii.Error) as e:
# return {'error': _('Invalid signature data.')}
# pdf = request.env.ref('project_task.action_report_project_task').with_user(SUPERUSER_ID)._render_qweb_pdf([task_sudo.id])[0]
# _message_post_helper(
# 'project.task', task_sudo.id, _('Task signed by %s') % (name,),
# attachments=[('%s.pdf' % task_sudo.name, pdf)],
# **({'token': access_token} if access_token else {}))
# query_string = '&message=sign_ok'
# if task_sudo.has_to_be_paid(True):
# query_string += '#allow_payment=yes'
# return {
# 'force_refresh': True,
# 'redirect_url': task_sudo.get_portal_url(query_string=query_string),
# }
# @http.route(['/my/task/<int:task_id>/decline'], type='http', auth="public", methods=['POST'], website=True)
# def decline(self, task_id, access_token=None, **post):
# try:
# task_sudo = self._document_check_access('project.task', task_id, access_token=access_token)
# except (AccessError, MissingError):
# return request.redirect('/my')
# message = post.get('decline_message')
# query_string = False
# if task_sudo.has_to_be_signed() and message:
# task_sudo.action_cancel()
# _message_post_helper('project.task', task_id, message, **{'token': access_token} if access_token else {})
# else:
# query_string = "&message=cant_reject"
# return request.redirect(task_sudo.get_portal_url(query_string=query_string))

View File

@@ -34,19 +34,22 @@
<!-- <a t-attf-href="/rate/{{ access_token }}/5"> <!-- <a t-attf-href="/rate/{{ access_token }}/5">
<img alt="Accepted" src="./static/src/img/square-check-solid.svg" title="Accepted"/> <img alt="Accepted" src="./static/src/img/square-check-solid.svg" title="Accepted"/>
</a> --> </a> -->
<a role="button" class="btn btn-primary" t-attf-href="#" style="color: #ffffff"><i class="fa fa-check"/> Accepted</a> <a role="button" class="btn btn-primary" t-attf-href="/rate/{{ access_token }}/5" style="color: #ffffff">
<i class="fa fa-check"/> Accepted</a>
</td> </td>
<td> <td>
<!-- <a t-attf-href="/rate/{{ access_token }}/3"> <!-- <a t-attf-href="/rate/{{ access_token }}/3">
<img alt="Declined" src="./static/src/img/circle-stop-solid.svg" title="Declined"/> <img alt="Declined" src="./static/src/img/circle-stop-solid.svg" title="Declined"/>
</a> --> </a> -->
<a role="button" class="btn btn-danger" t-attf-href="#" style="color: #ffffff"> <i class="fa fa-stop-circle"/> Declined</a> <a role="button" class="btn btn-danger" t-attf-href="/rate/{{ access_token }}/3" style="color: #ffffff">
<i class="fa fa-stop-circle"/> Declined</a>
</td> </td>
<td> <td>
<!-- <a t-attf-href="/rate/{{ access_token }}/1"> <!-- <a t-attf-href="/rate/{{ access_token }}/1">
<img alt="Feedback" src="./static/src/img/comment-regular.svg" title="Feedback Provided"/> <img alt="Feedback" src="./static/src/img/comment-regular.svg" title="Feedback Provided"/>
</a> --> </a> -->
<a role="button" class="btn btn-warning" t-attf-href="#" style="color: #ffffff"><i class="fa fa-comment"/> Feedback</a> <a role="button" class="btn btn-warning" t-attf-href="/rate/{{ access_token }}/1" style="color: #ffffff">
<i class="fa fa-comment"/> Feedback</a>
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -9,5 +9,5 @@ class ProjectProjectStage(models.Model):
class ProjectTask(models.Model): class ProjectTask(models.Model):
_inherit = 'project.task' _inherit = 'project.task'
task_acceptance = fields.Selection([('accept', 'Accepted'), ('decline', 'Decline'), ('feedback', 'Feedback Provided')]) task_acceptance = fields.Selection([('accept', 'Accepted'), ('decline', 'Decline'), ('feedback', 'Feedback Provided')],'Task Acceptance', traking=True)

View File

@@ -0,0 +1,16 @@
<!-- <?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="action_report_project_task" model="ir.actions.report">
<field name="name">Project / Task</field>
<field name="model">project.task</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">project_acceptance.report_project_task</field>
<field name="report_file">project_acceptance.report_project_task</field>
<field name="print_report_name">(object.stage_id.name in ('New', 'In Progress' 'Cancelled') and 'Task - %s' % (object.name)) or 'Task - %s' % (object.name)</field>
<field name="print_report_name"></field>
<field name="binding_model_id" ref="model_project_task"/>
<field name="binding_type">report</field>
</record>
</odoo> -->

View File

@@ -0,0 +1,44 @@
<!-- <?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_project_task_document">
<t t-call="web.external_layout">
<t t-set="doc" t-value="doc.with_context(lang=doc.partner_id.lang)" />
<t t-set="address">
<div t-field="doc.partner_id"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
<p t-if="doc.partner_id.vat"><t t-esc="doc.company_id.account_fiscal_country_id.vat_label or 'Tax ID'"/>: <span t-field="doc.partner_id.vat"/></p>
</t>
<div class="page">
<div class="oe_structure"/>
<h2 class="mt16">
<span> Task # </span>
<span t-field="doc.name"/>
</h2>
<div class="row mt32 mb32" id="informations">
<div>
<strong>Task Date:</strong>
<p class="m-0" t-field="doc.create_date"/>
</div>
</div>
<div class="row mt32 mb32" id="informations">
<div>
<strong>Responsible User:</strong>
<p class="m-0" t-field="doc.activity_user_id"/>
</div>
</div>
</div>
</t>
</template>
<template id="report_project_task">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="project_acceptance.report_project_task_document" t-lang="doc.partner_id.lang"/>
</t>
</t>
</template>
</odoo> -->

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- <odoo noupdate="1"> -->
<odoo>
<record id="task_acceptance_rule_" model="ir.rule">
<field name="name"></field>
<field name="model_id" ref=""/>
<field name="domain_force">[('', '', ), ('', '', )]</field>
<field name="groups" eval="[(4, ref('project.group_project_user'))]"/>
<field name="perm_create" eval="1"/>
<field name="perm_write" eval="1"/>
<field name="perm_unlink" eval="1"/>
<field name="perm_read" eval="0"/>
</record>
</odoo>

View File

@@ -3,15 +3,70 @@
<template id="portal_my_task_inherit" inherit_id="project.portal_my_task"> <template id="portal_my_task_inherit" inherit_id="project.portal_my_task">
<xpath expr="//div[@class='mt32']" position="before"> <xpath expr="//div[@class='mt32']" position="before">
<!-- modal relative to the actions accept -->
<!-- <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">
<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">
<p>
<span>By signing this proposal, 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>
</form>
</div>
</div> -->
<!-- modal relative to the action reject -->
<!-- <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">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<header class="modal-header">
<h4 class="modal-title">Decline This Task</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
</header>
<main class="modal-body">
<p>
Tell us why you are refusing this task, this will help us improve our services.
</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>
</footer>
</form>
</div>
</div> -->
<!-- <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 class="row justify-content-center text-center d-print-none pt-1 pb-4"> <div class="row justify-content-center text-center d-print-none pt-1 pb-4">
<div t-if="not sale_order_exceptions" class="col-sm-auto mt8"> <div t-if="not sale_order_exceptions" class="col-sm-auto mt8">
<!-- <a role="button" class="btn btn-primary" data-toggle="modal" data-target="#modalaccept" href="#"><i class="fa fa-check"/>Accept</a> --> <a role="button" class="btn btn-primary" t-attf-href="#" style="color: #ffffff"><i class="fa fa-check"/> Accepted</a>
<!-- <a role="button" class="btn btn-primary" t-attf-href="#" style="color: #ffffff"><i class="fa fa-check"/> Accepted</a> --> <!-- <a role="button" class="btn btn-primary" data-toggle="modal" data-target="#modalaccept" href="#" style="color: #ffffff"><i class="fa fa-check"/> Accepted</a> -->
<a role="button" class="btn btn-primary" data-toggle="modal" data-target="#modalaccept" href="#" style="color: #ffffff"><i class="fa fa-check"/> Accepted</a>
</div> </div>
<div class="col-sm-auto mt8"> <div class="col-sm-auto mt8">
<!-- <a role="button" class="btn btn-danger" data-toggle="modal" data-target="#modaldecline" href="#"> <i class="fa fa-times"/>Decline</a> -->
<a role="button" class="btn btn-danger" t-attf-href="#" style="color: #ffffff"> <i class="fa fa-stop-circle"/> Declined</a> <a role="button" class="btn btn-danger" t-attf-href="#" style="color: #ffffff"> <i class="fa fa-stop-circle"/> Declined</a>
<!-- <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> -->
</div> </div>
<div class="col-sm-auto mt8"> <div class="col-sm-auto mt8">
<!-- <a role="button" class="btn btn-secondary" href="#discussion"><i class="fa fa-comment"/> Feedback</a> --> <!-- <a role="button" class="btn btn-secondary" href="#discussion"><i class="fa fa-comment"/> Feedback</a> -->

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_task_form2_inherit_pad_project" model="ir.ui.view">
<field name="name">project.task.form.inherit</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='parent_id']" position="after">
<field name="task_acceptance"/>
</xpath>
</field>
</record>
</odoo>