Example #1
0
 getLanguages: function () {
     var self = this;
     this._rpc({
         model: 'website',
         method: 'get_languages',
         args: [[weContext.get().website_id]],
         context: weContext.get(),
     }).then( function (data) {
         self.$('#language-box').html(core.qweb.render('Configurator.language_promote', {
             'language': data,
             'def_lang': weContext.get().lang
         }));
     });
 },
Example #2
0
                dialog.on('service_level', this, function () {
                    var gengo_service_level = dialog.$el.find(".form-control").val();
                    dialog.$el.modal('hide');
                    self.$el.find('.gengo_post').addClass("hidden");
                    self.$el.find('.gengo_wait').removeClass("hidden");
                    var trans = [];
                    $('[data-oe-translation-state="to_translate"], [data-oe-translation-state="None"]').each(function () {
                        var $node = $(this);
                        var data = $node.data();

                        var val = ($node.is('img')) ? $node.attr('alt') : $node.text();
                        trans.push({
                            initial_content: qweb.tools.html_escape(val),
                            translation_id: data.oeTranslationId || null,
                            gengo_translation: gengo_service_level,
                            gengo_comment:"\nOriginal Page: " + document.URL
                        });
                    });
                    ajax.jsonRpc('/website_gengo/set_translations', 'call', {
                        'data': trans,
                        'lang': weContext.get().lang,
                    }).then(function () {
                        ajax.jsonRpc('/website/post_gengo_jobs', 'call', {});
                        self.save_and_reload();
                    }).fail(function () {
                        Dialog.alert(null, _t("Could not Post translation"));
                    });
                });
    willStart: function () {
        var self = this;

        var uri = this._getUri("/product_configurator/show_optional_products");
        var getModalContent = ajax.jsonRpc(uri, 'call', {
            product_id: self.rootProduct.product_id,
            variant_values: self.rootProduct.variant_values,
            pricelist_id: self.pricelistId,
            kwargs: {
                context: _.extend({
                    'quantity': self.rootProduct.quantity
                }, weContext.get()),
            }
        })
        .then(function (modalContent) {
            if (modalContent){
                var $modalContent = $(modalContent);
                $modalContent = self._postProcessContent($modalContent);
                self.$content = $modalContent;
            } else {
                self.trigger('options_empty');
                self.preventOpening = true;
            }
        });

        var parentInit = self._super.apply(self, arguments);
        return $.when(getModalContent, parentInit);
    },
Example #4
0
 loadMetaData: function () {
     var obj = this.getMainObject();
     var def = $.Deferred();
     if (!obj) {
         // return $.Deferred().reject(new Error("No main_object was found."));
         def.resolve(null);
     } else {
         var fields = ['website_meta_title', 'website_meta_description', 'website_meta_keywords'];
         if (obj.model == 'website.page'){
             fields.push('website_indexed');
         }
         rpc.query({
             model: obj.model,
             method: 'read',
             args: [[obj.id], fields, weContext.get()],
         }).then(function (data) {
             if (data.length) {
                 var meta = data[0];
                 meta.model = obj.model;
                 def.resolve(meta);
             } else {
                 def.resolve(null);
             }
         }).fail(function () {
             def.reject();
         });
     }
     return def;
 },
Example #5
0
 save: function () {
     var _super = this._super.bind(this);
     var self = this;
     var new_menu = this.$('.oe_menu_editor').nestedSortable('toArray', {startDepthCount: 0});
     var levels = [];
     var data = [];
     var context = weContext.get();
     // Resequence, re-tree and remove useless data
     new_menu.forEach(function (menu) {
         if (menu.id) {
             levels[menu.depth] = (levels[menu.depth] || 0) + 1;
             var mobj = self.flat[menu.id];
             mobj.sequence = levels[menu.depth];
             mobj.parent_id = (menu.parent_id|0) || menu.parent_id || self.root_menu_id;
             delete(mobj.children);
             data.push(mobj);
         }
     });
     this._rpc({
         model: 'website.menu',
         method: 'save',
         args: [context.website_id, { data: data, to_delete: self.to_delete }],
         context: context,
     }).then(function () {
         return _super();
     });
 },
Example #6
0
    _findExisting: function (name) {
        var self = this;
        var domain = [];
        if (!name || !name.length) {
            self.$search.siblings().remove();
            return;
        }
        if (isNaN(+name)) {
            if (this.Model !== 'res.partner') {
                domain.push(['name', 'ilike', name]);
            } else {
                domain.push('|', ['name', 'ilike', name], ['email', 'ilike', name]);
            }
        } else {
            domain.push(['id', '=', name]);
        }

        return this._rpc({
            model: this.Model,
            method: 'search_read',
            args: [domain, this.Model === 'res.partner' ? ['name', 'display_name', 'city', 'country_id'] : ['name', 'display_name']],
            kwargs: {
                order: [{name: 'name', asc: false}],
                limit: 5,
                context: weContext.get(),
            },
        }).then(function (result) {
            self.$search.siblings().remove();
            self.$search.after(qweb.render('web_editor.many2one.search',{contacts:result}));
        });
    },
Example #7
0
    _onDeletePageButtonClick: function (ev) {
        var pageId = $(ev.currentTarget).data('id');
        var self = this;
        var context = weContext.get();

        var def = $.Deferred();
        // Search the page dependencies
        this._getPageDependencies(pageId, context)
        .then(function (dependencies) {
        // Inform the user about those dependencies and ask him confirmation
            var confirmDef = $.Deferred();
            Dialog.safeConfirm(self, "", {
                title: _t("Delete Page"),
                $content: $(qweb.render('website.delete_page', {dependencies: dependencies})),
                confirm_callback: confirmDef.resolve.bind(confirmDef),
                cancel_callback: def.resolve.bind(self),
            });
            return confirmDef;
        }).then(function () {
        // Delete the page if the user confirmed
            return self._rpc({
                model: 'website.page',
                method: 'delete_page',
                args: [pageId],
                context: context,
            });
        }).then(function () {
            window.location.reload(true);
        }, def.reject.bind(def));
    },
Example #8
0
/**
 * Deletes the page after showing a dependencies warning for the given page id.
 *
 * @private
 * @param {integer} pageId - The ID of the page to be deleted
 * @param {Boolean} fromPageManagement
 *                  Is the function called by the page manager?
 *                  It will affect redirect after page deletion: reload or '/'
 */
// TODO: This function should be integrated in a widget in the future
function _deletePage(pageId, fromPageManagement) {
    var self = this;
    var context = weContext.get();
    var def = $.Deferred();

    // Search the page dependencies
    this._getPageDependencies(pageId, context)
    .then(function (dependencies) {
    // Inform the user about those dependencies and ask him confirmation
        var confirmDef = $.Deferred();
        Dialog.safeConfirm(self, "", {
            title: _t("Delete Page"),
            $content: $(qweb.render('website.delete_page', {dependencies: dependencies})),
            confirm_callback: confirmDef.resolve.bind(confirmDef),
            cancel_callback: def.resolve.bind(self),
        });
        return confirmDef;
    }).then(function () {
    // Delete the page if the user confirmed
        return self._rpc({
            model: 'website.page',
            method: 'unlink',
            args: [pageId],
            context: context,
        });
    }).then(function () {
        if (fromPageManagement) {
            window.location.reload(true);
        }
        else {
            window.location.href = '/';
        }
    }, def.reject.bind(def));
}
Example #9
0
File: rte.js Project: yvaucher/odoo
 return self.saving_mutex.exec(function () {
     return self._saveElement($el, context || weContext.get())
     .then(function () {
         $el.removeClass('o_dirty');
     }, function (response) {
         // because ckeditor regenerates all the dom, we can't just
         // setup the popover here as everything will be destroyed by
         // the DOM regeneration. Add markings instead, and returns a
         // new rejection with all relevant info
         var id = _.uniqueId('carlos_danger_');
         $el.addClass('o_dirty oe_carlos_danger ' + id);
         var html = (response.data.exception_type === 'except_osv');
         if (html) {
             var msg = $('<div/>', {text: response.data.message}).html();
             var data = msg.substring(3, msg.length  -2).split(/', u'/);
             response.data.message = '<b>' + data[0] + '</b>' + data[1];
         }
         $('.o_editable.' + id)
             .removeClass(id)
             .popover({
                 html: html,
                 trigger: 'hover',
                 content: response.data.message,
                 placement: 'auto top',
             })
             .popover('show');
     });
 });
 'init': function (field) {
     return rpc.query({
             model: 'mail.mass_mailing.list',
             method: 'name_search',
             args: ['', []],
             context: weContext.get(), // TODO use this._rpc
         });
 },
 init: function (field) {
     return rpc.query({
             model: 'mail.channel',
             method: 'name_search',
             args: ['', [['public','=','public']]],
             context: weContext.get(), // TODO use this._rpc
         });
 },
Example #12
0
 $('#tag_ids').select2(this.select2_wrapper(_t('Tags'), true, function () {
     return ajax.jsonRpc("/web/dataset/call_kw", 'call', {
         model: 'slide.tag',
         method: 'search_read',
         args: [],
         kwargs: {
             fields: ['name'],
             context: weContext.get()
         }
     });
 }));
Example #13
0
 _doCustomize: function (viewID) {
     return this._rpc({
         model: 'ir.ui.view',
         method: 'toggle',
         args: [[viewID]],
         context: weContext.get(),
     }).then(function () {
         window.location.reload();
         return $.Deferred();
     });
 },
Example #14
0
File: theme.js Project: 10537/odoo
 willStart: function () {
     if (templateDef === null) {
         templateDef = this._rpc({
             model: 'ir.ui.view',
             method: 'read_template',
             args: ['website.theme_customize', weContext.get()],
         }).then(function (data) {
             return QWeb.add_template(data);
         });
     }
     return $.when(this._super.apply(this, arguments), templateDef);
 },
Example #15
0
 saveMetaData: function (data) {
     var obj = this.getMainObject();
     if (!obj) {
         return $.Deferred().reject();
     } else {
         return rpc.query({
             model: obj.model,
             method: 'write',
             args: [[obj.id], data, weContext.get()],
         });
     }
 },
Example #16
0
 function () {
     return ajax.jsonRpc("/web/dataset/call_kw", 'call', {
         model: 'slide.category',
         method: 'search_read',
         args: [],
         kwargs: {
             fields: ['name'],
             domain: [['channel_id', '=', self.channel_id]],
             context: weContext.get()
         }
     });
 }));
Example #17
0
 translation_gengo_info: function () {
     var translated_ids = [];
     $('[data-oe-translation-state="translated"]').each(function () {
         translated_ids.push($(this).attr('data-oe-translation-id'));
     });
     ajax.jsonRpc('/website/get_translated_length', 'call', {
         'translated_ids': translated_ids,
         'lang': weContext.get().lang,
     }).done(function (res){
         var dialog = new GengoTranslatorStatisticDialog(res);
         dialog.appendTo($(document.body));
     });
 },
Example #18
0
 _onClonePageButtonClick: function (ev) {
     var pageId = $(ev.currentTarget).data('id');
     var context = weContext.get();
     this._rpc({
         model: 'website.page',
         method: 'clone_page',
         args: [pageId],
         kwargs: {
             context: context,
         },
     }).then(function (path) {
         window.location.href = path;
     });
 },
Example #19
0
 refresh: function () {
     var self = this;
     self.$el.append(_t("Loading..."));
     var language = self.language || weContext.get().lang.toLowerCase();
     this._rpc({
         route: '/website/seo_suggest',
         params: {
             keywords: self.root,
             lang: language,
         },
     }).then(function (keyword_list) {
         self.addSuggestions(JSON.parse(keyword_list));
     });
 },
Example #20
0
    start: function () {
        var def = this._super.apply(this, arguments);

        var gengo_langs = ["ar_SY","id_ID","nl_NL","fr_CA","pl_PL","zh_TW","sv_SE","ko_KR","pt_PT","en_US","ja_JP","es_ES","zh_CN","de_DE","fr_FR","fr_BE","ru_RU","it_IT","pt_BR","pt_BR","th_TH","nb_NO","ro_RO","tr_TR","bg_BG","da_DK","en_GB","el_GR","vi_VN","he_IL","hu_HU","fi_FI"];
        if (gengo_langs.indexOf(weContext.get().lang) >= 0) {
            this.$('.gengo_post,.gengo_wait,.gengo_inprogress,.gengo_info').remove();
            this.$('button[data-action=save]')
                .after(qweb.render('website.ButtonGengoTranslator'));
        }

        this.translation_gengo_display();

        return def;
    },
Example #21
0
 _saveElement: function ($el, context, withLang) {
     if ($el.data('oe-translation-id')) {
         return this._rpc({
             model: 'ir.translation',
             method: 'save_html',
             args: [
                 [+$el.data('oe-translation-id')],
                 this._getEscapedElement($el).html(),
                 context || weContext.get()
             ],
         });
     }
     return this._super($el, context, withLang === undefined ? true : withLang);
 },
Example #22
0
    save: function (data) {
        var self = this;
        var context = weContext.get();
        var url = this.$('#page_url').val();

        var $date_publish = this.$("#date_publish");
        $date_publish.closest(".form-group").removeClass('o_has_error').find('.form-control, .custom-select').removeClass('is-invalid');
        var date_publish = $date_publish.val();
        if (date_publish !== "") {
            date_publish = this._parse_date(date_publish);
            if (!date_publish) {
                $date_publish.closest(".form-group").addClass('o_has_error').find('.form-control, .custom-select').addClass('is-invalid');
                return;
            }
        }
        var params = {
            id: this.page.id,
            name: this.$('#page_name').val(),
            // Replace duplicate following '/' by only one '/'
            url: url.replace(/\/{2,}/g, '/'),
            is_menu: this.$('#is_menu').prop('checked'),
            is_homepage: this.$('#is_homepage').prop('checked'),
            website_published: this.$('#is_published').prop('checked'),
            create_redirect: this.$('#create_redirect').prop('checked'),
            redirect_type: this.$('#redirect_type').val(),
            website_indexed: this.$('#is_indexed').prop('checked'),
            date_publish: date_publish,
        };
        this._rpc({
            model: 'website.page',
            method: 'save_page_info',
            args: [[context.website_id], params],
            context: context,
        }).then(function (url) {
            // If from page manager: reload url, if from page itself: go to
            // (possibly) new url
            var mo;
            self.trigger_up('main_object_request', {
                callback: function (value) {
                    mo = value;
                },
            });
            if (mo.model === 'website.page') {
                window.location.href = url.toLowerCase();
            } else {
                window.location.reload(true);
            }
        });
    },
Example #23
0
 .each(function () {
     var $node = $(this);
     var options = $node.data('oe-contact-options');
     self._rpc({
         model: 'ir.qweb.field.contact',
         method: 'get_record_to_html',
         args: [[self.ID]],
         kwargs: {
             options: options,
             context: weContext.get(),
         },
     }).then(function (html) {
         $node.html(html);
     });
 });
Example #24
0
 source: function (request, response) {
     return self._rpc({
         model: 'website',
         method: 'search_pages',
         args: [null, request.term],
         kwargs: {
             limit: 15,
             context: weContext.get(),
         },
     }).then(function (exists) {
         var rs = _.map(exists, function (r) {
             return r.loc;
         });
         response(rs);
     });
 },
Example #25
0
 willStart: function () {
     var defs = [this._super.apply(this, arguments)];
     var self = this;
     var context = weContext.get();
     defs.push(this._rpc({
         model: 'website.menu',
         method: 'get_tree',
         args: [context.website_id, this.rootID],
     }).then(function (menu) {
         self.menu = menu;
         self.root_menu_id = menu.id;
         self.flat = self._flatenize(menu);
         self.to_delete = [];
     }));
     return $.when.apply($, defs);
 },
Example #26
0
File: iframe.js Project: 10537/odoo
    start: function () {
        var defs = [this._super.apply(this, arguments)];

        var ctx = weContext.getExtra();

        if (ctx.editable && window.location.search.indexOf('enable_editor') >= 0) {
            var editorInstance = new (editor.Class)(this);
            defs.push(editorInstance.prependTo(this.$el));
        }

        if (ctx.edit_translations) {
            var translator = new (translate.Class)(this, this.$('#wrapwrap'));
            defs.push(translator.prependTo(this.$el));
        }

        return $.when.apply($, defs);
    },
Example #27
0
 fetch_existing: function (needle) {
     var domain = [['res_model', '=', 'ir.ui.view']].concat(this.domain);
     if (needle && needle.length) {
         domain.push('|', ['datas_fname', 'ilike', needle], ['name', 'ilike', needle]);
     }
     return this._rpc({
         model: 'ir.attachment',
         method: 'search_read',
         args: [],
         kwargs: {
             domain: domain,
             fields: ['name', 'mimetype', 'checksum', 'url', 'type'],
             order: [{name: 'id', asc: false}],
             context: weContext.get(),
         }
     }).then(this.proxy('fetched_existing'));
 },
        new_help_page: function() {

             rpc.query({
			    model: 'website.support.help.groups',
				method: 'name_search',
				args: [],
				context: weContext.get()
		     }).then(function(action_ids){
                 wUtils.prompt({
                     id: "editor_new_help_page",
                     window_title: _t("New Help Page"),
                     select: "Select Help Group",
                     init: function (field) {
                         return action_ids;
                     },
                 }).then(function (cat_id) {
                     document.location = '/helppage/new?group_id=' + cat_id;
                 });
            });
        },
Example #29
0
    _onModalSubmit: function (goToShop){
        var customValues = JSON.stringify(
            this.optionalProductsModal.getSelectedProducts()
        );

        this.$form.ajaxSubmit({
            url:  '/shop/cart/update_option',
            data: {
                lang: weContext.get().lang,
                custom_values: customValues
            },
            success: function (quantity) {
                if (goToShop) {
                    var path = window.location.pathname.replace(/shop([\/?].*)?$/, "shop/cart");
                    window.location.pathname = path;
                }
                var $quantity = $(".my_cart_quantity");
                $quantity.parent().parent().removeClass("d-none", !quantity);
                $quantity.html(quantity).hide().fadeIn(600);
            }
        });
    },
Example #30
0
    save: function (data) {
        var self = this;
        var context = weContext.get();
        var url = this.$('#page_url').val();

        var date_publish = this.$('#date_publish').val();
        if (date_publish !== '') {
            date_publish = time.datetime_to_str(new Date(date_publish));
        }
        var params = {
            id: this.page.id,
            name: this.$('#page_name').val(),
            // Replace duplicate following '/' by only one '/'
            url: url.replace(/\/{2,}/g, '/'),
            is_menu: this.$('#is_menu').prop('checked'),
            is_homepage: this.$('#is_homepage').prop('checked'),
            website_published: this.$('#is_published').prop('checked'),
            create_redirect: this.$('#create_redirect').prop('checked'),
            redirect_type: this.$('#redirect_type').val(),
            website_indexed: this.$('#is_indexed').prop('checked'),
            date_publish: date_publish,
        };
        this._rpc({
            model: 'website.page',
            method: 'save_page_info',
            args: [[context.website_id], params],
            context: context,
        }).then(function () {
            // If from page manager: reload url, if from page itself: go to
            // (possibly) new url
            if (self._getMainObject().model === 'website.page') {
                window.location.href = url.toLowerCase();
            } else {
                window.location.reload(true);
            }
        });
    },