Browse Source

Ajout blocage paiement

12.0
Juliana 5 years ago
parent
commit
03b6f0f1b3
  1. 4
      controllers/main.py
  2. 36
      static/src/js/vracoop_retrait.js
  3. 96
      views/vracoop_templates.xml

4
controllers/main.py

@ -47,6 +47,7 @@ class VracoopWebsiteSaleDelivery(WebsiteSale):
return self._update_website_sale_retrait_return(order, **post)
def _update_website_sale_retrait_return(self, order, **post):
status = False
if 'vracoop_point_retrait_id' in post:
vracoop_point_retrait_id = int(post['vracoop_point_retrait_id'])
else:
@ -57,10 +58,11 @@ class VracoopWebsiteSaleDelivery(WebsiteSale):
day_retrait = ''
if 'hour_retrait' in post:
hour_retrait = post['hour_retrait']
status = True
else:
hour_retrait = ''
if order:
return {'status': order.delivery_rating_success,
return {'status': status,
'error_message': order.delivery_message,
'vracoop_point_retrait_id': vracoop_point_retrait_id,
'day_retrait': day_retrait,

36
static/src/js/vracoop_retrait.js

@ -32,24 +32,10 @@ odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) {
var _onRetraitUpdateAnswer = function(result) {
var $retrait_badge = $('#point_retrait input[name="point_retrait_type"][value=' + result.vracoop_point_retrait_id + ']');
// var $retrait_bloc = $('#slots_point_retrait_' + result.vracoop_point_retrait_id)
// console.log($retrait_bloc);
if (result.status === true) {
// $retrait_bloc.removeClass('d-none');
$pay_button.data('disabled_reasons').retrait_selection = false;
$pay_button.prop('disabled', _.contains($pay_button.data('disabled_reasons'), true));
}
else {
console.error(result.error_message);
}
};
var _onRetraitClick = function(ev) {
$pay_button.data('disabled_reasons', $pay_button.data('disabled_reasons') || {});
$pay_button.prop('disabled', true);
$pay_button.data('disabled_reasons').retrait_selection = true;
var vracoop_point_retrait_id = $(ev.currentTarget).val();
console.log(vracoop_point_retrait_id);
var values = {'vracoop_point_retrait_id': vracoop_point_retrait_id};
dp.add(ajax.jsonRpc('/shop/update_retrait', 'call', values))
.then(_onRetraitUpdateAnswer);
@ -64,21 +50,10 @@ odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) {
var _onDayUpdateAnswer = function(result) {
if (result.status === true) {
$pay_button.data('disabled_reasons').day_selection = false;
$pay_button.prop('disabled', _.contains($pay_button.data('disabled_reasons'), true));
}
else {
console.error(result.error_message);
}
};
var _onDayClick = function(ev) {
$pay_button.data('disabled_reasons', $pay_button.data('disabled_reasons') || {});
$pay_button.data('disabled_reasons').day_selection = true;
$pay_button.prop('disabled', true);
var day_retrait = $(ev.currentTarget).val();
console.log(day_retrait);
var values = {'day_retrait': day_retrait};
dp.add(ajax.jsonRpc('/shop/update_retrait', 'call', values))
.then(_onDayUpdateAnswer);
@ -92,9 +67,8 @@ odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) {
}
var _onHourUpdateAnswer = function(result) {
if (result.status === true) {
$pay_button.data('disabled_reasons').hour_selection = false;
$pay_button.data('disabled_reasons').retrait_selection = false;
$pay_button.prop('disabled', _.contains($pay_button.data('disabled_reasons'), true));
}
else {
@ -103,9 +77,6 @@ odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) {
};
var _onHourClick = function(ev) {
$pay_button.data('disabled_reasons', $pay_button.data('disabled_reasons') || {});
$pay_button.data('disabled_reasons').hour_selection = true;
$pay_button.prop('disabled', true);
var hour_retrait = $(ev.currentTarget).val();
var values = {'hour_retrait': hour_retrait};
dp.add(ajax.jsonRpc('/shop/update_retrait', 'call', values))
@ -124,8 +95,13 @@ odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) {
var $point_retrait = $('#point_retrait');
if (result.point_retrait === true) {
$point_retrait.removeClass('d-none');
$pay_button.data('disabled_reasons', $pay_button.data('disabled_reasons') || {});
$pay_button.prop('disabled', true);
$pay_button.data('disabled_reasons').retrait_selection = true;
}
else {
$pay_button.data('disabled_reasons').retrait_selection = false;
$pay_button.prop('disabled', _.contains($pay_button.data('disabled_reasons'), true));
$point_retrait.addClass('d-none');
}
};

96
views/vracoop_templates.xml

@ -91,100 +91,6 @@
</t>
</div>
</div>
<!-- <input t-att-value="point_retrait.id" t-att-id="'point_retrait2_%i' % point_retrait.id" type="radio" name="point_retrait_type" t-att-checked="order.vracoop_point_retrait_id and order.vracoop_point_retrait_id.id == point_retrait.id and 'checked' or False" t-att-class="'d-none' if point_retrait_nb == 1 else ''"/>
<label class="label-optional" t-field="point_retrait.name" t-att-for="'point_retrait2_%i' % point_retrait.id"/>
<t t-if="point_retrait.street">
<br/><span><t t-esc="point_retrait.street"/></span><br/>
</t>
<t t-if="point_retrait.street2">
<span><t t-esc="point_retrait.street2"/></span><br/>
</t>
<span><t t-esc="point_retrait.city"/>
<t t-esc="point_retrait.zip"/></span>
<div t-att-id="'slots_point_retrait_%i' % point_retrait.id">
<h5>Sélectionner le jour et le créneau pour votre retrait</h5>
<t t-set="list_slots" t-value="point_retrait.slot_calculate()"/>
<div class="top-content mt-4 mb-4">
<div class="container-fluid">
<div t-att-id="'carousel_%i' % point_retrait.id" class="carousel slide" data-ride="carousel" data-interval="false">
<ul class="nav nav-tabs carousel-inner row w-100 mx-auto" role="tablist">
<t t-foreach="list_slots" t-as="slot">
<t t-if="slot_first">
<li class="nav-item carousel-item col-12 col-sm-6 col-md-4 col-lg-3 active">
<a data-toggle="tab" class="nav-link active btn btn-primary" t-attf-href='##{slot[1].strftime("%A")}#{point_retrait.id}'>
<label class=" label_radio_button" role="radio">
<input t-attf-id='#{slot[1].day}-#{slot[1].month}-#{point_retrait.id}' name="day_select" type="radio" class="radio_hide" t-attf-value='#{slot[1].day}-#{slot[1].month}-#{point_retrait.id}'/>
<span class="span_radio_button">
<t class="week_day" t-esc="slot[0]"/><br/>
<t t-esc="slot[1].day"/><br/>
<t t-esc="slot[2]"/>
</span>
</label>
</a>
</li>
</t>
<t t-else="">
<li class="nav-item carousel-item col-12 col-sm-6 col-md-4 col-lg-3">
<a data-toggle="tab" class="nav-link btn btn-primary" t-attf-href='##{slot[1].strftime("%A")}#{point_retrait.id}'>
<label class=" label_radio_button" role="radio">
<input t-attf-id='#{slot[1].day}-#{slot[1].month}-#{point_retrait.id}' name="day_select" type="radio" class="radio_hide" t-attf-value='#{slot[1].day}-#{slot[1].month}-#{point_retrait.id}'/>
<span class="span_radio_button">
<t class="week_day" t-esc="slot[0]"/><br/>
<t t-esc="slot[1].day"/><br/>
<t t-esc="slot[2]"/>
</span>
</label>
</a>
</li>
</t>
</t>
</ul>
<a class="carousel-control-prev" t-att-href="'#carousel_%i' % point_retrait.id" role="button" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" t-att-href="'#carousel_%i' % point_retrait.id" role="button" data-slide="next">
<span class="carousel-control-next-icon" ></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
<div class="tab-content">
<t t-foreach="list_slots" t-as="slot">
<t t-if="slot_first">
<div class="container tab-pane active" t-attf-id='#{slot[1].strftime("%A")}#{point_retrait.id}'>
<t t-foreach="slot[3]" t-as="slot_by_day">
<label class="label_radio_button" role="radio">
<input name="hour_select" type="radio" class="radio_hide" t-att-value="slot_by_day[0]" t-attf-id="#{slot_by_day_index}"/>
<span class="btn btn-outline-primary span_radio_button">
<t t-esc="slot_by_day[0]"/> :
<t t-esc="slot_by_day[1]"/>
</span>
</label>
</t>
</div>
</t>
<t t-else="">
<div class="container tab-pane fade" t-attf-id='#{slot[1].strftime("%A")}#{point_retrait.id}'>
<t t-foreach="slot[3]" t-as="slot_by_day">
<label class=" label_radio_button" role="radio">
<input t-attf-id="#{slot_by_day_index}" name="hour_select" type="radio" class="radio_hide" t-att-value="slot_by_day[0]"/>
<span class="btn btn-outline-primary span_radio_button">
<t t-esc="slot_by_day[0]"/> :
<t t-esc="slot_by_day[1]"/>
</span>
</label>
</t>
</div>
</t>
</t>
</div>
</div>
-->
</template>
<template id="point_retrait_one">
@ -312,7 +218,7 @@
<ul class="list-group">
<t t-foreach="points_retrait" t-as="point_retrait">
<li class="list-group-item">
<t t-call="vracoop_click_and_collect.point_retrait_one"/>
<t t-call="vracoop_click_and_collect.point_retrait_choose"/>
</li>
</t>
</ul>

Loading…
Cancel
Save