From 3a81fad2812e00d8d06e25d4386f4e3a9bb87f70 Mon Sep 17 00:00:00 2001 From: Juliana Date: Wed, 23 Oct 2019 17:37:17 +0200 Subject: [PATCH] Pb save day --- controllers/main.py | 10 +--------- models/sale_order.py | 21 ++++++++------------- static/src/js/vracoop_retrait.js | 2 ++ views/vracoop_templates.xml | 8 ++++---- 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/controllers/main.py b/controllers/main.py index 183b947..a4af95b 100644 --- a/controllers/main.py +++ b/controllers/main.py @@ -37,12 +37,9 @@ class VracoopWebsiteSaleDelivery(WebsiteSale): if 'vracoop_point_retrait_id' in post: vracoop_point_retrait_id = int(post['vracoop_point_retrait_id']) order._check_retrait(force_retrait_id=vracoop_point_retrait_id) - if 'day_retrait' in post: - day_retrait = post['day_retrait'] - order._update_day(day_retrait=day_retrait) if 'hour_retrait' in post: hour_retrait = post['hour_retrait'] - order._update_hour(hour_retrait=hour_retrait) + order._update_day_hour(hour_retrait=hour_retrait) return self._update_website_sale_retrait_return(order, **post) @@ -52,10 +49,6 @@ class VracoopWebsiteSaleDelivery(WebsiteSale): vracoop_point_retrait_id = int(post['vracoop_point_retrait_id']) else: vracoop_point_retrait_id = '' - if 'day_retrait' in post: - day_retrait = post['day_retrait'] - else: - day_retrait = '' if 'hour_retrait' in post: hour_retrait = post['hour_retrait'] status = True @@ -65,7 +58,6 @@ class VracoopWebsiteSaleDelivery(WebsiteSale): return {'status': status, 'error_message': order.delivery_message, 'vracoop_point_retrait_id': vracoop_point_retrait_id, - 'day_retrait': day_retrait, 'hour_retrait': hour_retrait } return {} diff --git a/models/sale_order.py b/models/sale_order.py index 7937a02..fb87789 100644 --- a/models/sale_order.py +++ b/models/sale_order.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import models, fields -from datetime import * +from datetime import datetime class SaleOrder(models.Model): _inherit = 'sale.order' @@ -22,22 +22,17 @@ class SaleOrder(models.Model): return bool(retrait) - def _update_day(self, day_retrait=None): + def _update_day_hour(self, hour_retrait=None): self.ensure_one() today = datetime.today() - day = day_retrait.split("-") - day_retrait = datetime(today.year, int(day[1]), int(day[0])) + values = hour_retrait.split("-") + day_retrait = datetime(today.year, int(values[1]), int(values[0])) - self.write({'day_retrait': day_retrait}) - - return True - - def _update_hour(self, hour_retrait=None): - self.ensure_one() - # PointRetrait = self.env['vracoop.point.retrait'] - hour = hour_retrait.split(":") + hour = values[2].split(":") hour_retrait = float('%s.%s' % (hour[0], hour[1])) - self.write({'hour_retrait': hour_retrait}) + self.write({ + 'hour_retrait': hour_retrait, + 'day_retrait': day_retrait}) return True \ No newline at end of file diff --git a/static/src/js/vracoop_retrait.js b/static/src/js/vracoop_retrait.js index 0998589..80dce0b 100644 --- a/static/src/js/vracoop_retrait.js +++ b/static/src/js/vracoop_retrait.js @@ -54,6 +54,7 @@ odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) { var _onDayClick = function(ev) { 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); @@ -79,6 +80,7 @@ odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) { var _onHourClick = function(ev) { var hour_retrait = $(ev.currentTarget).val(); var values = {'hour_retrait': hour_retrait}; + console.log(values); dp.add(ajax.jsonRpc('/shop/update_retrait', 'call', values)) .then(_onHourUpdateAnswer); }; diff --git a/views/vracoop_templates.xml b/views/vracoop_templates.xml index a3be104..a159e0b 100644 --- a/views/vracoop_templates.xml +++ b/views/vracoop_templates.xml @@ -30,7 +30,7 @@