From 421fd1baa6b39255cf055dbd5492809e475ec052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Fri, 12 May 2023 13:51:23 +0000 Subject: [PATCH] [ADD] spreadsheet_dashboard_website_sale,website_sale: add eCommerce dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `sale.report `field `is_abandoned_cart` is moved from module `website_sale_dashboard` to `website_sale`. This allows to use it in the eCommerce dashboard in the community edition. Task 3222991 closes odoo/odoo#121165 Related: odoo/enterprise#40979 Signed-off-by: Rémi Rahir (rar) --- .../__init__.py | 1 + .../__manifest__.py | 15 + .../data/dashboards.xml | 12 + .../data/files/ecommerce_dashboard.json | 1295 +++++++++++++++++ addons/website_sale/report/sale_report.py | 15 +- 5 files changed, 1337 insertions(+), 1 deletion(-) create mode 100644 addons/spreadsheet_dashboard_website_sale/__init__.py create mode 100644 addons/spreadsheet_dashboard_website_sale/__manifest__.py create mode 100644 addons/spreadsheet_dashboard_website_sale/data/dashboards.xml create mode 100644 addons/spreadsheet_dashboard_website_sale/data/files/ecommerce_dashboard.json diff --git a/addons/spreadsheet_dashboard_website_sale/__init__.py b/addons/spreadsheet_dashboard_website_sale/__init__.py new file mode 100644 index 00000000000..a449448a63f --- /dev/null +++ b/addons/spreadsheet_dashboard_website_sale/__init__.py @@ -0,0 +1 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. diff --git a/addons/spreadsheet_dashboard_website_sale/__manifest__.py b/addons/spreadsheet_dashboard_website_sale/__manifest__.py new file mode 100644 index 00000000000..26817043ac9 --- /dev/null +++ b/addons/spreadsheet_dashboard_website_sale/__manifest__.py @@ -0,0 +1,15 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. +{ + 'name': "Spreadsheet dashboard for eCommerce", + 'version': '1.0', + 'category': 'Hidden', + 'summary': 'Spreadsheet', + 'description': 'Spreadsheet', + 'depends': ['spreadsheet_dashboard', 'website_sale'], + 'data': [ + 'data/dashboards.xml', + ], + 'installable': True, + 'auto_install': ['website_sale'], + 'license': 'LGPL-3', +} diff --git a/addons/spreadsheet_dashboard_website_sale/data/dashboards.xml b/addons/spreadsheet_dashboard_website_sale/data/dashboards.xml new file mode 100644 index 00000000000..69b5804ac56 --- /dev/null +++ b/addons/spreadsheet_dashboard_website_sale/data/dashboards.xml @@ -0,0 +1,12 @@ + + + + + eCommerce + + + + 200 + + + diff --git a/addons/spreadsheet_dashboard_website_sale/data/files/ecommerce_dashboard.json b/addons/spreadsheet_dashboard_website_sale/data/files/ecommerce_dashboard.json new file mode 100644 index 00000000000..c4ab1763c90 --- /dev/null +++ b/addons/spreadsheet_dashboard_website_sale/data/files/ecommerce_dashboard.json @@ -0,0 +1,1295 @@ +{ + "version": 12, + "sheets": [ + { + "id": "sheet1", + "name": "Dashboard", + "colNumber": 9, + "rowNumber": 29, + "rows": { + "5": { + "size": 48 + }, + "17": { + "size": 44 + }, + "18": { + "size": 35 + } + }, + "cols": { + "0": { + "size": 112 + }, + "1": { + "size": 112 + }, + "2": { + "size": 112 + }, + "3": { + "size": 112 + }, + "4": { + "size": 112 + }, + "5": { + "size": 112 + }, + "6": { + "size": 112 + }, + "7": { + "size": 112 + }, + "8": { + "size": 112 + } + }, + "merges": [], + "cells": { + "A6": { + "style": 1, + "content": "[Monthly Sales](odoo://view/{\"viewType\":\"graph\",\"action\":{\"domain\":[[\"state\",\"not in\",[\"draft\",\"cancel\",\"sent\"]]],\"context\":{\"group_by\":[],\"graph_measure\":\"price_subtotal\",\"graph_mode\":\"line\",\"graph_groupbys\":[\"date:day\"],\"graph_order\":null,\"graph_stacked\":true,\"graph_cumulated\":false},\"modelName\":\"sale.report\",\"views\":[[false,\"graph\"],[false,\"pivot\"],[false,\"search\"]]},\"threshold\":0,\"name\":\"Sales Analysis\"})", + "border": 1 + }, + "A18": { + "style": 1, + "content": "[Top Products](odoo://view/{\"viewType\":\"pivot\",\"action\":{\"domain\":[\"&\",[\"website_id\",\"!=\",false],[\"state\",\"in\",[\"sale\",\"done\"]]],\"context\":{\"group_by\":[],\"pivot_measures\":[\"order_id\",\"price_total\"],\"pivot_column_groupby\":[],\"pivot_row_groupby\":[\"product_id\"]},\"modelName\":\"sale.report\",\"views\":[[false,\"pivot\"],[false,\"graph\"],[false,\"search\"]]},\"threshold\":0,\"name\":\"Online Sales Analysis\"})", + "border": 1 + }, + "A19": { + "style": 2, + "content": "=_t(\"Products\")", + "border": 2 + }, + "A20": { + "style": 3, + "content": "=ODOO.PIVOT.HEADER(4,\"#product_id\",1)" + }, + "A21": { + "style": 4, + "content": "=ODOO.PIVOT.HEADER(4,\"#product_id\",2)" + }, + "A22": { + "style": 3, + "content": "=ODOO.PIVOT.HEADER(4,\"#product_id\",3)" + }, + "A23": { + "style": 4, + "content": "=ODOO.PIVOT.HEADER(4,\"#product_id\",4)" + }, + "A24": { + "style": 3, + "content": "=ODOO.PIVOT.HEADER(4,\"#product_id\",5)" + }, + "A25": { + "style": 4, + "content": "=ODOO.PIVOT.HEADER(4,\"#product_id\",6)" + }, + "A26": { + "style": 5, + "content": "=ODOO.PIVOT.HEADER(4,\"#product_id\",7)" + }, + "A27": { + "content": "=ODOO.PIVOT.HEADER(4,\"#product_id\",8)" + }, + "A28": { + "style": 5, + "content": "=ODOO.PIVOT.HEADER(4,\"#product_id\",9)" + }, + "A29": { + "content": "=ODOO.PIVOT.HEADER(4,\"#product_id\",10)" + }, + "B19": { + "style": 2, + "border": 2 + }, + "B20": { + "style": 5 + }, + "B22": { + "style": 5 + }, + "B24": { + "style": 5 + }, + "B26": { + "style": 5 + }, + "B28": { + "style": 5 + }, + "C19": { + "style": 2, + "content": "=_t(\"Units\")", + "border": 2 + }, + "C20": { + "style": 5, + "format": 1, + "content": "=ODOO.PIVOT(4,\"order_id\",\"#product_id\",1)" + }, + "C21": { + "format": 1, + "content": "=ODOO.PIVOT(4,\"order_id\",\"#product_id\",2)" + }, + "C22": { + "style": 5, + "format": 1, + "content": "=ODOO.PIVOT(4,\"order_id\",\"#product_id\",3)" + }, + "C23": { + "format": 1, + "content": "=ODOO.PIVOT(4,\"order_id\",\"#product_id\",4)" + }, + "C24": { + "style": 5, + "format": 1, + "content": "=ODOO.PIVOT(4,\"order_id\",\"#product_id\",5)" + }, + "C25": { + "format": 1, + "content": "=ODOO.PIVOT(4,\"order_id\",\"#product_id\",6)" + }, + "C26": { + "style": 5, + "format": 1, + "content": "=ODOO.PIVOT(4,\"order_id\",\"#product_id\",7)" + }, + "C27": { + "format": 1, + "content": "=ODOO.PIVOT(4,\"order_id\",\"#product_id\",8)" + }, + "C28": { + "style": 5, + "format": 1, + "content": "=ODOO.PIVOT(4,\"order_id\",\"#product_id\",9)" + }, + "C29": { + "content": "=ODOO.PIVOT(4,\"order_id\",\"#product_id\",10)" + }, + "D19": { + "style": 2, + "content": "=_t(\"Revenue\")", + "border": 2 + }, + "D20": { + "style": 5, + "content": "=ODOO.PIVOT(4,\"price_subtotal\",\"#product_id\",1)" + }, + "D21": { + "content": "=ODOO.PIVOT(4,\"price_subtotal\",\"#product_id\",2)" + }, + "D22": { + "style": 5, + "content": "=ODOO.PIVOT(4,\"price_subtotal\",\"#product_id\",3)" + }, + "D23": { + "content": "=ODOO.PIVOT(4,\"price_subtotal\",\"#product_id\",4)" + }, + "D24": { + "style": 5, + "content": "=ODOO.PIVOT(4,\"price_subtotal\",\"#product_id\",5)" + }, + "D25": { + "content": "=ODOO.PIVOT(4,\"price_subtotal\",\"#product_id\",6)" + }, + "D26": { + "style": 5, + "content": "=ODOO.PIVOT(4,\"price_subtotal\",\"#product_id\",7)" + }, + "D27": { + "content": "=ODOO.PIVOT(4,\"price_subtotal\",\"#product_id\",8)" + }, + "D28": { + "style": 5, + "content": "=ODOO.PIVOT(4,\"price_subtotal\",\"#product_id\",9)" + }, + "D29": { + "content": "=ODOO.PIVOT(4,\"price_subtotal\",\"#product_id\",10)" + }, + "E19": { + "style": 2 + }, + "F18": { + "style": 1, + "content": "[Top Categories](odoo://view/{\"viewType\":\"pivot\",\"action\":{\"domain\":[[\"state\",\"not in\",[\"draft\",\"cancel\",\"sent\"]]],\"context\":{\"group_by\":[],\"pivot_measures\":[\"order_id\",\"price_subtotal\"],\"pivot_column_groupby\":[],\"pivot_row_groupby\":[\"categ_id\"]},\"modelName\":\"sale.report\",\"views\":[[false,\"graph\"],[false,\"pivot\"],[false,\"search\"]]},\"threshold\":0,\"name\":\"Sales Analysis\"})", + "border": 1 + }, + "F19": { + "style": 2, + "content": "=_t(\"Categories\")", + "border": 2 + }, + "F20": { + "style": 3, + "content": "=ODOO.PIVOT.HEADER(1,\"#categ_id\",1)" + }, + "F21": { + "style": 4, + "content": "=ODOO.PIVOT.HEADER(1,\"#categ_id\",2)" + }, + "F22": { + "style": 3, + "content": "=ODOO.PIVOT.HEADER(1,\"#categ_id\",3)" + }, + "F23": { + "style": 4, + "content": "=ODOO.PIVOT.HEADER(1,\"#categ_id\",4)" + }, + "F24": { + "style": 3, + "content": "=ODOO.PIVOT.HEADER(1,\"#categ_id\",5)" + }, + "F25": { + "style": 4, + "content": "=ODOO.PIVOT.HEADER(1,\"#categ_id\",6)" + }, + "F26": { + "style": 5, + "content": "=ODOO.PIVOT.HEADER(1,\"#categ_id\",7)" + }, + "F27": { + "content": "=ODOO.PIVOT.HEADER(1,\"#categ_id\",8)" + }, + "F28": { + "style": 5, + "content": "=ODOO.PIVOT.HEADER(1,\"#categ_id\",9)" + }, + "G19": { + "style": 2, + "border": 2 + }, + "G20": { + "style": 5 + }, + "G22": { + "style": 5 + }, + "G24": { + "style": 5 + }, + "G26": { + "style": 5 + }, + "G28": { + "style": 5 + }, + "H19": { + "style": 2, + "content": "=_t(\"Units\")", + "border": 2 + }, + "H20": { + "style": 5, + "format": 1, + "content": "=ODOO.PIVOT(1,\"order_id\",\"#categ_id\",1)" + }, + "H21": { + "format": 1, + "content": "=ODOO.PIVOT(1,\"order_id\",\"#categ_id\",2)" + }, + "H22": { + "style": 5, + "format": 1, + "content": "=ODOO.PIVOT(1,\"order_id\",\"#categ_id\",3)" + }, + "H23": { + "format": 1, + "content": "=ODOO.PIVOT(1,\"order_id\",\"#categ_id\",4)" + }, + "H24": { + "style": 5, + "format": 1, + "content": "=ODOO.PIVOT(1,\"order_id\",\"#categ_id\",5)" + }, + "H25": { + "format": 1, + "content": "=ODOO.PIVOT(1,\"order_id\",\"#categ_id\",6)" + }, + "H26": { + "style": 5, + "format": 1, + "content": "=ODOO.PIVOT(1,\"order_id\",\"#categ_id\",7)" + }, + "H27": { + "format": 1, + "content": "=ODOO.PIVOT(1,\"order_id\",\"#categ_id\",8)" + }, + "H28": { + "style": 5, + "format": 1, + "content": "=ODOO.PIVOT(1,\"order_id\",\"#categ_id\",9)" + }, + "I19": { + "style": 2, + "content": "=_t(\"Revenue\")", + "border": 2 + }, + "I20": { + "style": 5, + "content": "=ODOO.PIVOT(1,\"price_subtotal\",\"#categ_id\",1)" + }, + "I21": { + "content": "=ODOO.PIVOT(1,\"price_subtotal\",\"#categ_id\",2)" + }, + "I22": { + "style": 5, + "content": "=ODOO.PIVOT(1,\"price_subtotal\",\"#categ_id\",3)" + }, + "I23": { + "content": "=ODOO.PIVOT(1,\"price_subtotal\",\"#categ_id\",4)" + }, + "I24": { + "style": 5, + "content": "=ODOO.PIVOT(1,\"price_subtotal\",\"#categ_id\",5)" + }, + "I25": { + "content": "=ODOO.PIVOT(1,\"price_subtotal\",\"#categ_id\",6)" + }, + "I26": { + "style": 5, + "content": "=ODOO.PIVOT(1,\"price_subtotal\",\"#categ_id\",7)" + }, + "I27": { + "content": "=ODOO.PIVOT(1,\"price_subtotal\",\"#categ_id\",8)" + }, + "I28": { + "style": 5, + "content": "=ODOO.PIVOT(1,\"price_subtotal\",\"#categ_id\",9)" + }, + "A7": { + "border": 2 + }, + "B6": { + "border": 1 + }, + "B7": { + "border": 2 + }, + "B18": { + "border": 1 + }, + "C6": { + "border": 1 + }, + "C7": { + "border": 2 + }, + "C18": { + "border": 1 + }, + "D6": { + "border": 1 + }, + "D7": { + "border": 2 + }, + "D18": { + "border": 1 + }, + "E6": { + "border": 1 + }, + "E7": { + "border": 2 + }, + "F6": { + "border": 1 + }, + "F7": { + "border": 2 + }, + "G6": { + "border": 1 + }, + "G7": { + "border": 2 + }, + "G18": { + "border": 1 + }, + "H6": { + "border": 1 + }, + "H7": { + "border": 2 + }, + "H18": { + "border": 1 + }, + "I6": { + "border": 1 + }, + "I7": { + "border": 2 + }, + "I18": { + "border": 1 + } + }, + "conditionalFormats": [], + "figures": [ + { + "id": "a761d77e-17d1-4d7a-ac85-5494c07dd360", + "x": 69, + "y": 0, + "width": 209, + "height": 115, + "tag": "chart", + "data": { + "baselineColorDown": "#DC6965", + "baselineColorUp": "#00A04A", + "baselineMode": "percentage", + "title": "Carts", + "type": "scorecard", + "background": "#EFEFEF", + "baseline": "Data!E2", + "baselineDescr": "since last period", + "keyValue": "Data!D2" + } + }, + { + "id": "7db1cb48-a155-4984-b8dd-de155db2b65f", + "x": 288, + "y": 0, + "width": 209, + "height": 115, + "tag": "chart", + "data": { + "baselineColorDown": "#DC6965", + "baselineColorUp": "#00A04A", + "baselineMode": "percentage", + "title": "Orders", + "type": "scorecard", + "background": "#EFEFEF", + "baseline": "Data!E3", + "baselineDescr": "since last period", + "keyValue": "Data!D3" + } + }, + { + "id": "1bfef494-7090-4263-8e07-83f14f43c0e7", + "x": 509, + "y": 0, + "width": 209, + "height": 115, + "tag": "chart", + "data": { + "baselineColorDown": "#DC6965", + "baselineColorUp": "#00A04A", + "baselineMode": "percentage", + "title": "Abandoned Carts", + "type": "scorecard", + "background": "#EFEFEF", + "baseline": "Data!E4", + "baselineDescr": "since last period", + "keyValue": "Data!D4" + } + }, + { + "id": "79d91c01-7aeb-4845-aa82-5a41895b74af", + "x": 730, + "y": 0, + "width": 209, + "height": 115, + "tag": "chart", + "data": { + "baselineColorDown": "#DC6965", + "baselineColorUp": "#00A04A", + "baselineMode": "percentage", + "title": "Total Revenue", + "type": "scorecard", + "background": "#EFEFEF", + "baseline": "Data!E5", + "baselineDescr": "since last period", + "keyValue": "Data!D5" + } + }, + { + "id": "0c5e3c79-3754-41a9-83df-b185003ce0b1", + "x": 0, + "y": 164, + "width": 1007, + "height": 248, + "tag": "chart", + "data": { + "title": "", + "background": "#FFFFFF", + "legendPosition": "none", + "metaData": { + "groupBy": [ + "date:month" + ], + "measure": "price_subtotal", + "order": null, + "resModel": "sale.report" + }, + "searchParams": { + "comparison": null, + "context": { + "search_default_Sales": 1, + "group_by_no_leaf": 1, + "group_by": [], + "search_default_filter_order_date": 1, + "search_default_recurring": 0, + "search_default_non_recurring": 1 + }, + "domain": [ + [ + "state", + "not in", + [ + "draft", + "cancel", + "sent" + ] + ] + ], + "groupBy": [ + "date:month" + ], + "orderBy": [] + }, + "type": "odoo_line", + "verticalAxisPosition": "left", + "stacked": true, + "fieldMatching": { + "eefac62b-900a-4197-95e9-9a4cdbb832d6": { + "chain": "date", + "type": "datetime", + "offset": 0 + }, + "70f31046-f26e-4847-b177-d09937e4b674": { + "chain": "website_id", + "type": "many2one" + }, + "cd428d80-466a-47b0-8af7-0393cd814d44": { + "chain": "country_id", + "type": "many2one" + }, + "d24e0ac3-8117-4d2e-a0e6-4f650672916e": { + "chain": "product_tmpl_id", + "type": "many2one" + }, + "2401236d-e945-48c2-b998-2533a8dcf1a0": { + "chain": "partner_id", + "type": "many2one" + }, + "289948d3-96db-4067-8fd6-51b5b75e677c": { + "chain": "categ_id", + "type": "many2one" + } + } + } + } + ], + "filterTables": [], + "areGridLinesVisible": true, + "isVisible": true + }, + { + "id": "795f40fb-7598-4275-b0a8-549499781f22", + "name": "Data", + "colNumber": 26, + "rowNumber": 100, + "rows": {}, + "cols": { + "0": { + "size": 109 + } + }, + "merges": [], + "cells": { + "A1": { + "style": 2, + "content": "KPI" + }, + "A2": { + "content": "Carts" + }, + "A3": { + "content": "Orders" + }, + "A4": { + "content": "Abandoned Carts" + }, + "A5": { + "content": "Revenue" + }, + "B1": { + "style": 2, + "content": "Current" + }, + "B2": { + "content": "=B3+B4" + }, + "B3": { + "content": "=ODOO.PIVOT(7,\"order_id\")" + }, + "B4": { + "content": "=ODOO.PIVOT(2,\"order_id\",\"is_abandoned_cart\",\"true\")" + }, + "B5": { + "content": "=ODOO.PIVOT(5,\"price_subtotal\")" + }, + "C1": { + "style": 2, + "content": "Previous" + }, + "C2": { + "content": "=C3+C4" + }, + "C3": { + "content": "=ODOO.PIVOT(8,\"order_id\")" + }, + "C4": { + "content": "=ODOO.PIVOT(3,\"order_id\",\"is_abandoned_cart\",\"true\")" + }, + "C5": { + "content": "=ODOO.PIVOT(6,\"price_subtotal\")" + }, + "D1": { + "style": 2, + "content": "Current" + }, + "D2": { + "style": 5, + "content": "=FORMAT.LARGE.NUMBER(B2)" + }, + "D3": { + "style": 5, + "content": "=FORMAT.LARGE.NUMBER(B3)" + }, + "D4": { + "style": 5, + "content": "=FORMAT.LARGE.NUMBER(B4)" + }, + "D5": { + "style": 5, + "content": "=FORMAT.LARGE.NUMBER(B5)" + }, + "E1": { + "style": 2, + "content": "Previous" + }, + "E2": { + "style": 5, + "content": "=FORMAT.LARGE.NUMBER(C2)" + }, + "E3": { + "style": 5, + "content": "=FORMAT.LARGE.NUMBER(C3)" + }, + "E4": { + "style": 5, + "content": "=FORMAT.LARGE.NUMBER(C4)" + }, + "E5": { + "style": 5, + "content": "=FORMAT.LARGE.NUMBER(C5)" + } + }, + "conditionalFormats": [], + "figures": [], + "filterTables": [], + "areGridLinesVisible": true, + "isVisible": true + } + ], + "entities": {}, + "styles": { + "1": { + "fontSize": 16, + "bold": true + }, + "2": { + "bold": true + }, + "3": { + "textColor": "#7B204B", + "fillColor": "#EFEFEF" + }, + "4": { + "textColor": "#7B204B" + }, + "5": { + "fillColor": "#EFEFEF" + } + }, + "formats": { + "1": "0" + }, + "borders": { + "1": { + "bottom": [ + "thin", + "#000" + ] + }, + "2": { + "top": [ + "thin", + "#000" + ] + } + }, + "revisionId": "9ab2e502-6676-4723-938f-14b19292d955", + "uniqueFigureIds": true, + "odooVersion": 5, + "globalFilters": [ + { + "id": "eefac62b-900a-4197-95e9-9a4cdbb832d6", + "type": "date", + "label": "Period", + "defaultValue": "last_week", + "rangeType": "relative", + "defaultsToCurrentPeriod": false + }, + { + "id": "70f31046-f26e-4847-b177-d09937e4b674", + "type": "relation", + "label": "Website", + "defaultValue": [], + "defaultValueDisplayNames": [], + "modelName": "website" + }, + { + "id": "cd428d80-466a-47b0-8af7-0393cd814d44", + "type": "relation", + "label": "Country", + "defaultValue": [], + "defaultValueDisplayNames": [], + "modelName": "res.country" + }, + { + "id": "d24e0ac3-8117-4d2e-a0e6-4f650672916e", + "type": "relation", + "label": "Product", + "defaultValue": [], + "defaultValueDisplayNames": [], + "modelName": "product.template" + }, + { + "id": "2401236d-e945-48c2-b998-2533a8dcf1a0", + "type": "relation", + "label": "Customer", + "defaultValue": [], + "defaultValueDisplayNames": [], + "modelName": "res.partner" + }, + { + "id": "289948d3-96db-4067-8fd6-51b5b75e677c", + "type": "relation", + "label": "Category", + "defaultValue": [], + "defaultValueDisplayNames": [], + "modelName": "product.category" + } + ], + "pivots": { + "1": { + "colGroupBys": [], + "context": { + "search_default_Sales": 1, + "group_by_no_leaf": 1, + "group_by": [], + "search_default_filter_order_date": 1, + "search_default_recurring": 0, + "search_default_non_recurring": 1 + }, + "domain": [ + [ + "state", + "not in", + [ + "draft", + "cancel", + "sent" + ] + ] + ], + "id": "1", + "measures": [ + { + "field": "order_id" + }, + { + "field": "price_subtotal" + } + ], + "model": "sale.report", + "rowGroupBys": [ + "categ_id" + ], + "name": "Sales Analysis by Product Category", + "sortedColumn": { + "groupId": [ + [], + [] + ], + "measure": "price_subtotal", + "order": "desc" + }, + "fieldMatching": { + "eefac62b-900a-4197-95e9-9a4cdbb832d6": { + "chain": "date", + "type": "datetime", + "offset": 0 + }, + "70f31046-f26e-4847-b177-d09937e4b674": { + "chain": "website_id", + "type": "many2one" + }, + "cd428d80-466a-47b0-8af7-0393cd814d44": { + "chain": "country_id", + "type": "many2one" + }, + "d24e0ac3-8117-4d2e-a0e6-4f650672916e": { + "chain": "product_tmpl_id", + "type": "many2one" + }, + "2401236d-e945-48c2-b998-2533a8dcf1a0": { + "chain": "partner_id", + "type": "many2one" + }, + "289948d3-96db-4067-8fd6-51b5b75e677c": { + "chain": "categ_id", + "type": "many2one" + } + } + }, + "2": { + "colGroupBys": [], + "context": {}, + "domain": [ + [ + "website_id", + "!=", + false + ] + ], + "id": "2", + "measures": [ + { + "field": "order_id" + } + ], + "model": "sale.report", + "rowGroupBys": [ + "is_abandoned_cart" + ], + "name": "Sales Analysis by Abandoned Cart", + "sortedColumn": { + "groupId": [ + [], + [ + "sale" + ] + ], + "measure": "price_subtotal", + "order": "desc" + }, + "fieldMatching": { + "eefac62b-900a-4197-95e9-9a4cdbb832d6": { + "chain": "date", + "type": "datetime", + "offset": 0 + }, + "70f31046-f26e-4847-b177-d09937e4b674": { + "chain": "website_id", + "type": "many2one" + }, + "cd428d80-466a-47b0-8af7-0393cd814d44": { + "chain": "country_id", + "type": "many2one" + }, + "d24e0ac3-8117-4d2e-a0e6-4f650672916e": { + "chain": "product_tmpl_id", + "type": "many2one" + }, + "2401236d-e945-48c2-b998-2533a8dcf1a0": { + "chain": "partner_id", + "type": "many2one" + }, + "289948d3-96db-4067-8fd6-51b5b75e677c": { + "chain": "categ_id", + "type": "many2one" + } + } + }, + "3": { + "colGroupBys": [], + "context": { + "search_default_confirmed": 1 + }, + "domain": [ + [ + "website_id", + "!=", + false + ] + ], + "id": "3", + "measures": [ + { + "field": "order_id" + } + ], + "model": "sale.report", + "rowGroupBys": [ + "is_abandoned_cart" + ], + "name": "Sales Analysis by Abandoned Cart", + "sortedColumn": { + "groupId": [ + [], + [ + "sale" + ] + ], + "measure": "price_subtotal", + "order": "desc" + }, + "fieldMatching": { + "eefac62b-900a-4197-95e9-9a4cdbb832d6": { + "chain": "date", + "type": "datetime", + "offset": -1 + }, + "70f31046-f26e-4847-b177-d09937e4b674": { + "chain": "website_id", + "type": "many2one" + }, + "cd428d80-466a-47b0-8af7-0393cd814d44": { + "chain": "country_id", + "type": "many2one" + }, + "d24e0ac3-8117-4d2e-a0e6-4f650672916e": { + "chain": "product_tmpl_id", + "type": "many2one" + }, + "2401236d-e945-48c2-b998-2533a8dcf1a0": { + "chain": "partner_id", + "type": "many2one" + }, + "289948d3-96db-4067-8fd6-51b5b75e677c": { + "chain": "categ_id", + "type": "many2one" + } + } + }, + "4": { + "colGroupBys": [], + "context": {}, + "domain": [ + "&", + [ + "website_id", + "!=", + false + ], + [ + "state", + "in", + [ + "sale", + "done" + ] + ] + ], + "id": "4", + "measures": [ + { + "field": "order_id" + }, + { + "field": "price_subtotal" + } + ], + "model": "sale.report", + "rowGroupBys": [ + "product_id" + ], + "name": "Sales Analysis by Product Variant", + "sortedColumn": { + "groupId": [ + [], + [] + ], + "measure": "price_subtotal", + "order": "desc" + }, + "fieldMatching": { + "eefac62b-900a-4197-95e9-9a4cdbb832d6": { + "chain": "date", + "type": "datetime", + "offset": 0 + }, + "70f31046-f26e-4847-b177-d09937e4b674": { + "chain": "website_id", + "type": "many2one" + }, + "cd428d80-466a-47b0-8af7-0393cd814d44": { + "chain": "country_id", + "type": "many2one" + }, + "d24e0ac3-8117-4d2e-a0e6-4f650672916e": { + "chain": "product_tmpl_id", + "type": "many2one" + }, + "2401236d-e945-48c2-b998-2533a8dcf1a0": { + "chain": "partner_id", + "type": "many2one" + }, + "289948d3-96db-4067-8fd6-51b5b75e677c": { + "chain": "categ_id", + "type": "many2one" + } + } + }, + "5": { + "colGroupBys": [], + "context": {}, + "domain": [ + "&", + [ + "website_id", + "!=", + false + ], + [ + "state", + "in", + [ + "sale", + "done" + ] + ] + ], + "id": "5", + "measures": [ + { + "field": "price_subtotal" + } + ], + "model": "sale.report", + "rowGroupBys": [], + "name": "Sales Analysis", + "sortedColumn": null, + "fieldMatching": { + "eefac62b-900a-4197-95e9-9a4cdbb832d6": { + "chain": "date", + "type": "datetime", + "offset": 0 + }, + "70f31046-f26e-4847-b177-d09937e4b674": { + "chain": "website_id", + "type": "many2one" + }, + "cd428d80-466a-47b0-8af7-0393cd814d44": { + "chain": "country_id", + "type": "many2one" + }, + "d24e0ac3-8117-4d2e-a0e6-4f650672916e": { + "chain": "product_tmpl_id", + "type": "many2one" + }, + "2401236d-e945-48c2-b998-2533a8dcf1a0": { + "chain": "partner_id", + "type": "many2one" + }, + "289948d3-96db-4067-8fd6-51b5b75e677c": { + "chain": "categ_id", + "type": "many2one" + } + } + }, + "6": { + "colGroupBys": [], + "context": { + "search_default_confirmed": 1 + }, + "domain": [ + "&", + [ + "website_id", + "!=", + false + ], + [ + "state", + "in", + [ + "sale", + "done" + ] + ] + ], + "id": "6", + "measures": [ + { + "field": "price_subtotal" + } + ], + "model": "sale.report", + "rowGroupBys": [], + "name": "Sales Analysis", + "sortedColumn": null, + "fieldMatching": { + "eefac62b-900a-4197-95e9-9a4cdbb832d6": { + "chain": "date", + "type": "datetime", + "offset": -1 + }, + "70f31046-f26e-4847-b177-d09937e4b674": { + "chain": "website_id", + "type": "many2one" + }, + "cd428d80-466a-47b0-8af7-0393cd814d44": { + "chain": "country_id", + "type": "many2one" + }, + "d24e0ac3-8117-4d2e-a0e6-4f650672916e": { + "chain": "product_tmpl_id", + "type": "many2one" + }, + "2401236d-e945-48c2-b998-2533a8dcf1a0": { + "chain": "partner_id", + "type": "many2one" + }, + "289948d3-96db-4067-8fd6-51b5b75e677c": { + "chain": "categ_id", + "type": "many2one" + } + } + }, + "7": { + "colGroupBys": [], + "context": {}, + "domain": [ + "&", + [ + "website_id", + "!=", + false + ], + [ + "state", + "in", + [ + "sale", + "done" + ] + ] + ], + "id": "7", + "measures": [ + { + "field": "order_id" + } + ], + "model": "sale.report", + "rowGroupBys": [], + "name": "Sales Analysis", + "sortedColumn": null, + "fieldMatching": { + "eefac62b-900a-4197-95e9-9a4cdbb832d6": { + "chain": "date", + "type": "datetime", + "offset": 0 + }, + "70f31046-f26e-4847-b177-d09937e4b674": { + "chain": "website_id", + "type": "many2one" + }, + "cd428d80-466a-47b0-8af7-0393cd814d44": { + "chain": "country_id", + "type": "many2one" + }, + "d24e0ac3-8117-4d2e-a0e6-4f650672916e": { + "chain": "product_tmpl_id", + "type": "many2one" + }, + "2401236d-e945-48c2-b998-2533a8dcf1a0": { + "chain": "partner_id", + "type": "many2one" + }, + "289948d3-96db-4067-8fd6-51b5b75e677c": { + "chain": "categ_id", + "type": "many2one" + } + } + }, + "8": { + "colGroupBys": [], + "context": { + "search_default_confirmed": 1 + }, + "domain": [ + "&", + [ + "website_id", + "!=", + false + ], + [ + "state", + "in", + [ + "sale", + "done" + ] + ] + ], + "id": "8", + "measures": [ + { + "field": "order_id" + } + ], + "model": "sale.report", + "rowGroupBys": [], + "name": "Sales Analysis", + "sortedColumn": null, + "fieldMatching": { + "eefac62b-900a-4197-95e9-9a4cdbb832d6": { + "chain": "date", + "type": "datetime", + "offset": -1 + }, + "70f31046-f26e-4847-b177-d09937e4b674": { + "chain": "website_id", + "type": "many2one" + }, + "cd428d80-466a-47b0-8af7-0393cd814d44": { + "chain": "country_id", + "type": "many2one" + }, + "d24e0ac3-8117-4d2e-a0e6-4f650672916e": { + "chain": "product_tmpl_id", + "type": "many2one" + }, + "2401236d-e945-48c2-b998-2533a8dcf1a0": { + "chain": "partner_id", + "type": "many2one" + }, + "289948d3-96db-4067-8fd6-51b5b75e677c": { + "chain": "categ_id", + "type": "many2one" + } + } + } + }, + "pivotNextId": 9, + "lists": {}, + "listNextId": 1, + "chartOdooMenusReferences": { + "0c5e3c79-3754-41a9-83df-b185003ce0b1": "website.menu_website_dashboard", + "a761d77e-17d1-4d7a-ac85-5494c07dd360": "website.menu_website_dashboard", + "7db1cb48-a155-4984-b8dd-de155db2b65f": "website.menu_website_dashboard", + "1bfef494-7090-4263-8e07-83f14f43c0e7": "website.menu_website_dashboard", + "79d91c01-7aeb-4845-aa82-5a41895b74af": "website.menu_website_dashboard" + } +} diff --git a/addons/website_sale/report/sale_report.py b/addons/website_sale/report/sale_report.py index 560e54b2eaa..84e02a92b01 100644 --- a/addons/website_sale/report/sale_report.py +++ b/addons/website_sale/report/sale_report.py @@ -7,14 +7,27 @@ class SaleReport(models.Model): _inherit = 'sale.report' website_id = fields.Many2one('website', readonly=True) + is_abandoned_cart = fields.Boolean(string="Abandoned Cart", readonly=True) def _select_additional_fields(self): res = super()._select_additional_fields() res['website_id'] = "s.website_id" + res['is_abandoned_cart'] = """ + s.date_order <= (timezone('utc', now()) - ((COALESCE(w.cart_abandoned_delay, '1.0') || ' hour')::INTERVAL)) + AND s.website_id IS NOT NULL + AND s.state = 'draft' + AND s.partner_id != %s""" % self.env.ref('base.public_partner').id + return res + + def _from_sale(self): + res = super()._from_sale() + res += """ + LEFT JOIN website w ON w.id = s.website_id""" return res def _group_by_sale(self): res = super()._group_by_sale() res += """, - s.website_id""" + s.website_id, + w.cart_abandoned_delay""" return res