summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/backend/dashboard.js
AgeCommit message (Collapse)Author
2021-05-03[FIX] http_routing, website: prevent crash when using `fw` in urlRomain Derie
Before this commit, the routing map generated and used would be the one from the website the request is performed, instead of the one from the `fw` website ID which will be the one we redirect the user to. This issue was introduced with the routing map by website, be8fc2296b38 and is restricted to a single case: a publisher using the website switcher, and it won't happen on next page naviguation/refresh as the `fw` website id will be the same as the current website's ID. Thus there won't be any routing map mismatch. Step to reproduce: - Create a page on website 2, set it as homepage - Naviguate to website 1 on '/' url - Naviguate to website 2 on '/' url This will raise a werkzeug error about `EndPoint not iterable`. ----- Technical analysis ------ This is the current flow: 1. `_dispatch()` is setting `website_routing` to `get_current_website()` -> 2 2. `_dispatch()` is calling `_match()` 3. `_match()` is calling `routing_map()` with key = `website_routing`, which was set to 2 in step 1. 4. `routing_map()` is calling `_generate_routing_rules()` which generate the rules based on `website_routing`, which was set to 2 in step 1. 5. `_dispatch()` authenticate the user by calling `_authenticate()` 6. `_dispatch()` is calling `_add_dispatch_parameter()`, where URL param `fw` is forced in session, so `get_current_website()` now return the correct `website_id` -> 1 The issue: in order to handle the `fw` URL parameter (step 6.), we need to check the rights to ensure we can allow the website switch. To check rights, user need to be authenticated (step 5.), which is done after generating the routing map (2. & 3. & 4.). The routing map is generated based on the current website (step 1.) Step 6 depends of steps 5 which depends of steps 2/3/4 which depend of step 1, but step 1 should depend of step 6, which is an impossible cycle. closes odoo/odoo#70278 X-original-commit: 878e28f93a65756fa2002ef2af5b02a3e2c59b1b Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com> Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
2020-12-18[FIX] website: dashboard: mounted called twiceAaron Bohy
Before this commit, the 'mounted' method of the ControlPanel in the website dashboard was called twice, when entering the dashboard. It happened because the dashboard updated the ControlPanel before being actually mounted, so mounted was called once when the dashboard was mounted, and once when the update was applied. Ideally, this should not be an issue (this isn't an issue with owl). However, in Odoo, we mix layers of Owl Components and legacy widgets. In these situations, the above scenario isn't properly handled (and can't be). As a consequence, in mobile (enterprise), it crashed because an handler bound in mounted (thus twice) was only unbound once. This commit avoids the issue by correctly setting the control panel props before rendering it (the update was actually useless). opw~2417307 closes odoo/odoo#63574 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-11-18[FIX] website: use correct action domain on dashboardRomain Derie
Without this commit, when clicking on a metric on the website dashboard, it would not load the correct data. Indeed, the dashboard is loaded for a specific website only, but clicking on a metric opens the data for every website together. Step to reproduce: - Make some orders on 2 differents website ecommerce - OPTIONAL: Get through the payment on some orders, then just leave some products in the cart afterward to have some unpaid orders - Go to the website dashboard, you see some metrics - Change the selected website on top right, you see the metrics adapts correctly - Click on a metric, it doesn't fit the number you clicked on. For instance, if you had 1 Unpaid Orders for website 1 and 3 Unpaid Orders for website 2, you see 4 orders in the tree view once you have clicked the metric. This commit ensures the correct website is appended to every dashboard action domain. opw-2369420 Fixes #44926, fixes #51125
2019-11-18[FIX] website: use localized date formatIvan Yelizariev
If getLangDateFormat is called right in loading the js file, it returns default format. We now call it when translations are ready. closes odoo/odoo#42126 X-original-commit: e7a58430a382ca1161131e562d53bef3ea0e6ce0 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2019-09-25[MERGE] forward port branch saas-12.4 up to bef26222b8fChristophe Simonis
2019-09-24[FIX] website: make 'Go to website' redirect to correct websiteRomain Derie
Before this commit, 'Go to website' in website module dashboard might not redirect to the correct website. It would just redirect to `/` (href) without forcing the website selected in the dashboard. task-2063252 Closes #36390 closes odoo/odoo#37359 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-08-28[FIX] website: fix ctx argumentRomainLibert
In the call to Chart.js we pass a ctx which should be a DOM element, however we pass `null` as the ctx. It seems that what happens is that we look for the DOM element inside the `document` (via getElementById) but this element is not yet inserted into the document, hence this returns `null`. Since we already have a reference to the canvas element which should be used as ctx, we can probably just reuse this reference closes odoo/odoo#36072 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2019-05-13[MERGE] forward port branch saas-12.2 up to 243a4ae5cbcChristophe Simonis
2019-05-10[MERGE] forward port branch saas-12.1 up to 330b99f60c0Christophe Simonis
2019-05-09[MERGE] forward port branch 12.0 up to e11bacfe512Christophe Simonis
2019-05-03[FIX] website{,_sale_link_tracker}: ecommerce graph todayMeghna Jaswani
The UTM graph data in Website > Dasboard > Analytics is not getting properly filtered on the basis of values of date_from and date_to on website_sale dashboard. The field confirmation date which is of type datetime while date_from and date_to are of date string in local browser timezone. Hence date_domain is not perfect as shown below on local date 29th april 2019, we would send: ('confirmation_date', '>=', '2019-04-22'), ('confirmation_date', '<=', '2019-04-29') But in reality we could want a from midnight of week before the current UTC day, and to current UTC now or 23:59:59 of current UTC day. This way, the data sent back matches more what is expected, instead of the preceding domain, we would then have the following: - if UTC now corresponding to local now is on '2019-04-29' ('confirmation_date', '>=', '2019-04-22 00:00:00'), ('confirmation_date', '<=', '2019-04-29 23:59:59') - if UTC now corresponding to local now is on '2019-04-28': ('confirmation_date', '>=', '2019-04-21 00:00:00'), ('confirmation_date', '<=', '2019-04-28 23:59:59') - if UTC now corresponding to local now is on '2019-04-30': ('confirmation_date', '>=', '2019-04-23 00:00:00'), ('confirmation_date', '<=', '2019-04-30 23:59:59') And each one will be displayed as days 22 up to 29 in line chart (with local today 29 being the last day of the chart and contening orders of the current UTC day). With these change in the UTM pie chart: - a local date that is before a UTC date => we see the sales from up to today UTC instead of from up to before yesterday UTC - a local date that is the same as an UTC date => we see the sale from up to today UTC instead of yesterday UTC And in the line chart (that already had half of the fix in f6fc7c23192): - a local date that is before a UTC date => we see the sales from up to today UTC instead of from up to yesterday UTC - a local date that is after a UTC date => we see the sales of current UTC day + range of days (eg. for a week 7) instead of current UTC day + range of days minus 1 (eg. for a week 6). opw-1971539 closes #33041 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Co-authored-by: Nicolas Lempereur <nle-odoo@users.noreply.github.com>
2019-04-05[MERGE] forward port branch saas-12.2 up to f2be461f090Christophe Simonis
2019-04-05[MERGE] forward port branch saas-12.1 up to f2d0995362cChristophe Simonis
2019-04-04[MERGE] forward port branch 12.0 up to 251021796c2Christophe Simonis
2019-04-01[IMP] website: use Chart.js in community dashboardMathieu Duckerts-Antoine
This commit is one part of the task 'removing nvd3'. We use now Chart.js to draw charts. Task ID: 1946138
2019-03-06[REF] website: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-04-01[FIX] website: tooltip width analytics chartNicolas Lempereur
On the line chart of google analytics account, we have a tooltip with lines ({date} sessions: {number of session}) overlapping and going outside of the modal width. This does not happen on google examples, the only fix found is to display the tooltip in HTML instead of SVG. opw-1961605 closes #32285 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2018-12-07[REF] *: adapt all client actionsAaron Bohy
to ControlPanel/Search view refactoring. The ControlPanel being now inside the DOM of client actions, those existing widgets needed to be adapted (in the way they define if and how they want a ControlPanel, and in the way the manipulate their DOM as it slightly changed). Tests needed to be adapted as well. Part of task 1893568 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com>
2019-01-16[IMP] website: improve onboarding flowAnshuman Sharma
- Improve the website tour (typo, tip positions, etc) and added new steps to publish a new page - Make close button of 'Mobile Preview' more visible - Fix the overflow for long menu names in menu editor dialog - Change the menu string from 'Affix Top Menu' to 'Fixed Top Menu' - Change theme customization dialog's title to 'Customize Theme' from 'Customize this theme' - Improve strings for Google Analytics task-1895287 closes odoo/odoo#28199
2018-11-13[FIX] website: Impossible to link an analytic accountGoffin Simon
Steps to reproduce the bug: - Go to Website > Dashboard > Analytics and click on "Link my analytics account" - Enter some data and save Bug: A traceback was raised: TypeError: website_set_ga_data() missing 1 required positional argument: 'website_id' opw:1905874 closes odoo/odoo#28636
2018-08-13[IMP] website_[blog|event|forum|sale|slide]: make website specificJeremy Kersten
Set up env & tools for module website multiwebsite (blog, event, sale..) website_id in modelConverter and ir_rule add _compute_domain_keys to have a different cache per website or rules would not be correctly website_dependant eg: blog 1 on website 1, blog 2 on website 2 access blog 1 from website 1 => can access -> normal access blog 1 from website 2 => can access -> should crash because (ir rule) split mixing website.published.mixin and website.published.multi.mixin to have website_id only on last one. multi mixing will: - override website_published compute to take current_website into account (not in backend) - force website when clicking on published in backend - website blog, website_sale, website_event, website_forum, website_slides are now multi website Co-authored-by: Derie Romain <rde@odoo.com> Co-authored-by: Kersten Jérémy <jke@odoo.com>
2018-08-13[IMP] website,*: support multiple websitesJoren Van Onder
This implements support to administer multiple websites. Although the core functionality already existed, managing multiple websites was fairly technical. In the interest of database updates and migration this attempts to keep duplicated data to a minimum. To do this the usual generic records are rendered unless some website-specific record exists that replaces it. Copy-on-write (COW) is used to create these website-specific records. Through this mechanism creating a website-specific record is delayed until necessary. A COW mechanism has been implemented on 4 models: ir.ui.view, website.page, website.menu and ir.attachment. These COW mechanisms are activated when editing data through the website (aka frontend). These frontend edits (e.g. with web_editor) will be website-specific, possibly creating a website-specific record when necessary. When editing data in the backend nothing special will happen, even when editing a generic record. Note that because of this mechanism also facilitates the ability to create new, uncustomized websites because the generic data is kept. Support is provided for a website to have any theme. Themes are fairly complex to handle. Standalone themes can depend on other standalone themes (e.g. theme_beauty depends on theme_loftspace) and themes usually modify some data of the themes they depend on. Because a theme can be installed on multiple websites, using website_id m2o fields does not work well. It would require duplicate data, making updates and migration harder. Because of this, data for themes (ir.ui.view and ir.attachment specifically) have a theme_id m2o. website has a theme_ids m2m that identifies all theme modules currently installed on it. Through these fields we figure out what to render. A theme is only fully uninstalled when it's no longer active on any website. The advantage of this approach is that upgrading or migrating theme data is no different from the single-website case. The website.published.mixin class was modified to handle multiple websites. A wizard was added in the backend to easily manage this for multiple website. Although not used anywhere in this commit, a 'website_id' variable has been added in the evaluation context of ir.rule. It allows to easily make any model multi-website aware, all that's needed is a custom website_id m2o field on a model and a custom record rule.
2018-07-27[REF] *: BS4, adapt col-related classesqsm-odoo
col-lg-* -> col-xl-* col-md-* -> col-lg-* col-sm-* -> col-md-* col-xs-* -> col-* col-lg-offset-* -> offset-xl-* col-md-offset-* -> offset-lg-* col-sm-offset-* -> offset-md-* col-xs-offset-* -> offset-* col-lg-pull-* -> order-xl-1 col-md-pull-* -> order-lg-1 col-sm-pull-* -> order-md-1 col-xs-pull-* -> order-1 col-lg-push-* -> order-xl-2 col-md-push-* -> order-lg-2 col-sm-push-* -> order-md-2 col-xs-push-* -> order-2
2018-03-21[MERGE] forward port branch saas-11.2 up to 500e3f49705Christophe Simonis
2018-03-20[MERGE] forward port branch 11.0 up to 2835d299792Christophe Simonis
2018-03-19[MERGE] forward port branch saas-15 up to 0d552411852Christophe Simonis
2018-03-08[REF] web,*: introduce the concept of AbstractActionGéry Debongnie
Before this commit, a client action was simply a subclass of Widget. This is quite simple, but not really enough for the ActionManager. The ActionManager needs to handle client actions in a different way that view actions. Sometimes, it needs to check if a method exists before calling it. With this commit, we introduce a new abstraction: the AbstractAction class, which defines a common API for all actions managed by the web client. Note that the API proposed in this commit is just the beginning. We will introduce other methods in the future, to manage the focus, or the scroll position, for example.
2018-01-16[REF] web,*: ActionManager/ViewManager refactoringAaron Bohy
This rev. is the first part (out of 3) of the refactoring of the ActionManager and ViewManager layer of the webclient. The main changes are: - there is no ViewManager anymore, its work is now handled by the ActionManager itself, but isolated in a specific file ; this eases a lot of things, as the breadcrumbs handling for example. - the ActionManager code is converted to the new coding principles and guidelines ; mainly, children widgets communicate with it by triggering events up, and not by function calls anymore. - the ActionManager layer is now testable, and a lot of tests have already been written. - the code in other addons has been adapted consequently. What's coming next: - introduce the 'AbstractAction' Widget, and make client actions and view controllers inherit from it ; this widget will implement a common API that could be used uniformly by the ActionManager (e.g. restore(), canBeLeft(), renderButtons(), getTitle()...). - move the ControlPanel handling from the ActionManager to the AbstractAction.
2017-12-05[IMP] website(_sale): Improve UX for the website dashboardDhawal Limbuwala
Purpose ======= There are some usability issues in the website dashboard Specification ============= 1/ Move button 'Go to Website' in the header 2/ Hide the action button bar if there's nothing in it 3/ Align the labels in the graph's legend 4/ Make the legend labels and display more obvious 5/ Modify the graph colors to be more readable 6/ Remove margins around todo buttons
2017-12-05[IMP] website: Reload website dashboard when coming back from breadcrumbDhawal Limbuwala
Purpose ======= When clicking on a dashboard element (eg: an invoice) and modifying it doesn't reload the dashboard, which could be confusing.
2017-12-05[IMP] website: Remove the suggested app on the website dashboardDhawal Limbuwala
2017-09-30[IMP] website: Script injected in DOM: window.onerror empty paramsrde
Before this commit, error thrown by scripts injected in DOM won't return a clean error on window.onerror. It would open the crash_manager's show_error's dialog that wouldn't display any informations except "Script Error." and "Traceback:". This is because of browser's security reason: it will just give you a 'Script error.' as message and nothing else for security issue. Now, this kind of error will show a clearer message informing that it is probably originating from a Javascript file served from a different origin. There is now also the possibility for developers to handle/override the behavior when this kind of error is catch to prevent the dialog to open for example. Might be of use: https://blog.sentry.io/2016/05/17/what-is-script-error.html https://stackoverflow.com/a/7778424 https://danlimerick.wordpress.com/2014/01/18/how-to-catch-javascript-errors-with-window-onerror-even-on-chrome-and-firefox/ (Search for Script Error)
2017-09-18[FIX] *: fix a bunch of incorrectly documented docstringXavier Morel
Fix a bunch of ill-documented/incomplete/incorrect method docs Without this, the automatic doc generation does not work.
2017-08-31[IMP] web: lazy load nvd3, ace and fullCalendar lib to reduce asset sizeChristophe Matthieu
2017-08-16[REF] web_editor, website, *: complete refactoringqsm-odoo
* mass_mailing, payment, point_of_sale, portal, survey, web, web_tour, website_blog, website_crm_partner_assign, website_event, website_event_questions, website_form, website_forum, website_gengo, website_hr_recruitment, website_links, website_mail, website_mail_channel, website_mass_mailing, website_quote, website_sale, website_sale_options, website_slides, website_twitter This commit reviews the whole "JS side" of the web_editor and website apps. This is a first step to be able to improve them with new and better functionnalities; this commit is not supposed to change any visual behavior. The main goal was to achieve a structure similar to the backend one. Now, the frontend side also has a root widget (like the WebClient) and all other widgets are attached to it one way or another. This allows the benefits of using the 'trigger_up' functionnality for example. As RPC are now mainly done with the `this._rpc` functionnality (being possible thanks to the parent hierarchy), the frontend will also be possible to test thanks to QUnit in a future update (besides the "text" editor side which still requires a refactoring to be able to do that). --- Here are some of the changes: (-) conventions and documentation The code has been updated to follow JS conventions and a lot of code has been commented (around +2000 lines of comment). This also means that lots of functions have been renamed to use camelCase or simply to make their name understandable. See https://github.com/odoo/odoo/wiki/Javascript-coding-guidelines. (-) deprecated: web_editor.base The "web_editor.base" module has been split and does not force the modules which require it to wait for DOM ready anymore. This was indeed slowing loading times, but also prevented to use some modules in some contexts (see the LESS editor use in web_studio which is the subject of another task). Now the "editor context" can be got thanks to the "web_editor.context" JS module with its "get" function. The "web_editor.base" module should probably not be used anymore (see its code and recent updates). (-) new: web.dom_ready If a JS module should wait for the DOM to be ready to be executed, a new JS module has been created: "web.dom_ready". This should always be used in a module which only want to instantiate stuff. Do not extend (or worst, include) classes after DOM ready. (-) website.website The "website.website" module has been split. "website.website" does not return anything useful anymore, it just initialize some miscellaneous stuff, without waiting for the DOM to be ready. You might want to check "website.utils", "website.content.compatibility" or `WebsiteRoot`. Also `website.form` has been deleted (use `this._rpc`), so has been `website.error`. `website.prompt` will be removed in a future update to be replaced by `Dialog.prompt`. (-) widgets are great Many classes which were not widgets are now widgets. This allows them to use the 'events', the 'xmlDependencies' and the 'this._rpc' features for example. Here are some of the main ones: - Snippet options: these were classes with a `$el` for the menu element and `$target` for the customized element. This is still the case but following standard `Widget` structure (one exception: using `this.$(...)` searches in the `$target` as before this update). - Snippet animations: instead of class instances with a `$target` element which can be `start` and `stop`, these are now standard widgets which can be `start` and `destroy`. `this.$target` is an alias to `this.$el` for ease of compatibility. - Snippet editors: instead of class instances in charge of an editor overlay, these are now widgets. Each "child" snippet editor is properly attached as a "child", which allows editors to communicate and to be properly destroyed. (-) root widgets and website navbar The frontend is different of the backend. In the backend, the page has an empty <body/> element and all the components are instantiated from parent to children (i.e. the `WebClient` is instantiated and is in charge of instantiating the `ControlPanel`, etc). The frontend cannot work like that on page loadings as they are way more frequent than in the backend and we do not want them to flicker. A frontend page is loaded as a <body/> element which already contains the website navbar and its menus and the whole content page. JS code has to be "attached" to these existing elements. This is possible thanks to the `RootWidget` instances and the specialized `WebsiteRoot`, `IframeRoot` and `WebsiteNavbar` (see code for details). (-) lazy loading No more (or at least a lot less) XML/JS has to be loaded on page loading, thanks to the use of the `Widget.xmlDependencies` feature. XML which have to be lazy loaded is loaded only on related Widget instantiation if necessary, which allows to execute a lot of JS code before the DOM is ready and to start many widgets on DOM ready (not later). A visual benefit of this is clicking on the 'edit' button as soon as it is possible: before this commit, this was sometimes not doing anything as event handlers were not binded yet. Still a possible exception: loading the session and locales. This may be asynchronous stuff which is still required before widget instantiations but this will be the subject of another task. (-) deprecated code and code location More than reviewing code and organizing it, many apparent dead code was removed. More importantly, mislocated code was put in the right app. This is the case for snippet animations which is a concept for website apps but was defined in the web_editor app, or some translation concepts which were part of website but should have been part of web_editor. --- There are probably more things to say about this commit but I will let the comments speak for those.
2017-08-16[MOV] web_editor, website: reorganize filesqsm-odoo