Browse Source

Pb save day

12.0
Juliana 5 years ago
parent
commit
3a81fad281
  1. 10
      controllers/main.py
  2. 21
      models/sale_order.py
  3. 2
      static/src/js/vracoop_retrait.js
  4. 8
      views/vracoop_templates.xml

10
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 {}

21
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

2
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);
};

8
views/vracoop_templates.xml

@ -30,7 +30,7 @@
<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}'/>
<input t-attf-id='#{slot[1].day}-#{slot[1].month}-#{point_retrait.id}' name="day_select d-none" 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/>
@ -44,7 +44,7 @@
<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}'/>
<input t-attf-id='#{slot[1].day}-#{slot[1].month}-#{point_retrait.id}' name="day_select" type="radio" class="radio_hide d-none" 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/>
@ -74,7 +74,7 @@
<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}"/>
<input name="hour_select" type="radio" class="radio_hide" t-attf-value="#{slot[1].day}-#{slot[1].month}-#{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]"/>
@ -87,7 +87,7 @@
<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]"/>
<input t-attf-id="#{slot_by_day_index}" name="hour_select" type="radio" class="radio_hide" t-attf-value="#{slot[1].day}-#{slot[1].month}-#{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]"/>

Loading…
Cancel
Save