[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({ var FieldPhoneFr = widget.FieldChar.extend({
template: 'FieldPhoneFr', template: 'FieldPhoneFr',
is_syntax_valid: function () { is_syntax_valid: function () {
var val = this.$('input').val() || ''; if (this.$input) {
return ((val.length === 0) || rePhone.test(val)); var val = this.$input.val() || '';
return ((val.length === 0) || rePhone.test(val));
} else {
return true;
}
}, },
render_value: function() { render_value: function() {
if (!this.get('effective_readonly')) { this._super();
this._super(); if (this.get('effective_readonly')) {
} else {
var val = this.get('value') || ''; var val = this.get('value') || '';
this.$el.find('a').attr('href', 'tel:' + val).text(val); 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); core.form_widget_registry.add('phonefr', FieldPhoneFr);
return {
FieldPhoneFr: FieldPhoneFr
};
}); });

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?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 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 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> <templates>
<t t-name="FieldPhoneFr"> <t t-name="FieldPhoneFr">
<span class="oe_form_field oe_form_field_email" <t t-if="widget.get('effective_readonly')">
t-att-style="widget.node.attrs.style"> <a t-if="widget.clickable" class="o_form_uri o_text_overflow" href="#" target="_blank"/>
<a t-if="widget.get('effective_readonly')" href="#" <span t-if="!widget.clickable" class="o_text_overflow"/>
class="oe_form_uri" target="_blank"/> </t>
<t t-if="!widget.get('effective_readonly')"> <input t-if="!widget.get('effective_readonly')" class="o_form_input" type="text"
<div> t-att-id="widget.id_for_label"
<input type="text" t-att-tabindex="widget.node.attrs.tabindex"
t-att-id="widget.id_for_label" t-att-autofocus="widget.node.attrs.autofocus"
t-att-tabindex="widget.node.attrs.tabindex" t-att-placeholder="widget.node.attrs.placeholder"
t-att-autofocus="widget.node.attrs.autofocus" t-att-maxlength="widget.field.size" />
t-att-placeholder="widget.node.attrs.placeholder"
t-att-maxlength="widget.field.size"
/>
</div>
</t>
</span>
</t> </t>
</templates> </templates>