From 03b6f0f1b3cb26518fa1c545005af4741bbde584 Mon Sep 17 00:00:00 2001 From: Juliana Date: Tue, 22 Oct 2019 23:17:05 +0200 Subject: [PATCH] Ajout blocage paiement --- controllers/main.py | 4 +- static/src/js/vracoop_retrait.js | 36 ++---------- views/vracoop_templates.xml | 96 +------------------------------- 3 files changed, 10 insertions(+), 126 deletions(-) diff --git a/controllers/main.py b/controllers/main.py index fcb4e1a..0cde3a6 100644 --- a/controllers/main.py +++ b/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, diff --git a/static/src/js/vracoop_retrait.js b/static/src/js/vracoop_retrait.js index 84f4daa..0998589 100644 --- a/static/src/js/vracoop_retrait.js +++ b/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'); } }; diff --git a/views/vracoop_templates.xml b/views/vracoop_templates.xml index dea42f7..fa1f6bb 100644 --- a/views/vracoop_templates.xml +++ b/views/vracoop_templates.xml @@ -91,100 +91,6 @@ -