[IMP] Added new object to m2m popup.

bzr revid: nicolas.vanhoren@openerp.com-20110510103046-6hctgajnom4y3x91
This commit is contained in:
niv-openerp 2011-05-10 12:30:46 +02:00
parent a1149a97c6
commit 9dcb8cfe24
2 changed files with 52 additions and 2 deletions

View File

@ -1025,9 +1025,50 @@ openerp.base.form.Many2XSelectPopup = openerp.base.BaseWidget.extend({
self.view_list.do_search.call(
self, domains, contexts, groupbys);
});
return this.searchview.start();
this.searchview.on_loaded.add_last(function () {
var $buttons = self.searchview.$element.find(".oe_search-view-buttons");
$buttons.append(QWeb.render("Many2XSelectPopup.search.buttons"));
var $nbutton = $buttons.find(".oe_many2xselectpopup-search-new");
$nbutton.click(function() {
self.new_object();
});
var $cbutton = $buttons.find(".oe_many2xselectpopup-search-close");
$cbutton.click(function() {
self.stop();
});
});
this.searchview.start();
},
on_select_element: function(element_id) {
},
new_object: function() {
var self = this;
this.searchview.hide();
this.view_list.$element.hide();
this.dataset.index = null;
this.view_form = new openerp.base.FormView({}, this.session,
this.element_id + "_view_form", this.dataset, false);
this.view_form.start();
this.view_form.on_loaded.add_last(function() {
var $buttons = self.view_form.$element.find(".oe_form_buttons");
$buttons.html(QWeb.render("Many2XSelectPopup.form.buttons"));
var $nbutton = $buttons.find(".oe_many2xselectpopup-form-save");
$nbutton.click(function() {
self.view_form.do_save();
});
var $cbutton = $buttons.find(".oe_many2xselectpopup-form-close");
$cbutton.click(function() {
self.stop();
});
});
this.view_form.on_created.add_last(function(r, success) {
if (r.result) {
var id = arguments[0].result;
self.on_select_element(id);
}
});
this.view_form.do_show();
}
});

View File

@ -383,7 +383,7 @@
<h2 class="oe_view_title"><t t-esc="view.attrs['string']"/></h2>
<form>
<t t-call="SearchView.render_lines"/>
<div style="text-align:right;">
<div class="oe_search-view-buttons" style="text-align:right;">
<input type="submit" value="Search"/>
<input type="reset" value="Clear"/>
</div>
@ -576,6 +576,15 @@
<div t-att-id="element_id">
<div t-att-id="element_id + '_search'"></div>
<div t-att-id="element_id + '_view_list'"></div>
<div t-att-id="element_id + '_view_form'"></div>
</div>
</t>
<t t-name="Many2XSelectPopup.search.buttons">
<button type="button" class="oe_many2xselectpopup-search-new">New</button>
<button type="button" class="oe_many2xselectpopup-search-close">Close</button>
</t>
<t t-name="Many2XSelectPopup.form.buttons">
<button type="button" class="oe_many2xselectpopup-form-save">Save</button>
<button type="button" class="oe_many2xselectpopup-form-close">Close</button>
</t>
</templates>