[FIX][MIG]Fix PhoneFR widget for v10

This commit is contained in:
Fabien Bourgeois 2017-06-07 09:49:20 +02:00
parent 48f2f7c606
commit b93a4e7343
2 changed files with 23 additions and 22 deletions

View File

@ -28,13 +28,16 @@ odoo.define('web.web_widget_phone_check', function(require) {
var FieldPhoneFr = widget.FieldChar.extend({
template: 'FieldPhoneFr',
is_syntax_valid: function () {
var val = this.$('input').val() || '';
return ((val.length === 0) || rePhone.test(val));
if (this.$input) {
var val = this.$input.val() || '';
return ((val.length === 0) || rePhone.test(val));
} else {
return true;
}
},
render_value: function() {
if (!this.get('effective_readonly')) {
this._super();
} else {
this._super();
if (this.get('effective_readonly')) {
var val = this.get('value') || '';
this.$el.find('a').attr('href', 'tel:' + val).text(val);
}
@ -42,4 +45,8 @@ odoo.define('web.web_widget_phone_check', function(require) {
});
core.form_widget_registry.add('phonefr', FieldPhoneFr);
return {
FieldPhoneFr: FieldPhoneFr
};
});

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@ -18,21 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<templates>
<t t-name="FieldPhoneFr">
<span class="oe_form_field oe_form_field_email"
t-att-style="widget.node.attrs.style">
<a t-if="widget.get('effective_readonly')" href="#"
class="oe_form_uri" target="_blank"/>
<t t-if="!widget.get('effective_readonly')">
<div>
<input type="text"
t-att-id="widget.id_for_label"
t-att-tabindex="widget.node.attrs.tabindex"
t-att-autofocus="widget.node.attrs.autofocus"
t-att-placeholder="widget.node.attrs.placeholder"
t-att-maxlength="widget.field.size"
/>
</div>
</t>
</span>
<t t-if="widget.get('effective_readonly')">
<a t-if="widget.clickable" class="o_form_uri o_text_overflow" href="#" target="_blank"/>
<span t-if="!widget.clickable" class="o_text_overflow"/>
</t>
<input t-if="!widget.get('effective_readonly')" class="o_form_input" type="text"
t-att-id="widget.id_for_label"
t-att-tabindex="widget.node.attrs.tabindex"
t-att-autofocus="widget.node.attrs.autofocus"
t-att-placeholder="widget.node.attrs.placeholder"
t-att-maxlength="widget.field.size" />
</t>
</templates>