summaryrefslogtreecommitdiff
path: root/addons/base/static/src
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2011-05-10 12:30:46 +0200
committerniv-openerp <nicolas.vanhoren@openerp.com>2011-05-10 12:30:46 +0200
commit9dcb8cfe246fb67eab8ec4db5604befc5261c5be (patch)
tree32c5557707726761340b0d5d4ca7339ce34d2c9a /addons/base/static/src
parenta1149a97c6250aca4dfb54a0cf7817f422d5fdae (diff)
[IMP] Added new object to m2m popup.
bzr revid: nicolas.vanhoren@openerp.com-20110510103046-6hctgajnom4y3x91
Diffstat (limited to 'addons/base/static/src')
-rw-r--r--addons/base/static/src/js/form.js43
-rw-r--r--addons/base/static/src/xml/base.xml11
2 files changed, 52 insertions, 2 deletions
diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js
index 37a5683360a..934d8fabe10 100644
--- a/addons/base/static/src/js/form.js
+++ b/addons/base/static/src/js/form.js
@@ -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();
}
});
diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml
index d6c4d3edbb1..9e1646ace08 100644
--- a/addons/base/static/src/xml/base.xml
+++ b/addons/base/static/src/xml/base.xml
@@ -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>