diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2012-10-08 17:28:31 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2012-10-08 17:28:31 +0200 |
| commit | 57cc1e3329c6d88b06fdd6e4d986ee6feadb159e (patch) | |
| tree | 9909746981f2433823ae64c18367bf79a7f78af9 /addons/web/static/src | |
| parent | 06fd81019ca693abde0df78c4de73ffb6617cc5a (diff) | |
added field monetary
bzr revid: nicolas.vanhoren@openerp.com-20121008152831-7r4ow3ljuxvedm7v
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/css/base.css | 11 | ||||
| -rw-r--r-- | addons/web/static/src/css/base.sass | 8 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 54 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 17 |
4 files changed, 69 insertions, 21 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 3d54aef0fa2..44fcadbf9cc 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -25,7 +25,6 @@ display: none !important; } } - .openerp.openerp_webclient_container { height: 100%; position: relative; @@ -46,7 +45,7 @@ text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5); /* http://www.quirksmode.org/dom/inputfile.html * http://stackoverflow.com/questions/2855589/replace-input-type-file-by-an-image - */ */ + */ } .openerp :-moz-placeholder { color: #afafb6 !important; @@ -2294,16 +2293,16 @@ margin-bottom: 32px; text-align: justify; } -.openerp .oe_form_editable .oe_form .oe_form_field_integer { +.openerp .oe_form_editable .oe_form .oe_form_field_integer input { width: 6em !important; } -.openerp .oe_form_editable .oe_form .oe_form_field_float { +.openerp .oe_form_editable .oe_form .oe_form_field_float input { width: 7em !important; } -.openerp .oe_form_editable .oe_form .oe_form_field_date { +.openerp .oe_form_editable .oe_form .oe_form_field_date input { width: 7.5em !important; } -.openerp .oe_form_editable .oe_form .oe_form_field_datetime { +.openerp .oe_form_editable .oe_form .oe_form_field_datetime input { width: 11.5em !important; } .openerp .oe_hidden_input_file { diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 0567d31b1eb..1ab41aa400f 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1822,13 +1822,13 @@ $sheet-max-width: 860px .oe_form_editable .oe_form - .oe_form_field_integer + .oe_form_field_integer input width: 6em !important - .oe_form_field_float + .oe_form_field_float input width: 7em !important - .oe_form_field_date + .oe_form_field_date input width: 7.5em !important - .oe_form_field_datetime + .oe_form_field_datetime input width: 11.5em !important // }}} // FormView.fields_binary {{{ diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 5638d95a3a9..e23510c02f4 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2165,11 +2165,12 @@ instance.web.form.ReinitializeWidgetMixin = { this.initialize_field(); }, initialize_field: function() { - this.on("change:effective_readonly", this, function() { - this.destroy_content(); - this.renderElement(); - this.initialize_content(); - }); + this.on("change:effective_readonly", this, this.reinitialize); + this.initialize_content(); + }, + reinitialize: function() { + this.destroy_content(); + this.renderElement(); this.initialize_content(); }, /** @@ -2190,9 +2191,10 @@ instance.web.form.ReinitializeWidgetMixin = { instance.web.form.ReinitializeFieldMixin = _.extend({}, instance.web.form.ReinitializeWidgetMixin, { initialize_field: function() { instance.web.form.ReinitializeWidgetMixin.initialize_field.call(this); - this.on("change:effective_readonly", this, function() { - this.render_value(); - }); + this.render_value(); + }, + reinitialize: function() { + instance.web.form.ReinitializeWidgetMixin.reinitialize.call(this); this.render_value(); }, /** @@ -2228,7 +2230,7 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we if (this.password) { show_value = new Array(show_value.length + 1).join('*'); } - this.$el.text(show_value); + this.$(".oe_form_char_content").text(show_value); } }, is_syntax_valid: function() { @@ -4990,6 +4992,37 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ }, }); +instance.web.form.FieldMonetary = instance.web.form.FieldFloat.extend({ + template: "FieldMonetary", + init: function() { + this._super.apply(this, arguments); + this.set({"currency": false}); + if (this.options.currency_field) { + this.field_manager.on("field_changed:" + this.options.currency_field, this, function() { + this.set({"currency": this.field_manager.get_field_value(this.options.currency_field)}); + }); + } + this.on("change:currency", this, this.get_currency_info); + this.get_currency_info(); + this.ci_dm = new instance.web.DropMisordered(); + }, + start: function() { + var tmp = this._super(); + this.on("change:currency_info", this, this.reinitialize); + return tmp; + }, + get_currency_info: function() { + var self = this; + if (this.get("currency") === false) { + this.set({"currency_info": null}); + return; + } + return this.ci_dm.add(new instance.web.Model("res.currency").query(["symbol", "position"]).first()).pipe(function(res) { + self.set({"currency_info": res}); + }); + }, +}); + /** * Registry of form fields, called by :js:`instance.web.FormView`. * @@ -5020,7 +5053,8 @@ instance.web.form.widgets = new instance.web.Registry({ 'progressbar': 'instance.web.form.FieldProgressBar', 'image': 'instance.web.form.FieldBinaryImage', 'binary': 'instance.web.form.FieldBinaryFile', - 'statusbar': 'instance.web.form.FieldStatus' + 'statusbar': 'instance.web.form.FieldStatus', + 'monetary': 'instance.web.form.FieldMonetary', }); /** diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index bf55db8d7c2..5e8e430e771 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -916,7 +916,7 @@ </t> <t t-name="FieldChar"> <span t-att-class="'oe_form_field '+widget.widget_class" t-att-style="widget.node.attrs.style"> - <t t-if="!widget.get('effective_readonly')"> + <t t-if="!widget.get('effective_readonly')"> <input t-att-type="widget.password ? 'password' : 'text'" t-att-id="widget.id_for_label" t-att-tabindex="widget.node.attrs.tabindex" @@ -925,6 +925,9 @@ t-att-maxlength="widget.field.size" /><img class="oe_field_translate oe_input_icon" t-if="widget.field.translate" t-att-src='_s + "/web/static/src/img/icons/terp-translate.png"' width="16" height="16" border="0"/> </t> + <t t-if="widget.get('effective_readonly')"> + <span class="oe_form_char_content"></span> + </t> </span> </t> <t t-name="FieldEmail"> @@ -1717,4 +1720,16 @@ <button class="oe_form_m2o_sc_button oe_button">Add All Info...</button> <button class="oe_form_m2o_cancel_button oe_button">Cancel</button> </t> +<t t-name="FieldMonetary" t-extend="FieldChar"> + <t t-jquery="t:first" t-operation="before"> + <t t-if="widget.get('currency_info') and widget.get('currency_info').position === 'before'"> + <t t-esc="widget.get('currency_info').symbol"/> + </t> + </t> + <t t-jquery="t:last" t-operation="after"> + <t t-if="widget.get('currency_info') and widget.get('currency_info').position === 'after'"> + <t t-esc="widget.get('currency_info').symbol"/> + </t> + </t> +</t> </templates> |
