Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
9413 มุมมอง

Dear Odoo Community, I'm having a template for booking hotel rooms, having two fields called Arrive and Departure. For the booking rooms process, i want to disable those dates which are already booked. 

The jquery solution using datepicker is quite simple :

var array = ["2020-07-27 00:00:00","2020-07-28 00:00:00"]
var trima = []for (i = 0; i < array.length; i++ ) { trima.push(array[i].substring(10,""))}
$('input').datepicker({ beforeShowDay: function(date){ var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [ trima.indexOf(string) == -1 ] }});

It would be quite simple to extend the Datepicker widget in Odoo for FIELDNAME. But what i need, is to get these adanced datepicker features (minDate, MaxDate, or this advanced option

options='{"datepicker": {"daysOfWeekDisabled": [5, 6]}}'/>

) to simple <input type=date> fields which are inside a t-foreach loop :


<div t-foreach="tickets" t-as="ticket">

        <input class="form-control" type="date"  t-attf-name="#{counter}-eventrg_begin_date"  />
         <input class="form-control" type="date"  t-attf-name="#{counter}-eventrg_end_date"/>


I have tried to add the class  o_website_form_date to the INPUT fields but i cant use these capabilities (daysOfWeekDisabled...) which are only available for FIELDNAME. Shall i write a widget for simple INPUT field ? How to perform do that ? Thank you for your help.


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Till odoo 14, under the hood, odoo uses this https://getdatepicker.com/4/Options/ date picker. Refer the options in that link and try them.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ย. 24
507
Islamic\Hijri date picker for odoo 15?? แก้ไขแล้ว
1
ต.ค. 22
2206
0
ส.ค. 20
2458
1
มี.ค. 19
3200
0
ก.พ. 18
2992