openerp.web.view_editor = function(openerp) {
var _PROPERTIES = {
- 'field' : ['required', 'readonly'],
+ 'field' : ['name', 'string', 'required', 'readonly', 'domain', 'context', 'nolabel', 'completion',
+ 'colspan', 'eval', 'ref', 'on_change', 'attrs'],
'form' : ['string', 'col', 'link'],
'notebook' : ['colspan', 'position', 'groups'],
'page' : ['string', 'states', 'attrs', 'groups'],
};
var QWeb = openerp.web.qweb;
openerp.web.ViewEditor = openerp.web.Widget.extend({
-
init: function(parent, element_id, dataset, view, options) {
this._super(parent);
this.element_id = element_id
render_name+= ">";
xml_tag+= ">";
});
- obj.main_xml = xml_tag;
+ obj.main_xml = xml;
obj.name = render_name;
return obj;
},
this.dialog.$element.html(QWeb.render('view_editor', {
'data': one_object['main_object'],
}));
-
$("tr[id^='viewedit-']").click(function() {
$("tr[id^='viewedit-']").removeClass('ui-selected');
$(this).addClass('ui-selected');
db = new openerp.web.DataSetSearch(self,'ir.model.fields', null, null);
db.read_slice([],{domain : [['model_id','=',result[0].id],['name','=',fld_name]]},function (res) {
// res will use for getting value of fields.
+ var widget = ['readonly','required','nolable','completion','groups','position','icon','align'];
var k = {"attrs":{"modifiers":"{'readonly':true}","name":"name"},"children":[],"tag":"field"};
_.each(properties,function(record){
- var type_widget = new (self.property.get_any(['undefined' , record, 'field'])) (self.dialog, k);
- $("div[id='"+self.dialog.element_id+"']").append('<div>'+record+''+type_widget.render()+'</div>');
+ if (_.include(widget,record)){
+ var type_widget = new (self.property.get_any(['undefined' , record, 'field'])) (self.dialog, k);
+ $("div[id='"+self.dialog.element_id+"']").append('<div>'+record+''+type_widget.render()+'</div>');
+ type_widget.set_value(res[0][record]);
+ }else{
+ var type_widget = new openerp.web.ViewEditor.FieldChar (self.dialog, k);
+ $("div[id='"+self.dialog.element_id+"']").append('<div id="res">'+record+''+type_widget.render()+'</div>');
+ type_widget.set_value(res[0][record]);
+ }
});
});
});
});
openerp.web.ViewEditor.FieldBoolean = openerp.web.form.FieldBoolean.extend({
init: function(view, node) {
- //this._super(view, node);
- this.template = "FieldBoolean";
+ this.$element = view.$element;
},
start: function() {
var self = this;
this._super.apply(this, arguments);
+ },
+ set_value: function(value) {
+ if (value === false || value === undefined) {
+ // As in GTK client, floats default to 0
+ value = 0;
+ this.dirty = true;
+ }
+ this._super.apply(this, [value]);
+ }
+});
+openerp.web.ViewEditor.FieldChar = openerp.web.form.FieldChar.extend({
+ init: function(view, node) {
+ this.$element = view.$element;
+ },
+ start: function() {
+ var self = this;
+ this._super.apply(this, arguments);
+ },
+ set_value: function(value) {
+ if (value === false || value === undefined) {
+ // As in GTK client, floats default to 0
+ value = 0;
+ this.dirty = true;
+ }
+ this._super.apply(this, [value]);
}
});
'readonly' : 'openerp.web.ViewEditor.FieldBoolean',
'nolabel' : 'openerp.web.ViewEditor.FieldBoolean',
'completion' : 'openerp.web.ViewEditor.FieldBoolean',
- /*'widget' : '',
- 'groups' : '',
+ /*'groups' : 'openerp.web.ViewEditor.WidgetFrame',
'position': '',
'icon': '',
'align': '' */
/**
* @constructs openerp.web.FormView
* @extends openerp.web.View
- *
+ *
* @param {openerp.web.Session} session the current openerp session
* @param {openerp.web.DataSet} dataset the dataset this view will work with
* @param {String} view_id the identifier of the OpenERP view object
},
update_dom: function() {
this._super.apply(this, arguments);
- if (this.field.translate) {
+ /* if (this.field.translate) {
this.$element.find('.oe_field_translate').toggle(!!this.view.datarecord.id);
}
if (!this.disable_utility_classes) {
if (this.view.show_invalid) {
this.$element.toggleClass('invalid', !this.is_valid());
}
- }
+ }*/
},
on_ui_change: function() {
this.dirty = this.view.dirty_for_user = true;
}).pipe(function() {
self.searchview.do_search();
});
-
+
});
this.searchview.appendTo($("#" + this.element_id + "_search"));
},
start: function() {
this._super();
this.selected_value = null;
-
+
this.render_list();
},
set_value: function(value) {
this._super(value);
this.selected_value = value;
-
+
this.render_list();
},
render_list: function() {
var shown = _.map(((this.node.attrs || {}).statusbar_visible || "").split(","),
function(x) { return x.trim(); });
shown = _.select(shown, function(x) { return x.length > 0; });
-
+
if (shown.length == 0) {
this.to_show = this.field.selection;
} else {
return _.indexOf(shown, x[0]) !== -1 || x[0] === self.selected_value;
});
}
-
+
var content = openerp.web.qweb.render("FieldStatus.content", {widget: this, _:_});
this.$element.html(content);
-
+
var colors = JSON.parse((this.node.attrs || {}).statusbar_colors || "{}");
var color = colors[this.selected_value];
if (color) {