},
init_dataset: function() {
var self = this;
+ this.created_elements = [];
this.dataset = new instance.web.ProxyDataSet(this, this.model, this.context);
this.dataset.read_function = this.options.read_function;
this.dataset.create_function = function(data, sup) {
this.dataset.child_name = this.options.child_name;
},
display_popup: function() {
+ var self = this;
this.renderElement();
instance.web.form.dialog(this.$element, {
close: function() {
on_write_completed: function() {},
setup_form_view: function() {
var self = this;
+ if (this.row_id) {
+ this.dataset.ids = [this.row_id];
+ this.dataset.index = 0;
+ } else {
+ this.dataset.index = null;
+ }
var options = _.clone(self.options.form_view_options) || {};
if (this.row_id !== null) {
options.initial_mode = this.options.readonly ? "view" : "edit";
self.view_form.do_show();
});
},
+ on_select_elements: function(element_ids) {
+ },
check_exit: function() {
+ if (this.created_elements.length > 0) {
+ this.on_select_elements(this.created_elements);
+ }
this.destroy();
},
+ destroy: function () {
+ this.$element.dialog('close');
+ this._super();
+ },
});
/**
var self = this;
_.defaults(this.options, {
initial_view: "search",
- create_function: function() {
- return self.create_row.apply(self, arguments);
- },
- read_function: null,
});
this.initial_ids = this.options.initial_ids;
- this.created_elements = [];
this.display_popup();
},
start: function() {
this.new_object();
}
},
- stop: function () {
- this.$element.dialog('close');
- this._super();
- },
setup_search_view: function(search_defaults) {
var self = this;
if (this.searchview) {
self.view_list.do_search(results.domain, results.context, results.group_by);
});
},
- create_row: function() {
- var self = this;
- var wdataset = new instance.web.DataSetSearch(this, this.model, this.context, this.domain);
- wdataset.parent_view = this.options.parent_view;
- wdataset.child_name = this.options.child_name;
- return wdataset.create.apply(wdataset, arguments);
- },
- on_select_elements: function(element_ids) {
- },
on_click_element: function(ids) {
this.selected_ids = ids || [];
if(this.selected_ids.length > 0) {
if (this.view_list) {
this.view_list.$element.hide();
}
- this.dataset.index = null;
this.setup_form_view();
},
- check_exit: function() {
- if (this.created_elements.length > 0) {
- this.on_select_elements(this.created_elements);
- }
- this._super();
- },
});
instance.web.form.SelectCreateListView = instance.web.ListView.extend({
start: function() {
this._super();
this.init_dataset();
- this.dataset.ids = [this.row_id];
- this.dataset.index = 0;
this.setup_form_view();
},
});