Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet

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.


Avatar
Verwerfen
Beste Antwort

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.

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Nov. 24
510
1
Okt. 22
2210
0
Aug. 20
2465
1
März 19
3214
0
Feb. 18
2998