diff options
| author | Frédéric van der Essen <fva@openerp.com> | 2012-10-08 17:54:10 +0200 |
|---|---|---|
| committer | Frédéric van der Essen <fva@openerp.com> | 2012-10-08 17:54:10 +0200 |
| commit | f175541201a4e0ce5e49c4d9c9d41e2ec809c9ae (patch) | |
| tree | 8a1bfdaa92bb780a88a499d2c6c2d85f01771244 /addons/web/static | |
| parent | 7bf081d7e656980bfa13dc6bdc072a2f20d94fd2 (diff) | |
| parent | 2ada6891489e77bfd3cbeaa6b8f76866bb5d5845 (diff) | |
[MERGE] from trunk
bzr revid: fva@openerp.com-20121008155410-0ixzq3fbgotalbx4
Diffstat (limited to 'addons/web/static')
| -rw-r--r-- | addons/web/static/src/css/base.css | 8 | ||||
| -rw-r--r-- | addons/web/static/src/css/base.sass | 8 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 72 | ||||
| -rw-r--r-- | addons/web/static/src/js/views.js | 8 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 17 |
5 files changed, 80 insertions, 33 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 61809f2ef7c..c8f1567bee9 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2299,16 +2299,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 41b75bec5c3..823ced4e24f 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1825,13 +1825,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 b41039361c0..6a16c06095d 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -846,10 +846,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } if (form_invalid) { self.set({'display_invalid_fields': true}); - for (var g in self.fields) { - if (!self.fields.hasOwnProperty(g)) { continue; } - self.fields[g]._check_css_flags(); - } first_invalid_field.focus(); self.on_invalid(); return $.Deferred().reject(); @@ -2102,6 +2098,8 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w this._set_required(); } this._check_visibility(); + this.field_manager.off("change:display_invalid_fields", this, this._check_css_flags); + this.field_manager.on("change:display_invalid_fields", this, this._check_css_flags); this._check_css_flags(); }, /** @@ -2167,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(); }, /** @@ -2192,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(); }, /** @@ -2230,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() { @@ -2961,7 +2961,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc title: _t("Open: ") + self.string } ); - pop.on_write_completed.add_last(function() { + pop.on('on_write_complete', self, function(){ self.display_value = {}; self.render_value(); self.focus(); @@ -4110,9 +4110,7 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in title: _t("Open: ") + this.m2m_field.string, readonly: this.getParent().get("effective_readonly") }); - pop.on_write_completed.add_last(function() { - self.reload_content(); - }); + pop.on('on_write_complete', self, self.reload_content); } }); @@ -4359,7 +4357,9 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ }; this.dataset.write_function = function(id, data, options, sup) { var fct = self.options.write_function || sup; - return fct.call(this, id, data, options).then(self.on_write_completed); + return fct.call(this, id, data, options).then(function() { + self.trigger('on_write_complete'); + }); }; this.dataset.parent_view = this.options.parent_view; this.dataset.child_name = this.options.child_name; @@ -4379,7 +4379,6 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ this.$buttonpane = dialog.$el.dialog("widget").find(".ui-dialog-buttonpane").html(""); this.start(); }, - on_write_completed: function() {}, setup_form_view: function() { var self = this; if (this.row_id) { @@ -4992,6 +4991,38 @@ 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"]) + .filter([["id", "=", self.get("currency")]]).first()).pipe(function(res) { + self.set({"currency_info": res}); + }); + }, +}); + /** * Registry of form fields, called by :js:`instance.web.FormView`. * @@ -5022,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/js/views.js b/addons/web/static/src/js/views.js index 21f539fed1b..b98d6d4802b 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1059,11 +1059,11 @@ instance.web.Sidebar = instance.web.Widget.extend({ action_id: item.action.id, context: additional_context }).then(function(result) { - result.result.context = _.extend(result.result.context || {}, + result.context = _.extend(result.context || {}, additional_context); - result.result.flags = result.result.flags || {}; - result.result.flags.new_window = true; - self.do_action(result.result, function () { + result.flags = result.flags || {}; + result.flags.new_window = true; + self.do_action(result, function () { // reload view self.getParent().reload(); }); 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> |
