Use properties
issue8109 review47811003
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Use properties
|
||||
* Allow sao classes to use javascript properties
|
||||
* Improve layout of CSV import/export
|
||||
* Add support for height and width on notebook
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@
|
||||
|
||||
if (this.screen.current_view.view_type == 'tree' &&
|
||||
(this.screen.current_view.attributes.keyword_open == 1)) {
|
||||
record_ids = this.screen.current_view.selected_records().map(
|
||||
record_ids = this.screen.current_view.selected_records.map(
|
||||
function(record) { return record.id; });
|
||||
Sao.Action.exec_keyword('tree_open', {
|
||||
model: this.screen.model_name,
|
||||
|
||||
+86
-76
@@ -64,19 +64,21 @@
|
||||
array.forEach(function(e, i, a) {
|
||||
e.group = a;
|
||||
});
|
||||
array.get_readonly = function() {
|
||||
// Must skip res.user for Preference windows
|
||||
var access = Sao.common.MODELACCESS.get(this.model.name);
|
||||
if (this.context()._datetime ||
|
||||
Object.defineProperty(array, 'readonly', {
|
||||
get: function() {
|
||||
// Must skip res.user for Preference windows
|
||||
var access = Sao.common.MODELACCESS.get(this.model.name);
|
||||
if (this.context._datetime ||
|
||||
(!(access.write || access.create) &&
|
||||
!this.skip_model_access)) {
|
||||
return true;
|
||||
!this.skip_model_access)) {
|
||||
return true;
|
||||
}
|
||||
return this.__readonly;
|
||||
},
|
||||
set: function(value) {
|
||||
this.__readonly = value;
|
||||
}
|
||||
return this.__readonly;
|
||||
};
|
||||
array.set_readonly = function(value) {
|
||||
this.__readonly = value;
|
||||
};
|
||||
});
|
||||
array.load = function(ids, modified) {
|
||||
var new_records = [];
|
||||
var i, len;
|
||||
@@ -112,7 +114,7 @@
|
||||
new_records.forEach(function(record) {
|
||||
record._changed.id = true;
|
||||
});
|
||||
var root_group = this.root_group();
|
||||
var root_group = this.root_group;
|
||||
this.changed().then(function() {
|
||||
root_group.screens.forEach(function(screen) {
|
||||
screen.display();
|
||||
@@ -247,17 +249,17 @@
|
||||
if (jQuery.isEmptyObject(records)) {
|
||||
return jQuery.when();
|
||||
}
|
||||
var root_group = this.root_group();
|
||||
var root_group = this.root_group;
|
||||
console.assert(records.every(function(r) {
|
||||
return r.model.name == this.model.name;
|
||||
}.bind(this)), 'records not from the same model');
|
||||
console.assert(records.every(function(r) {
|
||||
return r.group.root_group() == root_group;
|
||||
return r.group.root_group == root_group;
|
||||
}), 'records not from the same root group');
|
||||
records = records.filter(function(record) {
|
||||
return record.id >= 0;
|
||||
});
|
||||
var context = this.context();
|
||||
var context = this.context;
|
||||
context._timestamp = {};
|
||||
records.forEach(function(record) {
|
||||
jQuery.extend(context._timestamp, record.get_timestamp());
|
||||
@@ -275,15 +277,17 @@
|
||||
});
|
||||
}.bind(this));
|
||||
};
|
||||
array.root_group = function() {
|
||||
var root = this;
|
||||
var parent = this.parent;
|
||||
while (parent) {
|
||||
root = parent.group;
|
||||
parent = parent.parent;
|
||||
Object.defineProperty(array, 'root_group', {
|
||||
get: function() {
|
||||
var root = this;
|
||||
var parent = this.parent;
|
||||
while (parent) {
|
||||
root = parent.group;
|
||||
parent = parent.parent;
|
||||
}
|
||||
return root;
|
||||
}
|
||||
return root;
|
||||
};
|
||||
});
|
||||
array.save = function() {
|
||||
var deferreds = [];
|
||||
this.forEach(function(record) {
|
||||
@@ -306,7 +310,7 @@
|
||||
to_reload = to_reload.filter(function(e) {
|
||||
return !~ids.indexOf(e);
|
||||
});
|
||||
this.root_group().reload(to_reload);
|
||||
this.root_group.reload(to_reload);
|
||||
}.bind(this));
|
||||
};
|
||||
array.reload = function(ids) {
|
||||
@@ -354,12 +358,12 @@
|
||||
}
|
||||
});
|
||||
if (new_.length && added.length) {
|
||||
this.model.execute('default_get', [added, this.context()])
|
||||
this.model.execute('default_get', [added, this.context])
|
||||
.then(function(values) {
|
||||
new_.forEach(function(record) {
|
||||
record.set_default(values, true, false);
|
||||
});
|
||||
this.root_group().screens.forEach(function(screen) {
|
||||
this.root_group.screens.forEach(function(screen) {
|
||||
return screen.display();
|
||||
});
|
||||
}.bind(this));
|
||||
@@ -374,41 +378,45 @@
|
||||
}
|
||||
this.parent = null;
|
||||
};
|
||||
array.domain = function() {
|
||||
var domain = [];
|
||||
this.screens.forEach(function(screen) {
|
||||
if (screen.attributes.domain) {
|
||||
domain.push(screen.attributes.domain);
|
||||
}
|
||||
});
|
||||
if (this.parent && this.child_name) {
|
||||
var field = this.parent.model.fields[this.child_name];
|
||||
return [domain, field.get_domain(this.parent)];
|
||||
} else {
|
||||
return domain;
|
||||
}
|
||||
};
|
||||
array.context = function() {
|
||||
var context = jQuery.extend({}, this.model.session.context);
|
||||
if (this.parent) {
|
||||
var parent_context = this.parent.get_context();
|
||||
jQuery.extend(context, parent_context);
|
||||
if (this.child_name in this.parent.model.fields) {
|
||||
Object.defineProperty(array, 'domain', {
|
||||
get: function() {
|
||||
var domain = [];
|
||||
this.screens.forEach(function(screen) {
|
||||
if (screen.attributes.domain) {
|
||||
domain.push(screen.attributes.domain);
|
||||
}
|
||||
});
|
||||
if (this.parent && this.child_name) {
|
||||
var field = this.parent.model.fields[this.child_name];
|
||||
jQuery.extend(context, field.get_context(
|
||||
this.parent, parent_context));
|
||||
return [domain, field.get_domain(this.parent)];
|
||||
} else {
|
||||
return domain;
|
||||
}
|
||||
}
|
||||
jQuery.extend(context, this._context);
|
||||
if (this.parent_datetime_field) {
|
||||
context._datetime = this.parent.get_eval()
|
||||
[this.parent_datetime_field];
|
||||
});
|
||||
Object.defineProperty(array, 'context', {
|
||||
get: function() {
|
||||
var context = jQuery.extend({}, this.model.session.context);
|
||||
if (this.parent) {
|
||||
var parent_context = this.parent.get_context();
|
||||
jQuery.extend(context, parent_context);
|
||||
if (this.child_name in this.parent.model.fields) {
|
||||
var field = this.parent.model.fields[this.child_name];
|
||||
jQuery.extend(context, field.get_context(
|
||||
this.parent, parent_context));
|
||||
}
|
||||
}
|
||||
jQuery.extend(context, this._context);
|
||||
if (this.parent_datetime_field) {
|
||||
context._datetime = this.parent.get_eval()
|
||||
[this.parent_datetime_field];
|
||||
}
|
||||
return context;
|
||||
},
|
||||
set: function(context) {
|
||||
this._context = jQuery.extend({}, context);
|
||||
}
|
||||
return context;
|
||||
};
|
||||
array.set_context = function(context) {
|
||||
this._context = jQuery.extend({}, context);
|
||||
};
|
||||
});
|
||||
array.clean4inversion = function(domain) {
|
||||
if (jQuery.isEmptyObject(domain)) {
|
||||
return [];
|
||||
@@ -429,7 +437,7 @@
|
||||
return [head].concat(this.clean4inversion(tail));
|
||||
};
|
||||
array.domain4inversion = function() {
|
||||
var domain = this.domain();
|
||||
var domain = this.domain;
|
||||
if (!this.__domain4inversion ||
|
||||
!Sao.common.compare(this.__domain4inversion[0], domain)) {
|
||||
this.__domain4inversion = [domain, this.clean4inversion(domain)];
|
||||
@@ -809,7 +817,7 @@
|
||||
return fields;
|
||||
},
|
||||
get_context: function() {
|
||||
return this.group.context();
|
||||
return this.group.context;
|
||||
},
|
||||
field_get: function(name) {
|
||||
return this.model.fields[name].get(this);
|
||||
@@ -885,7 +893,7 @@
|
||||
return this.on_change_with(fieldnames).then(function() {
|
||||
var callback = function() {
|
||||
if (display) {
|
||||
return this.group.root_group().screens
|
||||
return this.group.root_group.screens
|
||||
.forEach(function(screen) {
|
||||
return screen.display();
|
||||
});
|
||||
@@ -1197,7 +1205,7 @@
|
||||
return Sao.common.compare(Object.keys(this.model.fields).sort(),
|
||||
Object.keys(this._loaded).sort());
|
||||
},
|
||||
root_parent: function root_parent() {
|
||||
get root_parent() {
|
||||
var parent = this;
|
||||
while (parent.group.parent) {
|
||||
parent = parent.group.parent;
|
||||
@@ -1232,14 +1240,14 @@
|
||||
path.reverse();
|
||||
return path;
|
||||
},
|
||||
deleted: function() {
|
||||
get deleted() {
|
||||
return Boolean(~this.group.record_deleted.indexOf(this));
|
||||
},
|
||||
removed: function() {
|
||||
get removed() {
|
||||
return Boolean(~this.group.record_removed.indexOf(this));
|
||||
},
|
||||
readonly: function() {
|
||||
return this.deleted() || this.removed() || this.exception;
|
||||
get readonly() {
|
||||
return this.deleted || this.removed || this.exception;
|
||||
},
|
||||
set_field_context: function() {
|
||||
for (var name in this.model.fields) {
|
||||
@@ -1248,12 +1256,14 @@
|
||||
}
|
||||
var field = this.model.fields[name];
|
||||
var value = this._values[name];
|
||||
if (!value || !value.set_context) {
|
||||
var context_descriptor = Object.getOwnPropertyDescriptor(
|
||||
value, 'context');
|
||||
if (!value || !context_descriptor.set) {
|
||||
continue;
|
||||
}
|
||||
var context = field.description.context;
|
||||
if (context) {
|
||||
value.set_context(this.expr_eval(context));
|
||||
value.context = this.expr_eval(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1396,7 +1406,7 @@
|
||||
record._changed[this.name] = true;
|
||||
this.changed(record).done(function() {
|
||||
record.validate(null, true).then(function() {
|
||||
var root_group = record.group.root_group();
|
||||
var root_group = record.group.root_group;
|
||||
root_group.screens.forEach(function(screen) {
|
||||
screen.display();
|
||||
});
|
||||
@@ -1495,7 +1505,7 @@
|
||||
this.description[state];
|
||||
}
|
||||
}.bind(this));
|
||||
if (record.group.get_readonly() ||
|
||||
if (record.group.readonly ||
|
||||
this.get_state_attrs(record).domain_readonly) {
|
||||
this.get_state_attrs(record).readonly = true;
|
||||
}
|
||||
@@ -1505,7 +1515,7 @@
|
||||
record.state_attrs[this.name] = jQuery.extend(
|
||||
{}, this.description);
|
||||
}
|
||||
if (record.group.get_readonly() || record.readonly()) {
|
||||
if (record.group.readonly || record.readonly) {
|
||||
record.state_attrs[this.name].readonly = true;
|
||||
}
|
||||
return record.state_attrs[this.name];
|
||||
@@ -1559,8 +1569,8 @@
|
||||
}
|
||||
var setdefault = true;
|
||||
var original_domain;
|
||||
if (!jQuery.isEmptyObject(record.group.domain())) {
|
||||
original_domain = inversion.merge(record.group.domain());
|
||||
if (!jQuery.isEmptyObject(record.group.domain)) {
|
||||
original_domain = inversion.merge(record.group.domain);
|
||||
} else {
|
||||
original_domain = inversion.merge(domain);
|
||||
}
|
||||
@@ -1673,7 +1683,7 @@
|
||||
Sao.field.TimeDelta = Sao.class_(Sao.field.Field, {
|
||||
_default: null,
|
||||
converter: function(group) {
|
||||
return group.context()[this.description.converter];
|
||||
return group.context[this.description.converter];
|
||||
},
|
||||
set_client: function(record, value, force_change) {
|
||||
if (typeof(value) == 'string') {
|
||||
@@ -1848,7 +1858,7 @@
|
||||
'params': [[value], ['rec_name'], record.get_context()]
|
||||
}, record.model.session).done(store_rec_name.bind(this)).done(
|
||||
function() {
|
||||
record.group.root_group().screens.forEach(
|
||||
record.group.root_group.screens.forEach(
|
||||
function(screen) {
|
||||
screen.display();
|
||||
});
|
||||
@@ -2083,7 +2093,7 @@
|
||||
record._changed[this.name] = true;
|
||||
this.changed(record).done(function() {
|
||||
record.validate(null, true).then(function() {
|
||||
var root_group = record.group.root_group();
|
||||
var root_group = record.group.root_group;
|
||||
root_group.screens.forEach(function(screen) {
|
||||
screen.display();
|
||||
});
|
||||
@@ -2242,7 +2252,7 @@
|
||||
for (var i = 0, len = record._values[this.name].length; i < len;
|
||||
i++) {
|
||||
var record2 = group[i];
|
||||
if (!record2.deleted() && !record2.removed())
|
||||
if (!record2.deleted && !record2.removed)
|
||||
result.push(record2.get_on_change_value(
|
||||
[this.description.relation_field || '']));
|
||||
}
|
||||
|
||||
+1
-1
@@ -883,7 +883,7 @@ var Sao = {};
|
||||
var ir_model = new Sao.Model('ir.model');
|
||||
return ir_model.execute('global_search',
|
||||
[text, Sao.config.limit, Sao.main_menu_screen.model_name],
|
||||
Sao.main_menu_screen.context())
|
||||
Sao.main_menu_screen.context)
|
||||
.then(function(s_results) {
|
||||
var results = [];
|
||||
for (var i=0, len=s_results.length; i < len; i++) {
|
||||
|
||||
+55
-53
@@ -200,7 +200,7 @@
|
||||
this.bookmark_match();
|
||||
},
|
||||
update: function() {
|
||||
var completions = this.screen.domain_parser().completion(
|
||||
var completions = this.screen.domain_parser.completion(
|
||||
this.get_text());
|
||||
this.search_list.children().remove();
|
||||
completions.forEach(function(e) {
|
||||
@@ -247,13 +247,13 @@
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
var domain = this.screen.domain_parser().parse(text);
|
||||
var domain = this.screen.domain_parser.parse(text);
|
||||
Sao.common.VIEW_SEARCH.add(model_name, name, domain)
|
||||
.then(function() {
|
||||
refresh();
|
||||
});
|
||||
this.set_text(
|
||||
this.screen.domain_parser().string(domain));
|
||||
this.screen.domain_parser.string(domain));
|
||||
}.bind(this));
|
||||
} else {
|
||||
var id = this.bookmark_match();
|
||||
@@ -265,19 +265,19 @@
|
||||
bookmarks: function() {
|
||||
var searches = Sao.common.VIEW_SEARCH.get(this.screen.model_name);
|
||||
return searches.filter(function(search) {
|
||||
return this.screen.domain_parser().stringable(search[2]);
|
||||
return this.screen.domain_parser.stringable(search[2]);
|
||||
}.bind(this));
|
||||
},
|
||||
bookmark_activate: function(e) {
|
||||
e.preventDefault();
|
||||
var domain = e.data;
|
||||
this.set_text(this.screen.domain_parser().string(domain));
|
||||
this.set_text(this.screen.domain_parser.string(domain));
|
||||
this.do_search();
|
||||
},
|
||||
bookmark_match: function() {
|
||||
var current_text = this.get_text();
|
||||
if (current_text) {
|
||||
var current_domain = this.screen.domain_parser().parse(
|
||||
var current_domain = this.screen.domain_parser.parse(
|
||||
current_text);
|
||||
this.but_star.prop('disabled', !current_text);
|
||||
var star = this.get_star();
|
||||
@@ -286,7 +286,7 @@
|
||||
var id = bookmarks[i][0];
|
||||
var name = bookmarks[i][1];
|
||||
var domain = bookmarks[i][2];
|
||||
var text = this.screen.domain_parser().string(domain);
|
||||
var text = this.screen.domain_parser.string(domain);
|
||||
if ((text === current_text) ||
|
||||
(Sao.common.compare(domain, current_domain))) {
|
||||
this.set_star(true);
|
||||
@@ -387,7 +387,7 @@
|
||||
return this.search_entry.val();
|
||||
},
|
||||
search_box: function() {
|
||||
var domain_parser = this.screen.domain_parser();
|
||||
var domain_parser = this.screen.domain_parser;
|
||||
var search = function() {
|
||||
this.search_modal.modal('hide');
|
||||
var text = '';
|
||||
@@ -487,7 +487,7 @@
|
||||
case 'time':
|
||||
var format;
|
||||
var date_format = Sao.common.date_format(
|
||||
this.screen.context().date_format);
|
||||
this.screen.context.date_format);
|
||||
if (field.type == 'date') {
|
||||
format = date_format;
|
||||
} else {
|
||||
@@ -760,7 +760,7 @@
|
||||
view = this.views_preload[view_type];
|
||||
} else {
|
||||
var prm = this.model.execute('fields_view_get',
|
||||
[view_id, view_type], this.context());
|
||||
[view_id, view_type], this.context);
|
||||
return prm.pipe(this.add_view.bind(this));
|
||||
}
|
||||
this.add_view(view);
|
||||
@@ -798,7 +798,7 @@
|
||||
|
||||
return view_widget;
|
||||
},
|
||||
number_of_views: function() {
|
||||
get number_of_views() {
|
||||
return this.views.length + this.view_to_load.length;
|
||||
},
|
||||
switch_view: function(view_type, view_id) {
|
||||
@@ -891,20 +891,20 @@
|
||||
this.context_screen.display(true);
|
||||
return jQuery.when();
|
||||
}
|
||||
this.new_group(jQuery.extend(this.context(),
|
||||
this.new_group(jQuery.extend(this.context,
|
||||
this.context_screen.get_on_change_value()));
|
||||
}
|
||||
|
||||
var domain = this.search_domain(search_string, true);
|
||||
if (this.context_domain) {
|
||||
var decoder = new Sao.PYSON.Decoder(this.context());
|
||||
var decoder = new Sao.PYSON.Decoder(this.context);
|
||||
domain = ['AND', domain, decoder.decode(this.context_domain)];
|
||||
}
|
||||
var tab_domain = this.screen_container.get_tab_domain();
|
||||
if (!jQuery.isEmptyObject(tab_domain)) {
|
||||
domain = ['AND', domain, tab_domain];
|
||||
}
|
||||
var context = this.context();
|
||||
var context = this.context;
|
||||
if (this.screen_container.but_active.hasClass('active')) {
|
||||
context.active_test = false;
|
||||
}
|
||||
@@ -960,8 +960,8 @@
|
||||
var domain = [];
|
||||
|
||||
// Test first parent to avoid calling unnecessary domain_parser
|
||||
if (!this.group.parent && this.domain_parser()) {
|
||||
var domain_parser = this.domain_parser();
|
||||
if (!this.group.parent && this.domain_parser) {
|
||||
var domain_parser = this.domain_parser;
|
||||
if (search_string || search_string === '') {
|
||||
domain = domain_parser.parse(search_string);
|
||||
} else {
|
||||
@@ -1010,15 +1010,15 @@
|
||||
var domain = ['AND', tab_domain[1], screen_domain];
|
||||
this.screen_container.set_tab_counter(null, i);
|
||||
this.group.model.execute(
|
||||
'search_count', [domain], this.context())
|
||||
'search_count', [domain], this.context)
|
||||
.then(function(count) {
|
||||
this.screen_container.set_tab_counter(count, i);
|
||||
}.bind(this));
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
context: function() {
|
||||
var context = this.group.context();
|
||||
get context() {
|
||||
var context = this.group.context;
|
||||
if ( this.context_screen ){
|
||||
context.context_model = this.context_screen.model_name;
|
||||
}
|
||||
@@ -1050,9 +1050,9 @@
|
||||
this.group = group;
|
||||
this.model = group.model;
|
||||
if (group && group.length) {
|
||||
this.set_current_record(group[0]);
|
||||
this.current_record = group[0];
|
||||
} else {
|
||||
this.set_current_record(null);
|
||||
this.current_record = null;
|
||||
}
|
||||
this.group.add_fields(fields);
|
||||
var views_add = function(view) {
|
||||
@@ -1066,14 +1066,17 @@
|
||||
},
|
||||
new_group: function(context) {
|
||||
if (!context) {
|
||||
context = this.context();
|
||||
context = this.context;
|
||||
}
|
||||
var group = new Sao.Group(this.model, context, []);
|
||||
group.set_readonly(this.attributes.readonly || false);
|
||||
group.readonly = this.attributes.readonly || false;
|
||||
this.set_group(group);
|
||||
},
|
||||
set_current_record: function(record) {
|
||||
this.current_record = record;
|
||||
get current_record() {
|
||||
return this.__current_record;
|
||||
},
|
||||
set current_record(record) {
|
||||
this.__current_record = record;
|
||||
if (this.message_callback){
|
||||
var pos = null;
|
||||
var record_id = null;
|
||||
@@ -1149,7 +1152,7 @@
|
||||
}
|
||||
return jQuery.when.apply(jQuery, deferreds).then(function() {
|
||||
return this.set_tree_state().then(function() {
|
||||
this.set_current_record(this.current_record);
|
||||
this.current_record = this.current_record;
|
||||
// set_cursor must be called after set_tree_state because
|
||||
// set_tree_state redraws the tree
|
||||
if (set_cursor) {
|
||||
@@ -1180,9 +1183,9 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.set_current_record(record);
|
||||
this.current_record = record;
|
||||
} else {
|
||||
this.set_current_record(this.group[0]);
|
||||
this.current_record = this.group[0];
|
||||
}
|
||||
this.set_cursor(false, false);
|
||||
view.display();
|
||||
@@ -1209,9 +1212,9 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.set_current_record(record);
|
||||
this.current_record = record;
|
||||
} else {
|
||||
this.set_current_record(this.group[0]);
|
||||
this.current_record = this.group[0];
|
||||
}
|
||||
this.set_cursor(false, false);
|
||||
view.display();
|
||||
@@ -1271,7 +1274,7 @@
|
||||
}
|
||||
return prm.then(function() {
|
||||
group.add(record, this.new_model_position());
|
||||
this.set_current_record(record);
|
||||
this.current_record = record;
|
||||
var prm = jQuery.when();
|
||||
if (previous_view.view_type == 'calendar') {
|
||||
prm = previous_view.set_default_date(
|
||||
@@ -1323,7 +1326,7 @@
|
||||
if (!current_record) {
|
||||
if ((this.current_view.view_type == 'tree') &&
|
||||
this.group && this.group.length) {
|
||||
this.set_current_record(this.group[0]);
|
||||
this.current_record = this.group[0];
|
||||
current_record = this.current_record;
|
||||
} else {
|
||||
return jQuery.when();
|
||||
@@ -1357,7 +1360,7 @@
|
||||
[path[path.length - 1][0], current_record.id]);
|
||||
}
|
||||
return this.group.get_by_path(path).then(function(record) {
|
||||
this.set_current_record(record);
|
||||
this.current_record = record;
|
||||
}.bind(this));
|
||||
}.bind(this)).then(function() {
|
||||
this.display().always(dfd.resolve);
|
||||
@@ -1392,14 +1395,14 @@
|
||||
return false;
|
||||
},
|
||||
unremove: function() {
|
||||
var records = this.current_view.selected_records();
|
||||
var records = this.current_view.selected_records;
|
||||
records.forEach(function(record) {
|
||||
record.group.unremove(record);
|
||||
});
|
||||
},
|
||||
remove: function(delete_, remove, force_remove, records) {
|
||||
var prm = jQuery.when();
|
||||
records = records || this.current_view.selected_records();
|
||||
records = records || this.current_view.selected_records;
|
||||
if (jQuery.isEmptyObject(records)) {
|
||||
return prm;
|
||||
}
|
||||
@@ -1440,10 +1443,10 @@
|
||||
}
|
||||
if (!jQuery.isEmptyObject(path)) {
|
||||
prms.push(this.group.get_by_path(path).then(function(record) {
|
||||
this.set_current_record(record);
|
||||
this.current_record = record;
|
||||
}.bind(this)));
|
||||
} else if (this.group.length) {
|
||||
this.set_current_record(this.group[0]);
|
||||
this.current_record = this.group[0];
|
||||
}
|
||||
|
||||
return jQuery.when.apply(jQuery, prms).then(function() {
|
||||
@@ -1455,12 +1458,12 @@
|
||||
},
|
||||
copy: function() {
|
||||
var dfd = jQuery.Deferred();
|
||||
var records = this.current_view.selected_records();
|
||||
this.model.copy(records, this.context())
|
||||
var records = this.current_view.selected_records;
|
||||
this.model.copy(records, this.context)
|
||||
.then(function(new_ids) {
|
||||
this.group.load(new_ids);
|
||||
if (!jQuery.isEmptyObject(new_ids)) {
|
||||
this.set_current_record(this.group.get(new_ids[0]));
|
||||
this.current_record = this.group.get(new_ids[0]);
|
||||
}
|
||||
this.display().always(dfd.resolve);
|
||||
}.bind(this), dfd.reject);
|
||||
@@ -1475,7 +1478,7 @@
|
||||
}
|
||||
return jQuery.when();
|
||||
},
|
||||
domain_parser: function() {
|
||||
get domain_parser() {
|
||||
var view_id, view_tree, domain_parser;
|
||||
if (this.current_view) {
|
||||
view_id = this.current_view.view_id;
|
||||
@@ -1487,7 +1490,7 @@
|
||||
}
|
||||
if (!(view_id in this.fields_view_tree)) {
|
||||
view_tree = this.model.execute('fields_view_get', [false, 'tree'],
|
||||
this.context(), false);
|
||||
this.context, false);
|
||||
this.fields_view_tree[view_id] = view_tree;
|
||||
} else {
|
||||
view_tree = this.fields_view_tree[view_id];
|
||||
@@ -1566,8 +1569,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
domain_parser = new Sao.common.DomainParser(
|
||||
fields, this.context());
|
||||
domain_parser = new Sao.common.DomainParser(fields, this.context);
|
||||
this._domain_parser[view_id] = domain_parser;
|
||||
return domain_parser;
|
||||
},
|
||||
@@ -1666,12 +1668,12 @@
|
||||
this.group.written(ids);
|
||||
}
|
||||
if (this.group.parent) {
|
||||
this.group.parent.root_parent().reload();
|
||||
this.group.parent.root_parent.reload();
|
||||
}
|
||||
return this.display();
|
||||
},
|
||||
get_buttons: function() {
|
||||
var selected_records = this.current_view.selected_records();
|
||||
var selected_records = this.current_view.selected_records;
|
||||
if (jQuery.isEmptyObject(selected_records)) {
|
||||
return [];
|
||||
}
|
||||
@@ -1700,12 +1702,12 @@
|
||||
model: this.model_name,
|
||||
id: this.current_record.id,
|
||||
ids: ids
|
||||
}, null, this.context(), true);
|
||||
}, null, this.context, true);
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
var selected_records = this.current_view.selected_records();
|
||||
var selected_records = this.current_view.selected_records;
|
||||
this.current_view.set_value();
|
||||
var fields = this.current_view.get_fields();
|
||||
|
||||
@@ -1747,16 +1749,16 @@
|
||||
var args = record.expr_eval(attributes.change || []);
|
||||
var values = record._get_on_change_args(args);
|
||||
return record.model.execute(attributes.name, [values],
|
||||
this.context()).then(function(changes) {
|
||||
this.context).then(function(changes) {
|
||||
record.set_on_change(changes);
|
||||
record.group.root_group().screens.forEach(
|
||||
record.group.root_group.screens.forEach(
|
||||
function(screen) {
|
||||
screen.display();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return record.save(false).then(function() {
|
||||
var context = this.context();
|
||||
var context = this.context;
|
||||
context._timestamp = {};
|
||||
ids = [];
|
||||
for (i = 0; i < selected_records.length; i++) {
|
||||
@@ -1836,7 +1838,7 @@
|
||||
function(v) {return v.view_id;}).concat(this.view_ids);
|
||||
if (this.current_view.view_type != 'form') {
|
||||
var search_string = this.screen_container.get_text();
|
||||
var search_value = this.domain_parser().parse(search_string);
|
||||
var search_value = this.domain_parser.parse(search_string);
|
||||
if (!jQuery.isEmptyObject(search_value)) {
|
||||
query_string.push(['search_value', dumps(search_value)]);
|
||||
}
|
||||
@@ -1980,7 +1982,7 @@
|
||||
}
|
||||
}
|
||||
if (record && (record != this.current_record)) {
|
||||
this.set_current_record(record);
|
||||
this.current_record = record;
|
||||
// Force a display of the view to synchronize the
|
||||
// widgets with the new record
|
||||
view.display();
|
||||
|
||||
+12
-12
@@ -524,7 +524,7 @@
|
||||
var screen = this.screen;
|
||||
var buttons = this.buttons;
|
||||
var prm = screen.model.execute('view_toolbar_get', [],
|
||||
screen.context());
|
||||
screen.context);
|
||||
prm.done(function(toolbars) {
|
||||
[
|
||||
['action', 'tryton-launch',
|
||||
@@ -637,7 +637,7 @@
|
||||
}).append(name))
|
||||
.click(function(evt) {
|
||||
evt.preventDefault();
|
||||
var ids = screen.current_view.selected_records()
|
||||
var ids = screen.current_view.selected_records
|
||||
.map(function(record) {
|
||||
return record.id;
|
||||
});
|
||||
@@ -675,7 +675,7 @@
|
||||
record_id = screen.current_record.id;
|
||||
}
|
||||
var record_ids = screen.current_view
|
||||
.selected_records().map(function(record) {
|
||||
.selected_records.map(function(record) {
|
||||
return record.id;
|
||||
});
|
||||
exec_action = Sao.Action.evaluate(exec_action,
|
||||
@@ -686,7 +686,7 @@
|
||||
ids: record_ids
|
||||
};
|
||||
Sao.Action.exec_action(exec_action, data,
|
||||
screen.context());
|
||||
screen.context);
|
||||
});
|
||||
}.bind(this))
|
||||
.appendTo(menu);
|
||||
@@ -797,7 +797,7 @@
|
||||
.then(function() {
|
||||
this.screen.group.forEach(function(record) {
|
||||
if (record.id == record_id) {
|
||||
this.screen.set_current_record(record);
|
||||
this.screen.current_record = record;
|
||||
set_cursor = true;
|
||||
}
|
||||
}.bind(this));
|
||||
@@ -903,7 +903,7 @@
|
||||
return this.screen.model.execute('read', [[record.id],
|
||||
fields.map(function(field) {
|
||||
return field[0];
|
||||
})], this.screen.context())
|
||||
})], this.screen.context)
|
||||
.then(function(result) {
|
||||
result = result[0];
|
||||
var message = '';
|
||||
@@ -939,7 +939,7 @@
|
||||
(revision < revisions[revisions.length - 1][0])) {
|
||||
revision = revisions[revisions.length - 1][0];
|
||||
}
|
||||
if (revision != this.screen.context()._datetime) {
|
||||
if (revision != this.screen.context._datetime) {
|
||||
this.screen.clear();
|
||||
// Update group context that will be propagated by
|
||||
// recreating new group
|
||||
@@ -957,19 +957,19 @@
|
||||
}.bind(this);
|
||||
}.bind(this);
|
||||
return this.modified_save().then(function() {
|
||||
var ids = this.screen.current_view.selected_records().map(
|
||||
var ids = this.screen.current_view.selected_records.map(
|
||||
function(record) {
|
||||
return record.id;
|
||||
});
|
||||
return this.screen.model.execute('history_revisions',
|
||||
[ids], this.screen.context())
|
||||
[ids], this.screen.context)
|
||||
.then(function(revisions) {
|
||||
new Sao.Window.Revision(revisions, set_revision(revisions));
|
||||
});
|
||||
}.bind(this));
|
||||
},
|
||||
update_revision: function() {
|
||||
var revision = this.screen.context()._datetime;
|
||||
var revision = this.screen.context._datetime;
|
||||
var label, title;
|
||||
if (revision) {
|
||||
var date_format = Sao.common.date_format();
|
||||
@@ -1273,11 +1273,11 @@
|
||||
export: function(){
|
||||
new Sao.Window.Export(
|
||||
this.title.text(), this.screen,
|
||||
this.screen.current_view.selected_records().map(function(r) {
|
||||
this.screen.current_view.selected_records.map(function(r) {
|
||||
return r.id;
|
||||
}),
|
||||
this.screen.current_view.get_fields(),
|
||||
this.screen.context());
|
||||
this.screen.context);
|
||||
},
|
||||
import: function(){
|
||||
new Sao.Window.Import(this.title.text(), this.screen);
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
get_fields: function() {
|
||||
return Object.keys(this.fields);
|
||||
},
|
||||
selected_records: function() {
|
||||
get selected_records() {
|
||||
return [];
|
||||
},
|
||||
get_buttons: function() {
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
// when loading
|
||||
if (!this.clicked_event) {
|
||||
this.clicked_event = true;
|
||||
this.screen.set_current_record(calEvent.record);
|
||||
this.screen.current_record = calEvent.record;
|
||||
this.screen.switch_view().always(function(){
|
||||
this.clicked_event = false;
|
||||
}.bind(this));
|
||||
@@ -253,7 +253,7 @@
|
||||
if (model_access.create) {
|
||||
// Set the calendar date to the clicked date
|
||||
this.el.fullCalendar('gotoDate', date);
|
||||
this.screen.set_current_record(null);
|
||||
this.screen.current_record = null;
|
||||
this.screen.new_();
|
||||
}
|
||||
},
|
||||
|
||||
+148
-148
@@ -411,7 +411,7 @@ function eval_pyson(value){
|
||||
button.el.prop('disabled', false);
|
||||
});
|
||||
},
|
||||
selected_records: function() {
|
||||
get selected_records() {
|
||||
if (this.screen.current_record) {
|
||||
return [this.screen.current_record];
|
||||
}
|
||||
@@ -1032,8 +1032,8 @@ function eval_pyson(value){
|
||||
this.labelled = null; // Element which received the labelledby
|
||||
},
|
||||
display: function() {
|
||||
var field = this.field();
|
||||
var record = this.record();
|
||||
var field = this.field;
|
||||
var record = this.record;
|
||||
var readonly = this.attributes.readonly;
|
||||
var invisible = this.attributes.invisible;
|
||||
var required = this.attributes.required;
|
||||
@@ -1089,7 +1089,7 @@ function eval_pyson(value){
|
||||
invalid_el.removeClass('has-error');
|
||||
}
|
||||
if (invisible === undefined) {
|
||||
invisible = field.get_state_attrs(this.record()).invisible;
|
||||
invisible = field.get_state_attrs(this.record).invisible;
|
||||
if (invisible === undefined) {
|
||||
invisible = false;
|
||||
}
|
||||
@@ -1102,19 +1102,19 @@ function eval_pyson(value){
|
||||
_invalid_el: function() {
|
||||
return this.el;
|
||||
},
|
||||
record: function() {
|
||||
get record() {
|
||||
if (this.view && this.view.screen) {
|
||||
return this.view.screen.current_record;
|
||||
}
|
||||
},
|
||||
field: function() {
|
||||
var record = this.record();
|
||||
get field() {
|
||||
var record = this.record;
|
||||
if (record) {
|
||||
return record.model.fields[this.field_name];
|
||||
}
|
||||
},
|
||||
focus_out: function() {
|
||||
if (!this.field()) {
|
||||
if (!this.field) {
|
||||
return;
|
||||
}
|
||||
if (!this.visible) {
|
||||
@@ -1183,7 +1183,7 @@ function eval_pyson(value){
|
||||
var context = {};
|
||||
context.language = lang.code;
|
||||
var params = [
|
||||
[widget.record().id],
|
||||
[widget.record.id],
|
||||
[widget.field_name],
|
||||
context
|
||||
];
|
||||
@@ -1214,7 +1214,7 @@ function eval_pyson(value){
|
||||
value = result[0][widget.field_name];
|
||||
}.bind(this));
|
||||
params = [
|
||||
[widget.record().id],
|
||||
[widget.record.id],
|
||||
[widget.field_name],
|
||||
context
|
||||
];
|
||||
@@ -1267,7 +1267,7 @@ function eval_pyson(value){
|
||||
var values = {};
|
||||
values[widget.field_name] = widget.translate_widget_get(input);
|
||||
var params = [
|
||||
[widget.record().id],
|
||||
[widget.record.id],
|
||||
values,
|
||||
context
|
||||
];
|
||||
@@ -1281,7 +1281,7 @@ function eval_pyson(value){
|
||||
}.bind(this));
|
||||
this.close(dialog);
|
||||
jQuery.when.apply(jQuery, promises).then(function() {
|
||||
widget.record().cancel();
|
||||
widget.record.cancel();
|
||||
widget.view.display();
|
||||
});
|
||||
}
|
||||
@@ -1307,7 +1307,7 @@ function eval_pyson(value){
|
||||
}
|
||||
};
|
||||
Sao.View.Form.TranslateMixin.translate = function() {
|
||||
if (this.record().id < 0 || this.record().has_changed()) {
|
||||
if (this.record.id < 0 || this.record.has_changed()) {
|
||||
var mg = Sao.i18n.gettext(
|
||||
'You need to save the record before adding translations.');
|
||||
Sao.common.message.run(mg);
|
||||
@@ -1389,8 +1389,8 @@ function eval_pyson(value){
|
||||
}
|
||||
},
|
||||
get_client_value: function() {
|
||||
var field = this.field();
|
||||
var record = this.record();
|
||||
var field = this.field;
|
||||
var record = this.record;
|
||||
var value = '';
|
||||
if (field) {
|
||||
value = field.get_client(record);
|
||||
@@ -1400,7 +1400,7 @@ function eval_pyson(value){
|
||||
display: function() {
|
||||
Sao.View.Form.Char._super.display.call(this);
|
||||
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
if (this.datalist) {
|
||||
this.datalist.children().remove();
|
||||
var set_autocompletion = function() {
|
||||
@@ -1436,7 +1436,7 @@ function eval_pyson(value){
|
||||
this.group.css('width', width);
|
||||
},
|
||||
set_value: function() {
|
||||
this.field().set_client(this.record(), this.input.val());
|
||||
this.field.set_client(this.record, this.input.val());
|
||||
},
|
||||
set_readonly: function(readonly) {
|
||||
this.input.prop('readonly', readonly);
|
||||
@@ -1556,7 +1556,7 @@ function eval_pyson(value){
|
||||
}.bind(this));
|
||||
},
|
||||
get_format: function() {
|
||||
return this.field().date_format(this.record());
|
||||
return this.field.date_format(this.record);
|
||||
},
|
||||
get_value: function() {
|
||||
var value = this.date.data('DateTimePicker').date();
|
||||
@@ -1566,8 +1566,8 @@ function eval_pyson(value){
|
||||
return value;
|
||||
},
|
||||
display: function() {
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
if (record && field) {
|
||||
this.date.data('DateTimePicker').format(
|
||||
Sao.common.moment_format(this.get_format()));
|
||||
@@ -1590,7 +1590,7 @@ function eval_pyson(value){
|
||||
this.input.focus();
|
||||
},
|
||||
set_value: function() {
|
||||
this.field().set_client(this.record(), this.get_value());
|
||||
this.field.set_client(this.record, this.get_value());
|
||||
},
|
||||
set_readonly: function(readonly) {
|
||||
this.date.find('button').prop('disabled', readonly);
|
||||
@@ -1602,8 +1602,8 @@ function eval_pyson(value){
|
||||
class_: 'form-datetime',
|
||||
_width: '20em',
|
||||
get_format: function() {
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
return field.date_format(record) + ' ' + field.time_format(record);
|
||||
},
|
||||
get_value: function() {
|
||||
@@ -1619,7 +1619,7 @@ function eval_pyson(value){
|
||||
class_: 'form-time',
|
||||
_width: '10em',
|
||||
get_format: function() {
|
||||
return this.field().time_format(this.record());
|
||||
return this.field.time_format(this.record);
|
||||
},
|
||||
get_value: function() {
|
||||
var value = this.date.data('DateTimePicker').date();
|
||||
@@ -1646,7 +1646,7 @@ function eval_pyson(value){
|
||||
},
|
||||
display: function() {
|
||||
Sao.View.Form.TimeDelta._super.display.call(this);
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
if (record) {
|
||||
var value = record.field_get_client(this.field_name);
|
||||
this.input.val(value || '');
|
||||
@@ -1658,7 +1658,7 @@ function eval_pyson(value){
|
||||
this.input.focus();
|
||||
},
|
||||
set_value: function() {
|
||||
this.field().set_client(this.record(), this.input.val());
|
||||
this.field.set_client(this.record, this.input.val());
|
||||
},
|
||||
set_readonly: function(readonly) {
|
||||
this.input.prop('readonly', readonly);
|
||||
@@ -1698,14 +1698,14 @@ function eval_pyson(value){
|
||||
this.factor = Number(attributes.factor || 1);
|
||||
},
|
||||
set_value: function() {
|
||||
this.field().set_client(
|
||||
this.record(), this.input.val(), undefined, this.factor);
|
||||
this.field.set_client(
|
||||
this.record, this.input.val(), undefined, this.factor);
|
||||
},
|
||||
get_client_value: function() {
|
||||
var value = '';
|
||||
var field = this.field();
|
||||
var field = this.field;
|
||||
if (field) {
|
||||
value = field.get(this.record());
|
||||
value = field.get(this.record);
|
||||
if (value !== null) {
|
||||
value *= this.factor;
|
||||
}
|
||||
@@ -1714,10 +1714,10 @@ function eval_pyson(value){
|
||||
},
|
||||
display: function() {
|
||||
Sao.View.Form.Integer._super.display.call(this);
|
||||
var field = this.field();
|
||||
var field = this.field;
|
||||
var value = '';
|
||||
if (field) {
|
||||
value = field.get_client(this.record(), this.factor);
|
||||
value = field.get_client(this.record, this.factor);
|
||||
}
|
||||
this.input_text.val(value);
|
||||
this.input_text.attr('maxlength', this.input.attr('maxlength'));
|
||||
@@ -1740,8 +1740,8 @@ function eval_pyson(value){
|
||||
Sao.View.Form.Float = Sao.class_(Sao.View.Form.Integer, {
|
||||
class_: 'form-float',
|
||||
display: function() {
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
var step = 'any';
|
||||
if (record) {
|
||||
var digits = field.digits(record, this.factor);
|
||||
@@ -1794,8 +1794,8 @@ function eval_pyson(value){
|
||||
});
|
||||
},
|
||||
display_update_selection: function() {
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
this.update_selection(record, field, function() {
|
||||
if (!field) {
|
||||
this.select.val('');
|
||||
@@ -1839,7 +1839,7 @@ function eval_pyson(value){
|
||||
},
|
||||
set_value: function() {
|
||||
var value = this.value_get();
|
||||
this.field().set_client(this.record(), value);
|
||||
this.field.set_client(this.record, value);
|
||||
},
|
||||
set_readonly: function(readonly) {
|
||||
this.select.prop('disabled', readonly);
|
||||
@@ -1867,7 +1867,7 @@ function eval_pyson(value){
|
||||
},
|
||||
display: function() {
|
||||
Sao.View.Form.Boolean._super.display.call(this);
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
if (record) {
|
||||
this.input.prop('checked', record.field_get(this.field_name));
|
||||
} else {
|
||||
@@ -1879,7 +1879,7 @@ function eval_pyson(value){
|
||||
},
|
||||
set_value: function() {
|
||||
var value = this.input.prop('checked');
|
||||
this.field().set_client(this.record(), value);
|
||||
this.field.set_client(this.record, value);
|
||||
},
|
||||
set_readonly: function(readonly) {
|
||||
this.input.prop('readonly', readonly);
|
||||
@@ -1915,7 +1915,7 @@ function eval_pyson(value){
|
||||
},
|
||||
display: function() {
|
||||
Sao.View.Form.Text._super.display.call(this);
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
if (record) {
|
||||
var value = record.field_get_client(this.field_name);
|
||||
this.input.val(value);
|
||||
@@ -1933,7 +1933,7 @@ function eval_pyson(value){
|
||||
},
|
||||
set_value: function() {
|
||||
var value = this.input.val() || '';
|
||||
this.field().set_client(this.record(), value);
|
||||
this.field.set_client(this.record, value);
|
||||
},
|
||||
set_readonly: function(readonly) {
|
||||
this.input.prop('readonly', readonly);
|
||||
@@ -2107,7 +2107,7 @@ function eval_pyson(value){
|
||||
display: function() {
|
||||
Sao.View.Form.RichText._super.display.call(this);
|
||||
var value = '';
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
if (record) {
|
||||
value = record.field_get_client(this.field_name);
|
||||
if(this.attributes.spell) {
|
||||
@@ -2125,13 +2125,13 @@ function eval_pyson(value){
|
||||
// avoid modification of not normalized value
|
||||
this._normalize(this.input);
|
||||
var value = this.input.html() || '';
|
||||
var previous = this.field().get_client(this.record());
|
||||
var previous = this.field.get_client(this.record);
|
||||
var previous_el = jQuery('<div/>').html(previous || '');
|
||||
this._normalize(previous_el);
|
||||
if (value == previous_el.html()) {
|
||||
value = previous;
|
||||
}
|
||||
this.field().set_client(this.record(), value);
|
||||
this.field.set_client(this.record, value);
|
||||
},
|
||||
_normalize: function(el) {
|
||||
// TODO order attributes
|
||||
@@ -2234,8 +2234,8 @@ function eval_pyson(value){
|
||||
this._readonly = false;
|
||||
},
|
||||
get_screen: function() {
|
||||
var domain = this.field().get_domain(this.record());
|
||||
var context = this.field().get_context(this.record());
|
||||
var domain = this.field.get_domain(this.record);
|
||||
var context = this.field.get_context(this.record);
|
||||
var view_ids = (this.attributes.view_ids || '').split(',');
|
||||
if (!jQuery.isEmptyObject(view_ids)) {
|
||||
// Remove the first tree view as mode is form only
|
||||
@@ -2257,7 +2257,7 @@ function eval_pyson(value){
|
||||
this.entry.val(value);
|
||||
},
|
||||
get_text: function() {
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
if (record) {
|
||||
return record.field_get_client(this.field_name);
|
||||
}
|
||||
@@ -2273,16 +2273,16 @@ function eval_pyson(value){
|
||||
Sao.View.Form.Many2One._super.focus_out.call(this);
|
||||
},
|
||||
set_value: function() {
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
if (field.get_client(record) != this.entry.val()) {
|
||||
field.set_client(record, this.value_from_id(null, ''));
|
||||
this.entry.val('');
|
||||
}
|
||||
},
|
||||
display: function() {
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
var text_value, value;
|
||||
Sao.View.Form.Many2One._super.display.call(this);
|
||||
|
||||
@@ -2344,7 +2344,7 @@ function eval_pyson(value){
|
||||
},
|
||||
_set_button_sensitive: function() {
|
||||
this.entry.prop('readonly', this._readonly);
|
||||
this.but_primary.prop('disabled', !this.read_access());
|
||||
this.but_primary.prop('disabled', !this.read_access);
|
||||
this.but_secondary.prop('disabled', this._readonly);
|
||||
},
|
||||
get_access: function(type) {
|
||||
@@ -2354,10 +2354,10 @@ function eval_pyson(value){
|
||||
}
|
||||
return true;
|
||||
},
|
||||
read_access: function() {
|
||||
get read_access() {
|
||||
return this.get_access('read');
|
||||
},
|
||||
create_access: function() {
|
||||
get create_access() {
|
||||
return this.attributes.create && this.get_access('create');
|
||||
},
|
||||
id_from_value: function(value) {
|
||||
@@ -2381,13 +2381,13 @@ function eval_pyson(value){
|
||||
return;
|
||||
}
|
||||
var win, callback;
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
var value = record.field_get(this.field_name);
|
||||
|
||||
if ((evt && evt.data == 'secondary') &&
|
||||
!this._readonly &&
|
||||
this.has_target(value)) {
|
||||
this.record().field_set_client(this.field_name,
|
||||
this.record.field_set_client(this.field_name,
|
||||
this.value_from_id(null, ''));
|
||||
this.entry.val('');
|
||||
return;
|
||||
@@ -2411,7 +2411,7 @@ function eval_pyson(value){
|
||||
rec_name_prm.done(function(name) {
|
||||
var value = this.value_from_id(
|
||||
screen.current_record.id, name);
|
||||
this.record().field_set_client(this.field_name,
|
||||
this.record.field_set_client(this.field_name,
|
||||
value, true);
|
||||
}.bind(this));
|
||||
}
|
||||
@@ -2427,15 +2427,15 @@ function eval_pyson(value){
|
||||
}
|
||||
if (model) {
|
||||
var dom;
|
||||
var domain = this.field().get_domain(record);
|
||||
var context = this.field().get_search_context(record);
|
||||
var order = this.field().get_search_order(record);
|
||||
var domain = this.field.get_domain(record);
|
||||
var context = this.field.get_search_context(record);
|
||||
var order = this.field.get_search_order(record);
|
||||
var text = this.entry.val();
|
||||
callback = function(result) {
|
||||
if (!jQuery.isEmptyObject(result)) {
|
||||
var value = this.value_from_id(result[0][0],
|
||||
result[0][1]);
|
||||
this.record().field_set_client(this.field_name,
|
||||
this.record.field_set_client(this.field_name,
|
||||
value, true);
|
||||
}
|
||||
};
|
||||
@@ -2449,7 +2449,7 @@ function eval_pyson(value){
|
||||
view_ids: (this.attributes.view_ids ||
|
||||
'').split(','),
|
||||
views_preload: (this.attributes.views || {}),
|
||||
new_: this.create_access(),
|
||||
new_: this.create_access,
|
||||
search_filter: parser.quote(text),
|
||||
title: this.attributes.string
|
||||
});
|
||||
@@ -2468,7 +2468,7 @@ function eval_pyson(value){
|
||||
rec_name_prm.done(function(name) {
|
||||
var value = this.value_from_id(
|
||||
screen.current_record.id, name);
|
||||
this.record().field_set_client(this.field_name, value);
|
||||
this.record.field_set_client(this.field_name, value);
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
@@ -2493,11 +2493,11 @@ function eval_pyson(value){
|
||||
|
||||
if (event_.which == Sao.common.F3_KEYCODE &&
|
||||
editable &&
|
||||
this.create_access()) {
|
||||
this.create_access) {
|
||||
this.new_();
|
||||
event_.preventDefault();
|
||||
} else if (event_.which == Sao.common.F2_KEYCODE &&
|
||||
this.read_access()) {
|
||||
this.read_access) {
|
||||
this.edit();
|
||||
event_.preventDefault();
|
||||
} else if (~activate_keys.indexOf(event_.which) && editable) {
|
||||
@@ -2508,13 +2508,13 @@ function eval_pyson(value){
|
||||
}
|
||||
}
|
||||
this.activate();
|
||||
} else if (this.has_target(this.record().field_get(
|
||||
} else if (this.has_target(this.record.field_get(
|
||||
this.field_name)) && editable) {
|
||||
var value = this.get_text();
|
||||
if ((value != this.entry.val()) ||
|
||||
~delete_keys.indexOf(event_.which)) {
|
||||
this.entry.val('');
|
||||
this.record().field_set_client(this.field_name,
|
||||
this.record.field_set_client(this.field_name,
|
||||
this.value_from_id(null, ''));
|
||||
}
|
||||
}
|
||||
@@ -2524,25 +2524,25 @@ function eval_pyson(value){
|
||||
if (!model || !Sao.common.MODELACCESS.get(model).read) {
|
||||
return;
|
||||
}
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
var value = record.field_get(this.field_name);
|
||||
var sao_model = new Sao.Model(model);
|
||||
|
||||
if (model && !this.has_target(value)) {
|
||||
var text = this.entry.val();
|
||||
if (!this._readonly && (text ||
|
||||
this.field().get_state_attrs(this.record())
|
||||
this.field.get_state_attrs(this.record)
|
||||
.required)) {
|
||||
var dom;
|
||||
var domain = this.field().get_domain(record);
|
||||
var context = this.field().get_search_context(record);
|
||||
var order = this.field().get_search_order(record);
|
||||
var domain = this.field.get_domain(record);
|
||||
var context = this.field.get_search_context(record);
|
||||
var order = this.field.get_search_order(record);
|
||||
|
||||
var callback = function(result) {
|
||||
if (!jQuery.isEmptyObject(result)) {
|
||||
var value = this.value_from_id(result[0][0],
|
||||
result[0][1]);
|
||||
this.record().field_set_client(this.field_name,
|
||||
this.record.field_set_client(this.field_name,
|
||||
value, true);
|
||||
} else {
|
||||
this.entry.val('');
|
||||
@@ -2559,7 +2559,7 @@ function eval_pyson(value){
|
||||
'').split(','),
|
||||
views_preload: (this.attributes.views ||
|
||||
{}),
|
||||
new_: this.create_access(),
|
||||
new_: this.create_access,
|
||||
search_filter: parser.quote(text),
|
||||
title: this.attributes.string
|
||||
});
|
||||
@@ -2568,24 +2568,24 @@ function eval_pyson(value){
|
||||
},
|
||||
_set_completion: function() {
|
||||
var search = this.el.find('.action-search');
|
||||
if (this.read_access()) {
|
||||
if (this.read_access) {
|
||||
search.removeClass('disabled');
|
||||
} else {
|
||||
search.addClass('disabled');
|
||||
}
|
||||
var create = this.el.find('.action-create');
|
||||
if (this.create_access()) {
|
||||
if (this.create_access) {
|
||||
create.removeClass('disabled');
|
||||
} else {
|
||||
create.addClass('disabled');
|
||||
}
|
||||
},
|
||||
_update_completion: function(text) {
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
if (!record) {
|
||||
return;
|
||||
}
|
||||
var field = this.field();
|
||||
var field = this.field;
|
||||
var value = field.get(record);
|
||||
if (this.has_target(value)) {
|
||||
var id = this.id_from_value(value);
|
||||
@@ -2599,7 +2599,7 @@ function eval_pyson(value){
|
||||
this.entry, record, field, model);
|
||||
},
|
||||
_completion_match_selected: function(value) {
|
||||
this.record().field_set_client(this.field_name,
|
||||
this.record.field_set_client(this.field_name,
|
||||
this.value_from_id(
|
||||
value.id, value.rec_name), true);
|
||||
},
|
||||
@@ -2666,7 +2666,7 @@ function eval_pyson(value){
|
||||
return [this.get_model(), [id, str]];
|
||||
},
|
||||
get_text: function() {
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
if (record) {
|
||||
return record.field_get_client(this.field_name)[1];
|
||||
}
|
||||
@@ -2704,12 +2704,12 @@ function eval_pyson(value){
|
||||
} else {
|
||||
value = ['', ''];
|
||||
}
|
||||
this.record().field_set_client(this.field_name, value);
|
||||
this.record.field_set_client(this.field_name, value);
|
||||
},
|
||||
set_value: function() {
|
||||
var value;
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
if (!this.get_model()) {
|
||||
value = this.entry.val();
|
||||
if (jQuery.isEmptyObject(value)) {
|
||||
@@ -2751,7 +2751,7 @@ function eval_pyson(value){
|
||||
}
|
||||
},
|
||||
display: function() {
|
||||
this.update_selection(this.record(), this.field(), function() {
|
||||
this.update_selection(this.record, this.field, function() {
|
||||
Sao.View.Form.Reference._super.display.call(this);
|
||||
}.bind(this));
|
||||
},
|
||||
@@ -2938,7 +2938,7 @@ function eval_pyson(value){
|
||||
|
||||
// TODO key_press
|
||||
|
||||
this.but_switch.prop('disabled', this.screen.number_of_views() <= 0);
|
||||
this.but_switch.prop('disabled', this.screen.number_of_views <= 0);
|
||||
},
|
||||
set_readonly: function(readonly) {
|
||||
this._readonly = readonly;
|
||||
@@ -2956,8 +2956,8 @@ function eval_pyson(value){
|
||||
_set_button_sensitive: function() {
|
||||
var access = Sao.common.MODELACCESS.get(this.screen.model_name);
|
||||
var size_limit, o2m_size;
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
if (record && field) {
|
||||
var field_size = record.expr_eval(this.attributes.size);
|
||||
o2m_size = field.get_eval(record).length;
|
||||
@@ -3001,12 +3001,12 @@ function eval_pyson(value){
|
||||
this._set_button_sensitive();
|
||||
|
||||
this.prm.done(function() {
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
|
||||
if (field === undefined) {
|
||||
this.screen.new_group();
|
||||
this.screen.set_current_record(null);
|
||||
this.screen.current_record = null;
|
||||
this.screen.group.parent = null;
|
||||
this.screen.display();
|
||||
return;
|
||||
@@ -3017,7 +3017,7 @@ function eval_pyson(value){
|
||||
this.screen.set_group(new_group);
|
||||
if ((this.screen.current_view.view_type == 'tree') &&
|
||||
this.screen.current_view.editable) {
|
||||
this.screen.set_current_record(null);
|
||||
this.screen.current_record = null;
|
||||
}
|
||||
}
|
||||
var domain = [];
|
||||
@@ -3055,11 +3055,11 @@ function eval_pyson(value){
|
||||
return;
|
||||
}
|
||||
this.view.set_value();
|
||||
var domain = this.field().get_domain(this.record());
|
||||
var context = this.field().get_search_context(this.record());
|
||||
var domain = this.field.get_domain(this.record);
|
||||
var context = this.field.get_search_context(this.record);
|
||||
domain = [domain,
|
||||
this.record().expr_eval(this.attributes.add_remove)];
|
||||
var removed_ids = this.field().get_removed_ids(this.record());
|
||||
this.record.expr_eval(this.attributes.add_remove)];
|
||||
var removed_ids = this.field.get_removed_ids(this.record);
|
||||
domain = ['OR', domain, ['id', 'in', removed_ids]];
|
||||
var text = this.wid_text.val();
|
||||
|
||||
@@ -3082,7 +3082,7 @@ function eval_pyson(value){
|
||||
this.wid_text.val('');
|
||||
}.bind(this);
|
||||
var parser = new Sao.common.DomainParser();
|
||||
var order = this.field().get_search_order(this.record());
|
||||
var order = this.field.get_search_order(this.record);
|
||||
var win = new Sao.Window.Search(this.attributes.relation,
|
||||
callback, {
|
||||
sel_multi: true,
|
||||
@@ -3118,17 +3118,17 @@ function eval_pyson(value){
|
||||
},
|
||||
new_single: function() {
|
||||
var context = jQuery.extend({},
|
||||
this.field().get_context(this.record()));
|
||||
this.field.get_context(this.record));
|
||||
// TODO sequence
|
||||
if (this.screen.current_view.type == 'form' ||
|
||||
this.screen.current_view.editable) {
|
||||
this.screen.new_();
|
||||
this.screen.current_view.el.prop('disabled', false);
|
||||
} else {
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
var field_size = record.expr_eval(
|
||||
this.attributes.size) || -1;
|
||||
field_size -= this.field().get_eval(record);
|
||||
field_size -= this.field.get_eval(record);
|
||||
var win = new Sao.Window.Form(this.screen, function() {}, {
|
||||
new_: true,
|
||||
many: field_size,
|
||||
@@ -3383,8 +3383,8 @@ function eval_pyson(value){
|
||||
},
|
||||
_set_button_sensitive: function() {
|
||||
var size_limit = false,
|
||||
record = this.record(),
|
||||
field = this.field();
|
||||
record = this.record,
|
||||
field = this.field;
|
||||
if (record && field) {
|
||||
var field_size = record.expr_eval(this.attributes.size);
|
||||
var m2m_size = field.get_eval(record).length;
|
||||
@@ -3406,12 +3406,12 @@ function eval_pyson(value){
|
||||
Sao.View.Form.Many2Many._super.display.call(this);
|
||||
|
||||
this.prm.done(function() {
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
|
||||
if (field === undefined) {
|
||||
this.screen.new_group();
|
||||
this.screen.set_current_record(null);
|
||||
this.screen.current_record = null;
|
||||
this.screen.group.parent = null;
|
||||
this.screen.display();
|
||||
return;
|
||||
@@ -3431,9 +3431,9 @@ function eval_pyson(value){
|
||||
},
|
||||
add: function() {
|
||||
var dom;
|
||||
var domain = this.field().get_domain(this.record());
|
||||
var context = this.field().get_search_context(this.record());
|
||||
var order = this.field().get_search_order(this.record());
|
||||
var domain = this.field.get_domain(this.record);
|
||||
var context = this.field.get_search_context(this.record);
|
||||
var order = this.field.get_search_order(this.record);
|
||||
var value = this.entry.val();
|
||||
|
||||
var callback = function(result) {
|
||||
@@ -3483,13 +3483,13 @@ function eval_pyson(value){
|
||||
}
|
||||
},
|
||||
_get_screen_form: function() {
|
||||
var domain = this.field().get_domain(this.record());
|
||||
var add_remove = this.record().expr_eval(
|
||||
var domain = this.field.get_domain(this.record);
|
||||
var add_remove = this.record.expr_eval(
|
||||
this.attributes.add_remove);
|
||||
if (!jQuery.isEmptyObject(add_remove)) {
|
||||
domain = [domain, add_remove];
|
||||
}
|
||||
var context = this.field().get_context(this.record());
|
||||
var context = this.field.get_context(this.record);
|
||||
var view_ids = (this.attributes.view_ids || '').split(',');
|
||||
if (!jQuery.isEmptyObject(view_ids)) {
|
||||
// Remove the first tree view as mode is form only
|
||||
@@ -3588,9 +3588,9 @@ function eval_pyson(value){
|
||||
|
||||
return group;
|
||||
},
|
||||
filename_field: function() {
|
||||
get filename_field() {
|
||||
if (this.filename) {
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
if (record) {
|
||||
return record.model.fields[this.filename];
|
||||
}
|
||||
@@ -3608,9 +3608,9 @@ function eval_pyson(value){
|
||||
}
|
||||
},
|
||||
select: function() {
|
||||
var record = this.record(),
|
||||
field = this.field(),
|
||||
filename_field = this.filename_field();
|
||||
var record = this.record,
|
||||
field = this.field,
|
||||
filename_field = this.filename_field;
|
||||
|
||||
Sao.common.get_input_data(this.input_select, function(data, filename) {
|
||||
field.set_client(record, data);
|
||||
@@ -3621,9 +3621,9 @@ function eval_pyson(value){
|
||||
},
|
||||
open: function() {
|
||||
var params = {};
|
||||
var filename_field = this.filename_field();
|
||||
var filename_field = this.filename_field;
|
||||
if (filename_field) {
|
||||
var filename = filename_field.get_client(this.record());
|
||||
var filename = filename_field.get_client(this.record);
|
||||
// Valid mimetype will make the browser directly open the file
|
||||
params.mimetype = Sao.common.guess_mimetype(filename);
|
||||
}
|
||||
@@ -3631,8 +3631,8 @@ function eval_pyson(value){
|
||||
},
|
||||
save_as: function(params) {
|
||||
var mimetype = params.mimetype || 'application/octet-binary';
|
||||
var field = this.field();
|
||||
var record = this.record();
|
||||
var field = this.field;
|
||||
var record = this.record;
|
||||
var prm;
|
||||
if (field.get_data) {
|
||||
prm = field.get_data(record);
|
||||
@@ -3641,19 +3641,19 @@ function eval_pyson(value){
|
||||
}
|
||||
prm.done(function(data) {
|
||||
var name;
|
||||
var field = this.filename_field();
|
||||
var field = this.filename_field;
|
||||
if (field) {
|
||||
name = field.get(this.record());
|
||||
name = field.get(this.record);
|
||||
}
|
||||
Sao.common.download_file(data, name);
|
||||
}.bind(this));
|
||||
},
|
||||
clear: function() {
|
||||
var filename_field = this.filename_field();
|
||||
var filename_field = this.filename_field;
|
||||
if (filename_field) {
|
||||
filename_field.set_client(this.record(), null);
|
||||
filename_field.set_client(this.record, null);
|
||||
}
|
||||
this.field().set_client(this.record(), null);
|
||||
this.field.set_client(this.record, null);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3703,7 +3703,7 @@ function eval_pyson(value){
|
||||
display: function() {
|
||||
Sao.View.Form.Binary._super.display.call(this);
|
||||
|
||||
var record = this.record(), field = this.field();
|
||||
var record = this.record, field = this.field;
|
||||
if (!field) {
|
||||
if (this.text) {
|
||||
this.text.val('');
|
||||
@@ -3721,7 +3721,7 @@ function eval_pyson(value){
|
||||
this.size.val(Sao.common.humanize(size));
|
||||
|
||||
if (this.text) {
|
||||
this.text.val(this.filename_field().get(record) || '');
|
||||
this.text.val(this.filename_field.get(record) || '');
|
||||
if (size) {
|
||||
this.but_open.parent().show();
|
||||
} else {
|
||||
@@ -3742,7 +3742,7 @@ function eval_pyson(value){
|
||||
},
|
||||
set_value: function() {
|
||||
if (this.text) {
|
||||
this.filename_field().set_client(this.record(),
|
||||
this.filename_field.set_client(this.record,
|
||||
this.text.val() || '');
|
||||
}
|
||||
},
|
||||
@@ -3796,7 +3796,7 @@ function eval_pyson(value){
|
||||
} else {
|
||||
value = [];
|
||||
}
|
||||
this.field().set_client(this.record(), value);
|
||||
this.field.set_client(this.record, value);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3835,7 +3835,7 @@ function eval_pyson(value){
|
||||
},
|
||||
update_img: function() {
|
||||
var value;
|
||||
var record = this.record();
|
||||
var record = this.record;
|
||||
if (record) {
|
||||
value = record.field_get_client(this.field_name);
|
||||
}
|
||||
@@ -3884,8 +3884,8 @@ function eval_pyson(value){
|
||||
display: function() {
|
||||
Sao.View.Form.URL._super.display.call(this);
|
||||
var url = '';
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
if (record) {
|
||||
url = record.field_get_client(this.field_name);
|
||||
}
|
||||
@@ -3964,8 +3964,8 @@ function eval_pyson(value){
|
||||
display: function() {
|
||||
Sao.View.Form.ProgressBar._super.display.call(this);
|
||||
var value, text;
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
if (!field) {
|
||||
value = 0;
|
||||
text = '';
|
||||
@@ -4051,9 +4051,9 @@ function eval_pyson(value){
|
||||
return this.wid_text;
|
||||
},
|
||||
add: function() {
|
||||
var context = this.field().get_context(this.record());
|
||||
var context = this.field.get_context(this.record);
|
||||
var value = this.wid_text.val();
|
||||
var domain = this.field().get_domain(this.record());
|
||||
var domain = this.field.get_domain(this.record);
|
||||
|
||||
var callback = function(result) {
|
||||
if (!jQuery.isEmptyObject(result)) {
|
||||
@@ -4077,8 +4077,8 @@ function eval_pyson(value){
|
||||
});
|
||||
},
|
||||
add_new_keys: function(ids) {
|
||||
var field = this.field();
|
||||
field.add_new_keys(ids, this.record())
|
||||
var field = this.field;
|
||||
field.add_new_keys(ids, this.record)
|
||||
.then(function(new_names) {
|
||||
var focus = false;
|
||||
new_names.forEach(function(name) {
|
||||
@@ -4100,11 +4100,11 @@ function eval_pyson(value){
|
||||
this.rows[key].remove();
|
||||
delete this.rows[key];
|
||||
if (modified) {
|
||||
this.set_value(this.record(), this.field());
|
||||
this.set_value(this.record, this.field);
|
||||
}
|
||||
},
|
||||
set_value: function() {
|
||||
this.field().set_client(this.record(), this.get_value());
|
||||
this.field.set_client(this.record, this.get_value());
|
||||
},
|
||||
get_value: function() {
|
||||
var value = {};
|
||||
@@ -4140,7 +4140,7 @@ function eval_pyson(value){
|
||||
},
|
||||
add_line: function(key) {
|
||||
var field, row;
|
||||
var key_schema = this.field().keys[key];
|
||||
var key_schema = this.field.keys[key];
|
||||
this.fields[key] = field = new (
|
||||
this.get_entries(key_schema.type_))(key, this);
|
||||
this.rows[key] = row = jQuery('<div/>', {
|
||||
@@ -4169,8 +4169,8 @@ function eval_pyson(value){
|
||||
display: function() {
|
||||
Sao.View.Form.Dict._super.display.call(this);
|
||||
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
if (!field) {
|
||||
return;
|
||||
}
|
||||
@@ -4260,7 +4260,7 @@ function eval_pyson(value){
|
||||
class_: 'dict-char',
|
||||
init: function(name, parent_widget) {
|
||||
this.name = name;
|
||||
this.definition = parent_widget.field().keys[name];
|
||||
this.definition = parent_widget.field.keys[name];
|
||||
this.parent_widget = parent_widget;
|
||||
this.create_widget();
|
||||
},
|
||||
@@ -4357,8 +4357,8 @@ function eval_pyson(value){
|
||||
Sao.View.Form.Dict.Float._super.create_widget.call(this);
|
||||
this.input_text = integer_input(this.input);
|
||||
},
|
||||
digits: function() {
|
||||
var record = this.parent_widget.record();
|
||||
get digits() {
|
||||
var record = this.parent_widget.record;
|
||||
if (record) {
|
||||
var digits = record.expr_eval(this.definition.digits);
|
||||
if (!digits || !digits.every(function(e) {
|
||||
@@ -4379,7 +4379,7 @@ function eval_pyson(value){
|
||||
set_value: function(value) {
|
||||
var step = 'any',
|
||||
options = {};
|
||||
var digits = this.digits();
|
||||
var digits = this.digits;
|
||||
if (digits) {
|
||||
step = Math.pow(10, -digits[1]);
|
||||
options.minimumFractionDigits = digits[1];
|
||||
@@ -4531,8 +4531,8 @@ function eval_pyson(value){
|
||||
set_value: function() {
|
||||
// avoid modification because different encoding
|
||||
var value = this.get_encoded_value();
|
||||
var record = this.record();
|
||||
var field = this.field();
|
||||
var record = this.record;
|
||||
var field = this.field;
|
||||
var previous = field.get_client(record);
|
||||
if (previous && Sao.common.compare(
|
||||
value, this.encoder.encode(this.decoder.decode(previous)))) {
|
||||
|
||||
+3
-3
@@ -195,7 +195,7 @@
|
||||
if ((type == 'date') || (type == 'datetime')) {
|
||||
var format_func, date_format, time_format;
|
||||
date_format = Sao.common.date_format(
|
||||
this.view.screen.context().date_format);
|
||||
this.view.screen.context.date_format);
|
||||
time_format = '%X';
|
||||
if (type == 'datetime') {
|
||||
format_func = function(dt) {
|
||||
@@ -292,7 +292,7 @@
|
||||
var type = this.xfield.type;
|
||||
if ((type == 'date') || (type == 'datetime')) {
|
||||
var date_format = Sao.common.date_format(
|
||||
this.view.screen.context().date_format);
|
||||
this.view.screen.context.date_format);
|
||||
var datetime_format = date_format + ' %X';
|
||||
if (type == 'datetime') {
|
||||
format_func = function(dt) {
|
||||
@@ -322,7 +322,7 @@
|
||||
var type = this.xfield.type;
|
||||
if ((type == 'date') || (type == 'datetime')) {
|
||||
var date_format = Sao.common.date_format(
|
||||
this.view.screen.context().date_format);
|
||||
this.view.screen.context.date_format);
|
||||
var datetime_format = date_format + ' %X';
|
||||
if (type == 'datetime') {
|
||||
key = Sao.common.format_datetime(datetime_format, key);
|
||||
|
||||
+8
-8
@@ -415,7 +415,7 @@
|
||||
}
|
||||
var inversion = new Sao.common.DomainInversion();
|
||||
domain = inversion.simplify(domain);
|
||||
var decoder = new Sao.PYSON.Decoder(this.screen.context());
|
||||
var decoder = new Sao.PYSON.Decoder(this.screen.context);
|
||||
this.columns.forEach(function(column) {
|
||||
visible_columns += 1;
|
||||
var name = column.attributes.name;
|
||||
@@ -555,7 +555,7 @@
|
||||
record = this.edited_row.record;
|
||||
this.edited_row.set_selection(true);
|
||||
}
|
||||
this.screen.set_current_record(record);
|
||||
this.screen.current_record = record;
|
||||
// TODO update_children
|
||||
},
|
||||
update_sum: function() {
|
||||
@@ -564,7 +564,7 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
var selected_records = this.selected_records();
|
||||
var selected_records = this.selected_records;
|
||||
var aggregate = '-';
|
||||
var sum_label = this.sum_widgets[name][0];
|
||||
var sum_value = this.sum_widgets[name][1];
|
||||
@@ -634,7 +634,7 @@
|
||||
'title', sum_label.text() + ' ' + sum_value.text());
|
||||
}
|
||||
},
|
||||
selected_records: function() {
|
||||
get selected_records() {
|
||||
if (this.selection_mode == Sao.common.SELECTION_NONE) {
|
||||
return [];
|
||||
}
|
||||
@@ -674,7 +674,7 @@
|
||||
if (this.selection.prop('checked')) {
|
||||
return;
|
||||
}
|
||||
var selected_records = this.selected_records();
|
||||
var selected_records = this.selected_records;
|
||||
this.selection.prop('indeterminate', false);
|
||||
if (jQuery.isEmptyObject(selected_records)) {
|
||||
this.selection.prop('checked', false);
|
||||
@@ -1077,7 +1077,7 @@
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
if (this.record.deleted() || this.record.removed()) {
|
||||
if (this.record.deleted || this.record.removed) {
|
||||
this.el.css('text-decoration', 'line-through');
|
||||
} else {
|
||||
this.el.css('text-decoration', 'inherit');
|
||||
@@ -1090,7 +1090,7 @@
|
||||
this.collapse_children();
|
||||
} else {
|
||||
if (this.tree.n_children(this) > Sao.config.limit) {
|
||||
this.tree.screen.set_current_record(this.record);
|
||||
this.tree.screen.current_record = this.record;
|
||||
this.tree.screen.switch_view('form');
|
||||
} else {
|
||||
this.update_expander(true);
|
||||
@@ -1194,7 +1194,7 @@
|
||||
this.tree.select_changed(this.record);
|
||||
} else {
|
||||
this.tree.select_changed(
|
||||
this.tree.selected_records()[0] || null);
|
||||
this.tree.selected_records[0] || null);
|
||||
}
|
||||
this.tree.update_selection();
|
||||
},
|
||||
|
||||
+7
-7
@@ -72,7 +72,7 @@
|
||||
}.bind(this));
|
||||
|
||||
var readonly = (this.screen.attributes.readonly ||
|
||||
this.screen.group.get_readonly());
|
||||
this.screen.group.readonly);
|
||||
|
||||
this._initial_value = null;
|
||||
if (view_type == 'form') {
|
||||
@@ -242,7 +242,7 @@
|
||||
record_label: function(data) {
|
||||
var name = '_';
|
||||
var access = Sao.common.MODELACCESS.get(this.screen.model_name);
|
||||
var readonly = this.screen.group.get_readonly();
|
||||
var readonly = this.screen.group.readonly;
|
||||
if (data[0] >= 1) {
|
||||
name = data[0];
|
||||
if (this.domain) {
|
||||
@@ -319,7 +319,7 @@
|
||||
response: function(response_id) {
|
||||
var result;
|
||||
this.screen.current_view.set_value();
|
||||
var readonly = this.screen.group.get_readonly();
|
||||
var readonly = this.screen.group.readonly;
|
||||
if (~['RESPONSE_OK', 'RESPONSE_ACCEPT'].indexOf(response_id) &&
|
||||
!readonly &&
|
||||
this.screen.current_record) {
|
||||
@@ -460,7 +460,7 @@
|
||||
add_uri: function(uri) {
|
||||
var screen = this.screen;
|
||||
this.switch_prm.then(function() {
|
||||
screen.set_current_record(null);
|
||||
screen.current_record = null;
|
||||
screen.switch_view('form').then(function() {
|
||||
screen.new_().then(function(record) {
|
||||
record.field_set_client('link', uri);
|
||||
@@ -473,7 +473,7 @@
|
||||
add_text: function(text) {
|
||||
var screen = this.screen;
|
||||
this.switch_prm.then(function() {
|
||||
screen.set_current_record(null);
|
||||
screen.current_record = null;
|
||||
screen.switch_view('form').then(function() {
|
||||
screen.new_().then(function(record) {
|
||||
record.field_set_client('description', text);
|
||||
@@ -648,7 +648,7 @@
|
||||
var records;
|
||||
var value = [];
|
||||
if (response_id == 'RESPONSE_OK') {
|
||||
records = this.screen.current_view.selected_records();
|
||||
records = this.screen.current_view.selected_records;
|
||||
} else if (response_id == 'RESPONSE_APPLY') {
|
||||
this.screen.search_filter();
|
||||
return;
|
||||
@@ -722,7 +722,7 @@
|
||||
});
|
||||
// Reset readonly set automaticly by MODELACCESS
|
||||
this.screen.attributes.readonly = false;
|
||||
this.screen.group.set_readonly(false);
|
||||
this.screen.group.readonly = false;
|
||||
this.screen.group.skip_model_access = true;
|
||||
|
||||
var set_view = function(view) {
|
||||
|
||||
Reference in New Issue
Block a user