summaryrefslogtreecommitdiff
path: root/addons/google_spreadsheet/static
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2015-03-10 08:44:41 +0100
committerGéry Debongnie <ged@odoo.com>2015-03-18 09:01:52 +0100
commit858e46e977de772c36d3073d0d61b2a3c5958117 (patch)
tree2fc1680684c77260e70c0bd38f1dc0c0b2139a18 /addons/google_spreadsheet/static
parent824dbe13ad7f415e4028c62d5c764a0fb1fed184 (diff)
[REF] update various small addons to the new module system
Diffstat (limited to 'addons/google_spreadsheet/static')
-rw-r--r--addons/google_spreadsheet/static/src/js/search.js102
1 files changed, 55 insertions, 47 deletions
diff --git a/addons/google_spreadsheet/static/src/js/search.js b/addons/google_spreadsheet/static/src/js/search.js
index 650eccdf619..fbdb669ad7b 100644
--- a/addons/google_spreadsheet/static/src/js/search.js
+++ b/addons/google_spreadsheet/static/src/js/search.js
@@ -1,50 +1,58 @@
-openerp.google_spreadsheet = function(instance) {
- var _t = instance.web._t,
- QWeb = instance.web.qweb;
+odoo.define('google_spreadsheet.google.spreadsheet', ['web.core', 'web.data', 'web.FavoriteMenu', 'web.FormView', 'web.pyeval'], function (require) {
+"use strict";
- instance.web.FormView.include({
- on_processed_onchange: function(result, processed) {
- var self = this;
- var fields = self.fields;
- _(result.selection).each(function (selection, fieldname) {
- var field = fields[fieldname];
- if (!field) { return; }
- field.field.selection = selection;
- field.values = selection;
- field.renderElement();
- });
- return this._super(result, processed);
- },
- });
- instance.web.search.FavoriteMenu.include({
- prepare_dropdown_menu: function (filters) {
- this._super(filters);
- this.$('.favorites-menu').append(QWeb.render('SearchView.addtogooglespreadsheet'));
- this.$('.add-to-spreadsheet').click(this.add_to_spreadsheet.bind(this));
- },
- add_to_spreadsheet: function () {
- var data = this.searchview.build_search_data(),
- model = this.searchview.dataset.model,
- view_manager = this.searchview.getParent(),
- list_view = view_manager.views.list,
- list_view_id = list_view ? list_view.view_id : false,
- context = this.searchview.dataset.get_context() || [],
- domain = this.searchview.dataset.get_domain() || [],
- compound_context = new instance.web.CompoundContext(context),
- compound_domain = new instance.web.CompoundDomain(context),
- groupbys = instance.web.pyeval.eval('groupbys', data.groupbys).join(" "),
- ds = new instance.web.DataSet(this, 'google.drive.config');
+var core = require('web.core');
+var data = require('web.data');
+var FavoriteMenu = require('web.FavoriteMenu');
+var FormView = require('web.FormView');
+var pyeval = require('web.pyeval');
+
+var QWeb = core.qweb;
+
+FormView.include({
+ on_processed_onchange: function(result, processed) {
+ var self = this;
+ var fields = self.fields;
+ _(result.selection).each(function (selection, fieldname) {
+ var field = fields[fieldname];
+ if (!field) { return; }
+ field.field.selection = selection;
+ field.values = selection;
+ field.renderElement();
+ });
+ return this._super(result, processed);
+ },
+});
- _.each(data.contexts, compound_context.add, compound_context);
- _.each(data.domains, compound_domain.add, compound_domain);
+FavoriteMenu.include({
+ prepare_dropdown_menu: function (filters) {
+ this._super(filters);
+ this.$('.favorites-menu').append(QWeb.render('SearchView.addtogooglespreadsheet'));
+ this.$('.add-to-spreadsheet').click(this.add_to_spreadsheet.bind(this));
+ },
+ add_to_spreadsheet: function () {
+ var sv_data = this.searchview.build_search_data(),
+ model = this.searchview.dataset.model,
+ view_manager = this.searchview.getParent(),
+ list_view = view_manager.views.list,
+ list_view_id = list_view ? list_view.view_id : false,
+ context = this.searchview.dataset.get_context() || [],
+ compound_context = new data.CompoundContext(context),
+ compound_domain = new data.CompoundDomain(context),
+ groupbys = pyeval.eval('groupbys', sv_data.groupbys).join(" "),
+ ds = new data.DataSet(this, 'google.drive.config');
+
+ _.each(sv_data.contexts, compound_context.add, compound_context);
+ _.each(sv_data.domains, compound_domain.add, compound_domain);
+
+ compound_domain = JSON.stringify(compound_domain.eval());
+ ds.call('set_spreadsheet', [model, compound_domain, groupbys, list_view_id])
+ .done(function (res) {
+ if (res.url){
+ window.open(res.url, '_blank');
+ }
+ });
+ },
+});
- compound_domain = JSON.stringify(compound_domain.eval());
- ds.call('set_spreadsheet', [model, compound_domain, groupbys, list_view_id])
- .done(function (res) {
- if (res['url']){
- window.open(res['url'], '_blank');
- }
- });
- },
- });
-}; \ No newline at end of file
+});