Datepicker not able to just allow future dates on ODOO V11 - datepicker

Hello team I am using ODOO V11 and a need a rule in the datepicker that not allow choose past dates.
For that I am using a module from community
https://apps.odoo.com/apps/modules/11.0/web_widget_datepicker_options/
I got some error when I put as parameter 0 in the min date to allow just dates from the current date:
<field name="active_date" options="{'datepicker':{'minDate': '0'}}"/>
eError: maxDate() Could not parse date parameter: 0.
When I try pass a specific date it works successfully
<field name="active_date" options="{'datepicker':{'minDate': '2018-09-01'}}"/>
Could you please take a look and tell me the parameter correctly to put in the option for datepicker?

for making datepicker only accept future dates, you need to change your code into
<field name="active_date" options="{'datepicker':{'minDate': 'now'}}"/>

Related

Vue 3 Datepicker update as user types

I am using Vue3Datepicker in our project (Composition Api).
What I am trying to do is to give the users ability to type in any format. e.g. if the user types in any of the following, it can parse it to 2nd Feb 2022:
02/02/2022
02-02-2022
02.02.2022
I have checked different events of the datepicker but couldn't find one that triggers while user is typing. most of the events are for when the model has been updated, which in this case if the format is for example DD/MM/YYYY, typing 02.02.2022 doesn't update the model so that is not hit at all.
import Datepicker from '#vuepic/vue-datepicker';
<Datepicker v-model="props.modelValue"
format="dd/MM/yyyy"
autoApply
textInput
:enableTimePicker="false" />
Any help is appreciated.

Phoenix Datepicker to only show available dates

I am working on a simple booking system using the Phoenix framework. At the moment, I have a route for new bookings, displaying a date picker which takes the values from a "booking" model with the following attributes:
:time, Ecto.DateTime
:description, :string
belongs_to :user, Test.User
When I head to "bookings/new", my form is correctly displayed and I can pick whatever date I want. However, I am now trying to figure out how to remove unavailable dates from the picker.
As far as I can see, the form is taking the values from ecto's DateTime primitive type, however coming from an OOP background I cannot figure out what resource I need to update in order to remove unavailable dates. Do I have to create a custom type?
Thanks in advance
I am quite late to respond to this but I hope it will be able to help someone; you can use the builder option when using the date_select on forms.
<%= date_select f, :time, builder: fn b -> %>
<%= b.(:day, prompt: "Date") %> /
<%= b.(:month, prompt: "Month") %> /
<%= b.(:year, prompt: "Year") %>
<% end %>
That's how you can customize it if you need just the day, month and year. You can do the same with time too.
You can't block arbitrary dates in the default DateTime picker. You can restrict the range (e.g. limit the years to 1234 to 1243 or months to January to June), but since they're independent <select> inputs, you can't hide specific combinations. Two ways to solve this that I can think of are:
Do the validation on the server. You can use AJAX to do the validation as soon as the user selects, without a page refresh, if you want.
Use JavaScript to restrict the range, either blocking selecting a taken date using custom JS, or use an existing, full fledged DatePicker / Calendar library.

Disable previous dates in Odoo datepicker

I want to restrict the user selecting previous date from the date picker of odoo-8. Please give me how to disable previous dates in odoo datepicker
There's a module for that https://apps.openerp.com/apps/modules/8.0/web_widget_datepicker_options/
If you have a date field named current_date
<field name="current_date" />
After installing the module, just add the option for the jquery datepicker minDate and set it to 0 like this
<field name="current_date" options="{'datepicker':{'minDate': 0}}"/>
Screenshot
I previously did this by
setting an onchange on the field that'll be triggered every time the field is changed, and in the onchange you can convert the date to a python date (with odoo's default time format) and compare it to the current date
from datetime import datetime
from openerp import api
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
from openerp.exceptions import Warning
#api.onchange('current_date')
def onchange_date(self):
if datetime.strptime(self.current_date, DEFAULT_SERVER_DATE_FORMAT).date() < datetime.now().date():
raise warning('Please select a date equal/or greater than the current date')
return False
return my_date

Bypassing parameters in ireport 5.6.0

I created a simple report in i-report and i added a parameter on a field salary. Now every time i click on preview i get the parameter pop-up to filter. And if the value if not correct i get a blank page. Now that's exactly what i was trying to do. However i am wondering if there's a way to enter a certain value in the parameter box to display all records. Any idea if this possible and if yes how? Thank you.
WHERE EMPLOYEES."SALARY" = ${P1}
You need to change your query (lets imagine that SALARY is numeric, Double). to
WHERE EMPLOYEES."SALARY" = $P{parameter1} OR 0=$P{parameter1}
and define your parameter with a defaultValueExpression and set attribute isForPrompting="false"
<parameter name="parameter1" class="java.lang.Double" isForPrompting="false">
<defaultValueExpression><![CDATA[new java.lang.Double(0)]]></defaultValueExpression>
</parameter>
You will see no more prompt and display all data, if SALARY is of other class naturally you need to adjust the example accordingly.

Ajax Control Toolkit Date Picker - Is it possible to not have to select the day?

So I can set the date format on the Calendar Extender to it displays just the month, but you would still have to select the Year, then the Month, then the Day.
I would like to just select the Year, then the Month.
<cc2:CalendarExtender ID="DateOfReleaseCalendarExtender" runat="server"
TargetControlID="DateOfReleaseTextBox"
Format="MMMM yyyy" />
That is not a built-in feature, no. You'll have to extend it yourself. I would probably hook into the Javascript events--whichever one you think makes sense in your situation.
This requires patching the CalendarExtender part of the AjaxControlToolkit assembly.
I found a blog post that explains how to do something very similar to what you are trying to do: Patching the CalendarExtender Control