Skip to content

Commit

Permalink
[ADD]sale_require_terms_and_conditions
Browse files Browse the repository at this point in the history
closes #692

Signed-off-by: matiasperalta1 <mnp@adhoc.com.ar>
  • Loading branch information
JrAdhoc authored and matiasperalta1 committed Sep 15, 2023
1 parent 2ab9bc7 commit 39b9029
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
42 changes: 42 additions & 0 deletions sale_require_terms_and_conditions/__manifest__.py
@@ -0,0 +1,42 @@
##############################################################################
#
# Copyright (C) 2015 ADHOC SA (http://www.adhoc.com.ar)
# All Rights Reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Sale Require Terms and Conditions',
'version': "16.0.1.0.0",
'category': 'Sales',
'sequence': 14,
'summary': '',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'images': [
],
'depends': [
'sale'
],
'data': [
'views/sale_order_portal_template.xml',

],
'demo': [],
'installable': True,
'auto_install': False,
'application': False,
}
@@ -0,0 +1,79 @@
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<template id="sale_order_portal_template" inherit_id="sale.sale_order_portal_template">
<xpath expr="//ul[hasclass('list-group')]/li" position="replace">
<li class="list-group-item flex-grow-1">
<div class="o_download_pdf btn-toolbar flex-sm-nowrap">
<div class="btn-group flex-grow-1 mr-1 mb-1">
<a class="btn btn-secondary btn-block o_download_btn" t-att-href="sale_order.get_portal_url(report_type='pdf', download=True)" title="Download">
<i class="fa fa-download"/>
Download</a>
</div>
<div class="btn-group flex-grow-1 mb-1">
<a class="btn btn-secondary btn-block o_print_btn o_portal_invoice_print" t-att-href="sale_order.get_portal_url(report_type='pdf')" id="print_invoice_report" title="Print" target="_blank">
<i class="fa fa-print"/>
Print</a>
</div>
</div>
</li>
</xpath>
<xpath expr="//div[hasclass('justify-content-center')]/t/div/a" position="attributes">
<attribute name="id">modalacceptbuttonsign</attribute>
</xpath>
<xpath expr="//div[hasclass('justify-content-center')]/div/a" position="attributes">
<attribute name="id">o_sale_portal_paynow</attribute>
</xpath>
<xpath expr="//div[hasclass('justify-content-center')]" position="before">
<t t-if="not is_html_empty(sale_order.note)">
<div style="display:flex;flex-direction:column;margin-top:15px" id="tyc_div">
<span id="tycSpan">Debe aceptar los términos y condiciones para continuar:</span>
<div>
<input style="margin-top:5px" type="checkbox" name="x_accept_tyc" id="x_accept_tyc"/>
<span style="font-weight:bold"> Acepto los Términos y Condiciones</span>
</div>
</div>
</t>
</xpath>
<xpath expr="//div[hasclass('o_portal_sale_sidebar')]" position="after">
<script>
var terms = document.getElementById("terms");
if(terms !== null ){
var tycDiv = document.getElementById("tyc_div");
var tycSpan = document.getElementById("tycSpan");
var input = document.getElementById("x_accept_tyc");
var button = document.getElementById("modalacceptbuttonsign") ? document.getElementById("modalacceptbuttonsign"): document.getElementById("o_sale_portal_paynow");
var alertSuccess = document.getElementsByClassName("alert-success")[0];
var alertWarning = document.getElementsByClassName("alert-warning")[0];
if(button !== null &amp;&amp; typeof(alertSuccess) == 'undefined' &amp;&amp; typeof(alertWarning) == 'undefined'){
button.disabled = true;
button.dataset['bsTarget'] = "";
button.dataset['bsToggle'] = "";
button.style.backgroundColor = "#787878";
button.style.borderColor = "#787878";

input.onclick = function(){
if(input.checked){
button.disabled = false;
button.dataset['bsTarget'] = "#modalaccept";
button.dataset['bsToggle'] = "modal";
button.style.backgroundColor = "";
button.style.borderColor = "";
}else {
button.disabled = true;
button.dataset['bsTarget'] = "";
button.dataset['bsToggle'] = "";
button.style.backgroundColor = "#787878";
button.style.borderColor = "#787878";
}
};
}else{
tycSpan.innerText = "Usted ha aceptado los términos y condiciones";
input.checked = true;
input.disabled = true;
tycDiv.scrollIntoView({behavior: 'smooth'})
}
}
</script>
</xpath>
</template>
</odoo>

0 comments on commit 39b9029

Please sign in to comment.