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
Related
I want to create a date picker with options for start date and end date so the user can choose if he/she want to apply start date or end date.
I am currently implemented the following
current implementation
And when I change the date from the datepicker the options are gone.
error on current implementation
I am using https://www.daterangepicker.com/ library If there is another library it is welcome.enter image description here
This is what I want to create like
enter image description here
you can see it on if it is deleted https://ibb.co/1QvtjmS
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'}}"/>
I'm new for SAPUI5, I'm using plan calendar for assigning some schedule for employee.Though i'm able to do it but if i want to update already scheduled task then in the popup small calendar gets opened. In that calendar i want to provide validation for start date and end date as if user selects start date then automatically for end date calendar dates less than start date should get disabled.
Sharing screen shot of planning calendar and it's reference documentation.
Planning calendar documentation
Help will be appreciated.
Can't u use the 'change' event of sap.m.DatePicker? If the value changes, set the 'minDate' property of the datepicker.
Fragment
<DatePicker id="idStartDate" change="onChangeStartDate"/>
<DatePicker id="idEndDate" change="onChangeEndDate"/>
Controller - don't forget to define sap.ui.core.Fragment in controller definiton
// don't forget to define Fragment in controller
onChangeStartDate: function(){
var startDate = Fragment.byId("fragId, "idStartDate").getDateValue();
Fragment.byId("fragId, "idEndDate").setMinDate(startDate);
},
onChangeEndDate: function(){
var endDate = Fragment.byId("fragId, "idEndDate").getDateValue();
Fragment.byId("fragId, "idStartDate").setMaxDate(endDate);
}
Just use binding. I will assume your first input field is bound against {StartDate} and the second against {EndDate}
Then you can bind the second DatePickers minDate Property to {StartDate} like this:
<DatePicker dateValue="{StartDate}"/>
<DatePicker dateValue="{EndDate}" minDate="{StartDate}"/>
(BTW: you could use sap.ui.unified.Calendar for Date Range Selections: Explored Example)
I want to get value from date picker (get date from date picker and stored in to variable) in katalon.
I would suggest using the Java programming language and get your datepicker Date from Java code. Do not forget to include the import statement at the top of the test case for the java.util... library you get the datepicker from.
I have a date list field and need to replace a value in the list with another value
so I have this list of type "date list"
The user enter a new value in a date field in the webpage. This new value should be added to in this case the second item in the date list, but it in the real case it should be able to be added to any position in the list
This is the inputfield where user enter a new date
<xp:inputText id="inputText1">
<xp:this.converter>
<xp:convertDateTime pattern="yyyy-MM-dd"></xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
This is the code I use in my button that should replace the date
doc is a data source on the XPage
var v:java.util.Vector = doc.getDocument().getItemValueDateTimeArray("TDate")
v.setElementAt(getComponent("inputText1").getValue(),1)
doc.replaceItemValue("TDate",v)
doc.save()
Not sure what I am doing wrong here, but I seem to have two problems, first the field only seem to contain one element after I save, and secondly the date that is added contain both date and time, and not only the date
This is the result after running the code
Running the same kind of code using a multivalue "text" field works fine.
how can I modify my code so that my replace operation in the date list works
to set a date value without the time part
get a DateTime object and call the function setAnyTime() on the NDT object and replace the item
to set a specific time value in a multivalue datetime field
get the field you will get a vector with all the datetime object.
Get the specific timedate in the vector change it and set it back to the vector. and after that replace the item