init: function (parent, $target, lang) { this.parent = parent; this.ir_translation = new Model('ir.translation'); this.lang = lang || base.get_context().lang; this.setTarget($target); this._super(); this.rte = new RTE_Translate(this, this.config); this.rte.on('change', this, this.rte_changed); },
refresh: function () { var self = this; self.$el.append(_t("Loading...")); var language = self.language || base.get_context().lang.toLowerCase(); ajax.jsonRpc('/website/seo_suggest', 'call', { 'keywords': self.root, 'lang': language, }).then(function (keyword_list) { self.addSuggestions(JSON.parse(keyword_list)); }); },
get_contact_rendering: function (options) { return ajax.jsonRpc('/web/dataset/call_kw', 'call', { model: 'ir.qweb.field.contact', method: 'get_record_to_html', args: [[this.ID]], kwargs: { options: options, context: base.get_context(), } }); },
edit:function () { this.gengo_translate = true; this._super.apply(this, arguments); var self = this; 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(base.get_context()['lang']) !== -1){ self.$('.gengo_post,.gengo_wait,.gengo_inprogress,.gengo_info').remove(); self.$('button[data-action=save]') .after(qweb.render('website.ButtonGengoTranslator')); } },
$('#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: base.get_context() } }); }));
do_customize: function (e) { e.preventDefault(); var view_id = $(e.currentTarget).data('view-id'); return ajax.jsonRpc('/web/dataset/call_kw', 'call', { model: 'ir.ui.view', method: 'toggle', args: [[parseInt(view_id, 10)]], kwargs: {context: base.get_context()} }).then(function () { window.location.reload(); }); },
start: function () { var self = this; base.ready().then(function () { self.$el.on('click', "#theme_customize a", theme_customize); if ((window.location.hash || "").indexOf("theme=true") !== -1) { theme_customize(); window.location.hash = ""; } }); return this._super(); }
odoo.define("website_sale.tour_shop_frontend", function (require) { "use strict"; var tour = require("web_tour.tour"); var base = require("web_editor.base"); var steps = require("website_sale.tour_shop"); tour.register("shop", { url: "/shop", wait_for: base.ready(), }, steps); });
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: base.get_context() } }); }));
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, base.get_context()], }); } },
return this._super(type, value).then(function (mailing_list_id) { ajax.jsonRpc('/web/dataset/call', 'call', { model: 'mail.mass_mailing.list', method: 'read', args: [[parseInt(mailing_list_id)], ['popup_content'], base.get_context()], }).then(function (data) { self.$target.find(".o_popup_content_dev").empty(); if (data && data[0].popup_content) { $(data[0].popup_content).appendTo(self.$target.find(".o_popup_content_dev")); } }); });
odoo.define('website_hr_recruitment.tour', function(require) { 'use strict'; var base = require('web_editor.base'); var core = require('web.core'); var Tour = require('web.Tour'); var Model = require('web.Model'); var Session = require('web.Session'); base.ready().done(function () { Tour.register({ id: 'website_hr_recruitment_tour', name: "Test the hr applicants form", path: '/jobs/apply/3', mode: 'test', steps: [ { title: "Complete name", element: "input[name=partner_name]", sampleText: "John Smith" }, { title: "Complete Email", element: "input[name=email_from]", sampleText: "*****@*****.**" }, { title: "Complete phone number", element: "input[name=partner_phone]", sampleText: "118.218" }, { title: "Complete Subject", element: "textarea[name=description]", sampleText: "### HR RECRUITMENT TEST DATA ###" }, // TODO: Upload a file ? { title: "Send the form", element: ".o_website_form_send" }, { title: "Check the form is submited without errors", waitFor: ".oe_structure:has(h1:contains('Thank you!'))" } ] }); }); return {}; });
translation_gengo_info: function () { var repr = $(document.documentElement).data('mainObject'); 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': base.get_context()['lang'], }).done(function(res){ var dialog = new GengoTranslatorStatisticDialog(res); dialog.appendTo($(document.body)); }); },
$modal.on('click', '.a-submit', function () { var $a = $(this); $form.ajaxSubmit({ url: '/shop/cart/update_option', data: {lang: base.get_context().lang}, success: function (quantity) { if (!$a.hasClass('js_goto_shop')) { window.location.href = window.location.href.replace(/shop([\/?].*)?$/, "shop/cart"); } var $q = $(".my_cart_quantity"); $q.parent().parent().removeClass("hidden", !quantity); $q.html(quantity).hide().fadeIn(600); } }); $modal.modal('hide'); });
odoo.define("website_event.tour", function (require) { "use strict"; var core = require("web.core"); var tour = require("web_tour.tour"); var base = require("web_editor.base"); var _t = core._t; tour.register("event", { url: "/", wait_for: base.ready(), }, [tour.STEPS.WEBSITE_NEW_PAGE, { trigger: "a[data-action=new_event]", content: _t("Click here to create a new event."), position: "bottom", }, { trigger: ".modal-dialog #editor_new_event input[type=text]", content: _t("Create a name for your new event and click <em>\"Continue\"</em>. e.g: Technical Training"), position: "right", }, { trigger: ".modal-dialog button.btn-primary.btn-continue", extra_trigger: ".modal-dialog #editor_new_event input[type=text][value!=\"\"]", content: _t("Click <em>Continue</em> to create the event."), position: "right", }, { trigger: "#snippet_structure .oe_snippet:eq(2) .oe_snippet_thumbnail", content: _t("Drag this block and drop it in your page."), position: "bottom", run: "drag_and_drop", }, { trigger: "button[data-action=save]", content: _t("Once you click on save, your event is updated."), position: "bottom", }, { trigger: "button.btn-danger.js_publish_btn", extra_trigger: "body:not(.editor_enable)", content: _t("Click to publish your event."), position: "top", }, { trigger: ".js_publish_management button[data-toggle=\"dropdown\"]", extra_trigger: ".js_publish_management button.js_publish_btn.btn-success:visible", content: _t("Click here to customize your event further."), position: "left", }]); });
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 ajax.jsonRpc('/web/dataset/call_kw', 'call', { model: 'ir.attachment', method: 'search_read', args: [], kwargs: { domain: domain, fields: ['name', 'mimetype', 'checksum', 'url'], // if we want to use /web/image/xxx with redirect for image url, remove 'url' order: 'id desc', context: base.get_context() } }).then(this.proxy('fetched_existing')); },
_saveView: function (session) { var def = $.Deferred(); var self = this; ajax.jsonRpc('/web/dataset/call', 'call', { model: 'ir.ui.view', method: 'write', args: [[session.id], {arch: session.text}, _.extend(base.get_context(), {lang: null})], }).then(function () { self._toggleDirtyInfo(session.id, false); def.resolve(); }, function (source, error) { def.reject(session, error); }); return def; },
init: function (parent, getConfig) { var self = this; this._super.apply(this, arguments); this.init_bootstrap_carousel = $.fn.carousel; this.edit_bootstrap_carousel = function () { var res = self.init_bootstrap_carousel.apply(this, arguments); // off bootstrap keydown event to remove event.preventDefault() // and allow to change cursor position $(this).off('keydown.bs.carousel'); return res; }; this._getConfig = getConfig || this._getDefaultConfig; base.computeFonts(); },
odoo.define('website_crm.tour', function(require) { 'use strict'; var tour = require('web_tour.tour'); var base = require('web_editor.base'); tour.register('website_crm_tour', { test: true, url: '/page/contactus', wait_for: base.ready(), }, [{ content: "Complete name", trigger: "input[name=contact_name]", run: "text John Smith", }, { content: "Complete phone number", trigger: "input[name=phone]", run: "text 118.218" }, { content: "Complete Email", trigger: "input[name=email_from]", run: "text john@smith.com" }, { content: "Complete Company", trigger: "input[name=partner_name]", run: "text Odoo S.A." }, { content: "Complete Subject", trigger: "input[name=name]", run: "text Useless message" }, { content: "Complete Subject", trigger: "textarea[name=description]", run: "text ### TOUR DATA ###" }, { content: "Send the form", trigger: ".o_website_form_send" }, { content: "Check we were redirected to the success page", trigger: "#wrap:has(h1:contains('Thanks')):has(div.alert-success)" }]); return {}; });
odoo.define('sale.tour_sale_signature', function (require) { 'use strict'; var tour = require('web_tour.tour'); var base = require('web_editor.base'); // This tour relies on data created on the Python test. tour.register('sale_signature', { test: true, url: '/my/quotes', wait_for: base.ready(), }, [ { content: "open the test SO", trigger: 'a:containsExact("test SO")', }, { content: "click sign", trigger: 'a:contains("Sign")', }, { content: "click Auto", trigger: '.o_portal_sign_auto_button', }, { content: "click select style", trigger: '.o_portal_sign_auto_select_style a', }, { content: "click style 4", trigger: '.o_portal_sign_auto_font_selection a:eq(3)', }, { content: "click submit", trigger: '.o_portal_sign_submit', }, { content: "check it's confirmed", trigger: '#quote_content:contains("Thank You")', }, ]); });
saveView: function (session) { var xml = new XmlDocument(session.text); var isWellFormed = xml.isWellFormed(); var def = $.Deferred(); if (isWellFormed === true) { ajax.jsonRpc('/web/dataset/call', 'call', { model: 'ir.ui.view', method: 'write', args: [[session.id], { 'arch': xml.xml }, _.extend(base.get_context(), {'lang': null})], }).then(function () { def.resolve(); }).fail(function (source, error) { def.reject("server", session, error); }); } else { def.reject(null, session, isWellFormed); } return def; },
new_blog_post: function () { var model = new Model('blog.blog'); model.call('name_search', [], { context: base.get_context() }).then(function (blog_ids) { if (blog_ids.length == 1) { document.location = '/blog/' + blog_ids[0][0] + '/post/new'; } else if (blog_ids.length > 1) { website.prompt({ id: "editor_new_blog", window_title: _t("New Blog Post"), select: "Select Blog", init: function (field) { return blog_ids; }, }).then(function (blog_id) { document.location = '/blog/' + blog_id + '/post/new'; }); } }); },
saveElement: function ($el, context) { // remove multi edition if ($el.data('oe-model')) { var key = $el.data('oe-model')+":"+$el.data('oe-id')+":"+$el.data('oe-field')+":"+$el.data('oe-type')+":"+$el.data('oe-expression'); if (this.__saved[key]) return $.when(); this.__saved[key] = true; } var markup = this.getEscapedElement($el).prop('outerHTML'); return ajax.jsonRpc('/web/dataset/call', 'call', { model: 'ir.ui.view', method: 'save', args: [ $el.data('oe-id'), markup, $el.data('oe-xpath') || null, _.omit(context || base.get_context(), 'lang') ], }); },
save : function() { var $target = $('#wrapwrap').find('#o_newsletter_popup'); if ($target && $target.length) { $target.modal('hide'); $target.css("display", "none"); $('.o_popup_bounce_small').show(); if (!$target.find('.o_popup_content_dev').length) { $target.find('.o_popup_modal_body').prepend($('<div class="o_popup_content_dev" data-oe-placeholder="' + _t("Type Here ...") + '"></div>')); } var content = $('#wrapwrap .o_popup_content_dev').html(); var newsletter_id = $target.parent().attr('data-list-id'); ajax.jsonRpc('/web/dataset/call', 'call', { model: 'mail.mass_mailing.list', method: 'write', args: [parseInt(newsletter_id), {'popup_content':content}, base.get_context()], }); } return this._super(); },
saveElement: function ($el, context) { // remove multi edition if ($el.data('oe-translation-id')) { var key = 'translation:'+$el.data('oe-translation-id'); if (this.__saved[key]) return true; this.__saved[key] = true; var translation_content = this.getEscapedElement($el).html(); return ajax.jsonRpc('/web/dataset/call', 'call', { model: 'ir.translation', method: 'write', args: [ [+$el.data('oe-translation-id')], {value: translation_content, state: 'translated'}, context || base.get_context() ], }); } return this._super.apply(this, arguments); },
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']; var model = new Model(obj.model).call('read', [[obj.id], fields, base.get_context()]).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; },
odoo.define("website.tour.contact", function (require) { "use strict"; var core = require("web.core"); var tour = require("web_tour.tour"); var base = require("web_editor.base"); var _t = core._t; tour.register("contact", { url: "/page/contactus", wait_for: base.ready(), }, [{ trigger: "li#customize-menu", content: _t("<b>Install a contact form</b> to improve this page."), extra_trigger: "#o_contact_mail", position: "bottom", }, { trigger: "li#install_apps", content: _t("<b>Install new apps</b> to get more features. Let's install the <i>'Contact form'</i> app."), position: "bottom", }]); });
odoo.define('website_sale.tour_shop_no_variant_attribute', function (require) { 'use strict'; var tour = require('web_tour.tour'); var base = require('web_editor.base'); // This tour relies on a data created from the python test. tour.register('tour_shop_no_variant_attribute', { test: true, url: '/shop?search=Test Product', wait_for: base.ready(), }, [ { content: "select Test Product", trigger: '.oe_product_cart a:containsExact("Test Product")', }, { content: "check price", trigger: '.oe_currency_value:contains("1.00")', run: function () {}, }, { content: "add to cart", trigger: 'a:contains(Add to Cart)', }, { content: "check no_variant value is present", trigger: '.td-product_name:contains(No Variant Attribute: No Variant Value)', extra_trigger: '#cart_products', run: function () {}, }, { content: "check price is correct", trigger: '.td-price:contains(11.0)', run: function () {}, }, ]); });
odoo.define('website_hr_recruitment.tour', function(require) { 'use strict'; var base = require('web_editor.base'); var tour = require("web_tour.tour"); tour.register('website_hr_recruitment_tour', { test: true, url: '/jobs/apply/3', wait_for: base.ready(), }, [{ content: "Complete name", trigger: "input[name=partner_name]", run: "text John Smith" }, { content: "Complete Email", trigger: "input[name=email_from]", run: "text john@smith.com" }, { content: "Complete phone number", trigger: "input[name=partner_phone]", run: "text 118.218" }, { content: "Complete Subject", trigger: "textarea[name=description]", run: "text ### HR RECRUITMENT TEST DATA ###" }, { // TODO: Upload a file ? content: "Send the form", trigger: ".o_website_form_send" }, { content: "Check the form is submited without errors", trigger: ".oe_structure:has(h1:contains('Congratulations'))" }]); return {}; });
odoo.define('website_event_sale.tour', function (require) { 'use strict'; var tour = require('web_tour.tour'); var base = require("web_editor.base"); tour.register('event_buy_tickets', { test: true, url: '/event', wait_for: base.ready() }, [ { content: "Go to the `Events` page", trigger: 'a[href*="/event"]:contains("Conference on Business Apps"):first', }, { content: "Select 1 unit of `Standard` ticket type", extra_trigger: '#wrap:not(:has(a[href*="/event"]:contains("Conference on Business Apps")))', trigger: 'select:eq(0)', run: 'text 1', }, { content: "Select 2 units of `VIP` ticket type", extra_trigger: 'select:eq(0):has(option:contains(1):propSelected)', trigger: 'select:eq(1)', run: 'text 2', }, { content: "Click on `Order Now` button", extra_trigger: 'select:eq(1):has(option:contains(2):propSelected)', trigger: '.btn-primary:contains("Register Now")', }, { content: "Fill attendees details", trigger: 'form[id="attendee_registration"] .btn:contains("Continue")', run: function () { $("input[name='1-name']").val("Att1"); $("input[name='1-phone']").val("111 111"); $("input[name='1-email']").val("*****@*****.**"); $("input[name='2-name']").val("Att2"); $("input[name='2-phone']").val("222 222"); $("input[name='2-email']").val("*****@*****.**"); $("input[name='3-name']").val("Att3"); $("input[name='3-phone']").val("333 333"); $("input[name='3-email']").val("*****@*****.**"); }, }, { content: "Validate attendees details", extra_trigger: "input[name='1-name'], input[name='2-name'], input[name='3-name']", trigger: 'button:contains("Continue")', }, { content: "Check that the cart contains exactly 3 triggers", trigger: 'a:has(.my_cart_quantity:containsExact(3))', run: function () {}, // it's a check }, { content: "go to cart", trigger: 'a:contains(Return to Cart)', }, { content: "Modify the cart to add 1 unit of `VIP` ticket type", extra_trigger: "#cart_products:contains(Standard):contains(VIP)", trigger: "#cart_products tr:contains(VIP) .fa-plus", }, { content: "Now click on `Process Checkout`", extra_trigger: 'a:has(.my_cart_quantity):contains(4)', trigger: '.btn-primary:contains("Process Checkout")' }, { content: "Complete the checkout", trigger: 'a[href="/shop/confirm_order"]:contains("Confirm")', }, { content: "Check that the subtotal is 5,500.00", trigger: '#order_total_untaxed .oe_currency_value:contains("5,500.00")', run: function () {}, // it's a check }, { content: "Select `Wire Transfer` payment method", trigger: '#payment_method label:contains(Wire Transfer) input', }, { content: "Pay", extra_trigger: '#payment_method label:contains(Wire Transfer) input:checked', trigger: '.oe_sale_acquirer_button .btn[type="submit"]:visible', }, { content: "Last step", trigger: '.oe_website_sale:contains("Thank you for your order")', } ] ); });