[FIX] website_crm_partner_assign: use html5 input date over text

Create a lead, assign it to a partner who has portal access. Go to that
opportunity on the portal, edit any date to set 3-digit year (0-999) and
submit the form. Go to the opportunity using the web app, traceback.

Dates are only supported starting to 1900 thus many parsing function
assume the year to be a 4-digits year. The html form has been changed to
use an input type date with a minimum value instead of a plain text
input. This ensure a better support by browser (they use their built-in
calendar) and allow basic html5 form validation.

opw-2033276

closes odoo/odoo#34796

Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
This commit is contained in:
Julien Castiaux
2019-07-11 12:05:54 +00:00
parent 8bab33c948
commit b2b639b693
2 changed files with 5 additions and 3 deletions
@@ -226,7 +226,9 @@ sAnimations.registry.crmPartnerAssign = sAnimations.Class.extend({
_onEditOppConfirm: function (ev) {
ev.preventDefault();
ev.stopPropagation();
this._buttonExec($(ev.currentTarget), this._editOpportunity);
if ($(".edit_opp_form")[0].checkValidity()) {
this._buttonExec($(ev.currentTarget), this._editOpportunity);
}
},
/**
* @private
@@ -670,7 +670,7 @@
<div class="col-md-6">
<label>Expected Closing:</label>
<div class="input-group date">
<input type="text" name="date_deadline" t-att-value="opportunity.date_deadline" class="form-control date_deadline" data-date-format="YYYY-MM-DD" t-att-name="prefix" placeholder="YYYY-MM-DD"/>
<input type="date" min="1900-01-01" name="date_deadline" t-att-value="opportunity.date_deadline" class="form-control date_deadline" data-date-format="YYYY-MM-DD" t-att-name="prefix" placeholder="YYYY-MM-DD"/>
<div class="input-group-append">
<span class="input-group-text">
<span class="fa fa-calendar" role="img" aria-label="Calendar"></span>
@@ -695,7 +695,7 @@
<div class="form-group">
<label class="col-form-label" for="activity_date_deadline">Next Activity Date</label>
<div class="input-group date">
<input type="text" name="activity_date_deadline" t-att-value="user_activity.date_deadline" class="form-control activity_date_deadline" data-date-format="YYYY-MM-DD" t-att-name="prefix" placeholder="YYYY-MM-DD"/>
<input type="date" min="1900-01-01" name="activity_date_deadline" t-att-value="user_activity.date_deadline" class="form-control activity_date_deadline" data-date-format="YYYY-MM-DD" t-att-name="prefix" placeholder="YYYY-MM-DD"/>
<div class="input-group-append">
<span class="input-group-text">
<span class="fa fa-calendar" role="img" aria-label="Calendar" title="Calendar"></span>