Skip to content

[ADD] estate: added core functionality and improvement awesome_dashboard #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: 18.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions awesome_dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from . import models
from . import controllers
39 changes: 19 additions & 20 deletions awesome_dashboard/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
# -*- coding: utf-8 -*-
{
'name': "Awesome Dashboard",

'summary': """
"name": "Awesome Dashboard",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary changes

"summary": """
Starting module for "Discover the JS framework, chapter 2: Build a dashboard"
""",

'description': """
"description": """
Starting module for "Discover the JS framework, chapter 2: Build a dashboard"
""",

'author': "Odoo",
'website': "https://www.odoo.com/",
'category': 'Tutorials/AwesomeDashboard',
'version': '0.1',
'application': True,
'installable': True,
'depends': ['base', 'web', 'mail', 'crm'],

'data': [
'views/views.xml',
"author": "Odoo",
"website": "https://www.odoo.com/",
"category": "Tutorials/AwesomeDashboard",
"version": "0.1",
"application": True,
"installable": True,
"depends": ["base", "web", "mail", "crm"],
"data": [
"views/views.xml",
],
'assets': {
'web.assets_backend': [
'awesome_dashboard/static/src/**/*',
"assets": {
"web.assets_backend": [
"awesome_dashboard/static/src/**/*",
],
"awesome_dashboard.dashboard": [
"awesome_dashboard/static/src/dashboard/**/*",
],
},
'license': 'AGPL-3'
"license": "AGPL-3",
}
70 changes: 70 additions & 0 deletions awesome_dashboard/i18n/hi_IN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * awesome_dashboard
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-06-24 12:17+0000\n"
"PO-Revision-Date: 2025-06-24 12:17+0000\n"
"Last-Translator: \n"
"Language-Team: Hindi\n"
"Language: hi\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: awesome_dashboard
#. odoo-javascript
#: code:addons/awesome_dashboard/static/src/dashboard/dashboardSetting/dashboard_setting.xml:0
msgid "Apply"
msgstr "लागू करें"

#. module: awesome_dashboard
#: model:ir.ui.menu,name:awesome_dashboard.menu_root
msgid "Awesome Dashboard"
msgstr "ऑसम डैशबोर्ड"

#. module: awesome_dashboard
#. odoo-javascript
#: code:addons/awesome_dashboard/static/src/dashboard/dashboardSetting/dashboard_setting.xml:0
msgid "Cancel"
msgstr "रद्द करें"

#. module: awesome_dashboard
#. odoo-javascript
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard.xml:0
msgid "Customers"
msgstr "ग्राहक"

#. module: awesome_dashboard
#: model:ir.actions.client,name:awesome_dashboard.dashboard
#: model:ir.ui.menu,name:awesome_dashboard.dashboard_menu
msgid "Dashboard"
msgstr "डैशबोर्ड"

#. module: awesome_dashboard
#. odoo-javascript
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard.xml:0
msgid "Dashboard Settings"
msgstr "डैशबोर्ड सेटिंग्स"

#. module: awesome_dashboard
#. odoo-javascript
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard.xml:0
msgid "Leads"
msgstr "लीड्स"

#. module: awesome_dashboard
#. odoo-javascript
#: code:addons/awesome_dashboard/static/src/dashboard/piechartcard/piechartcard.xml:0
msgid "Loading chart..."
msgstr "चार्ट लोड हो रहा है..."

#. module: awesome_dashboard
#. odoo-javascript
#: code:addons/awesome_dashboard/static/src/dashboard/dashboardSetting/dashboard_setting.xml:0
msgid "Select items to display on your dashboard:"
msgstr "अपने डैशबोर्ड पर प्रदर्शित करने के लिए आइटम चुनें:"
1 change: 1 addition & 0 deletions awesome_dashboard/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_users
21 changes: 21 additions & 0 deletions awesome_dashboard/models/res_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from odoo import fields, models, api


class ResUsers(models.Model):
_inherit = "res.users"

dashboard_disabled_items = fields.Char(default="")

@api.model
def set_dashboard_settings(self, disable_item_ids):
if self.env.user:
items = ",".join(map(str, disable_item_ids))
self.env.user.sudo().write({"dashboard_disabled_items": items})
return True
return False

@api.model
def get_dashboard_settings(self):
if self.env.user and self.env.user.dashboard_disabled_items:
return self.env.user.dashboard_disabled_items.split(",")
return []
10 changes: 0 additions & 10 deletions awesome_dashboard/static/src/dashboard.js

This file was deleted.

8 changes: 0 additions & 8 deletions awesome_dashboard/static/src/dashboard.xml

This file was deleted.

81 changes: 81 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { Component, useState, onWillStart } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { Layout } from "@web/search/layout";
import { useService } from "@web/core/utils/hooks";
import { DashboardItem } from "./dashboardItem/dashboard_item";
import { Piechart } from "./pieChart/pieChart";
import { DashboardSettings } from "./dashboardSetting/dashboard_setting";
import { rpc } from "@web/core/network/rpc";

class AwesomeDashboard extends Component {
static template = "awesome_dashboard.AwesomeDashboard";
static components = { Layout, DashboardItem, Piechart };

setup() {
const dashboardItemsRegistryData = registry.category("awesome_dashboard");
this.action = useService("action");
this.items = dashboardItemsRegistryData.getAll();
this.statisticServices = useService("awesome_dashboard.statistics");
this.state = useState({ statistic: this.statisticServices.statistic });
this.dialogService = useService("dialog");
this.displayData = useState({
disabledItems: [],
isLoading: true,
});
onWillStart(async () => {
try {
// this.displayData.isLoading = true;
const fetchedDisabledItems = await rpc(
"/web/dataset/call_kw/res.users/get_dashboard_settings",
{
model: "res.users",
method: "get_dashboard_settings",
args: [],
kwargs: {},
}
);
this.displayData.disabledItems = fetchedDisabledItems;
} catch (error) {
console.error(
"Error loading initial dashboard settings from server:",
error
);
this.displayData.disabledItems = [];
} finally {
this.displayData.isLoading = false;
}
});
}
openCustomers() {
this.action.doAction("base.action_partner_form");
}

async openLeads(activity) {
this.action.doAction({
type: "ir.actions.act_window",
name: "Journal Entry",
target: "current",
res_id: activity.res_id,
res_model: "crm.lead",
views: [
[false, "list"],
[false, "form"],
],
});
}

updateConfiguration(newUncheckedItems) {
this.displayData.disabledItems.length = 0;
this.displayData.disabledItems.push(...newUncheckedItems);
}

openSetting() {
this.dialogService.add(DashboardSettings, {
items: this.items,
initialUncheckedItems: this.state.uncheckedItems,
updateConfiguration: this.updateConfiguration.bind(this),
});
}
}

registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard);
42 changes: 42 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.o_dashboard{
background-color: burlywood;
}

.o_dashboard_stat_block {
text-align: center;
margin-bottom: 24px;
}

.o_dashboard_stat_label {
font-weight: normal;
margin-bottom: 10px;
display: block;
}

.o_dashboard_stat_value {
font-size: 48px;
color: #228B22;
font-weight: bold;
}

.o_dashboard_item {
background: #fff;
border-radius: 0.75rem;
box-shadow: 0 2px 8px rgba(0,0,0,0.07);
padding: 1rem;
margin: 1rem;
display: inline-flex;
justify-content: center;
vertical-align: top;
min-height: 3rem;
}

@media (max-width: 426px) {
.o_dashboard_item {
width: 100% !important;
display: flex;
margin-left: 0.5rem;
margin-right: 0.5rem;
box-sizing: border-box;
}
}
25 changes: 25 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

<t t-name="awesome_dashboard.AwesomeDashboard">
<Layout display="{controlPanel: {}}" className="'o_dashboard h-100'">
<t t-set-slot="control-panel-create-button">
<button t-on-click="openCustomers" type="button" class="btn btn-primary" title="Customers">Customers</button>
<button t-on-click="openLeads" type="button" class="btn btn-primary" title="Customers">Leads</button>
</t>
<t t-set-slot="control-panel-additional-actions">
<button class="btn btn-light" title="Dashboard Settings" t-on-click="openSetting">
<i class="fa fa-cog"></i>
</button>
</t>
<div class="d-flex flex-wrap">
<t t-foreach="items" t-as="item" t-key="item.id">
<DashboardItem t-if="(displayData.disabledItems || []).includes(item.id) === false" size="item.size || 1">
<t t-set="itemProp" t-value="item.props ? item.props(this.state.statistic) : {'data': this.state.statistic}"/>
<t t-component="item.Component" t-props="itemProp" />
</DashboardItem>
</t>
</div>
</Layout>
</t>
</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component } from "@odoo/owl";
export class DashboardItem extends Component {
static template = "awesome_dashboard.DashboardItem";
static props = {
slots: {
type: Object,
shape: { default: true },
},
size: {
type: Number,
default: 1,
optional:true
},
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.DashboardItem">
<div t-attf-class="o_dashboard_item"
t-attf-style="width: #{18 * itemSize}rem; background: #fff; border-radius: 0.75rem; box-shadow: 0 2px 8px rgba(0,0,0,0.07); padding: 1rem; margin: 1rem; display: inline-flex; justify-content: center; vertical-align: top; min-height: 3rem;">
<div class="card-body">
<t t-slot="default"/>
</div>
</div>
</t>
</templates>
Loading