Skip to content

[ADD] estate: added core functionality of Real Estate #826

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
3 changes: 3 additions & 0 deletions awesome_dashboard/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
'web.assets_backend': [
'awesome_dashboard/static/src/**/*',
],
'awesome_dashboard.dashboard': [
'awesome_dashboard/static/src/dashboard/**/*',
],
},
'license': 'AGPL-3'
}
80 changes: 80 additions & 0 deletions awesome_dashboard/i18n/hi_IN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# 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:25+0000\n"
"PO-Revision-Date: 2025-06-24 12:25+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. 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/dashboard_setting/dashboard_setting.xml:0
msgid "Cancel"
msgstr "रद्द करना"

#. module: awesome_dashboard
#. odoo-javascript
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard.xml:0
msgid "Customer"
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
#: model:ir.model.fields,field_description:awesome_dashboard.field_res_users__dashboard_disabled_items
msgid "Dashboard Disabled Items"
msgstr "डैशबोर्ड अक्षम आइटम"

#. module: awesome_dashboard
#. odoo-javascript
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard.xml:0
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard_setting/dashboard_setting.xml:0
msgid "Done"
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/dashboard_setting/dashboard_setting.xml:0
msgid "Select items to display on your dashboard:"
msgstr "अपने डैशबोर्ड पर प्रदर्शित करने के लिए आइटम चुनें:"

#. module: awesome_dashboard
#: model:ir.model,name:awesome_dashboard.model_res_users
msgid "User"
msgstr "उपयोगकर्ता"

#. module: awesome_dashboard
#. odoo-javascript
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard.xml:0
msgid "Which cards do you wish to see?"
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 models, fields, api


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

dashboard_disabled_items = fields.Char(string='Dashboard Disabled Items')

@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.

108 changes: 108 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/** @odoo-module **/

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 { PieChart } from "./piechart/piechart";
import { DashboardItem } from "./dashboarditem/dashboarditem";
import { PieChartCard } from "./piechartcard/piechartcard";
import { NumberCard } from "./numbercard/numbercard";
import { Dialog } from "@web/core/dialog/dialog";
import { CheckBox } from "@web/core/checkbox/checkbox";
import { browser } from "@web/core/browser/browser";
import { rpc } from "@web/core/network/rpc";

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

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

openCustomers(){
this.action.doAction("base.action_partner_form");
}
async openLeads(){
this.action.doAction({
type: "ir.actions.act_window",
res_model: "crm.lead",
views: [[false, "list"], [false, "form"]],
target: "current",
});
}
updateConfiguration(newDisabledItems) {
this.dialog_state.disabledItems = newDisabledItems;
}

openSetting() {
this.action.doAction("base_setup.action_general_configuration");
}
openConfiguration() {
this.dialog.add(ConfigurationDialog, {
items: this.items,
disabledItems: this.dialog_state.disabledItems,
onUpdateConfiguration: this.updateConfiguration.bind(this),
})
}
}

class ConfigurationDialog extends Component {
static template = "awesome_dashboard.ConfigurationDialog";
static components = { Dialog, CheckBox };
static props = ["close", "items", "disabledItems", "onUpdateConfiguration"];

setup() {
this.items = useState(this.props.items.map((item) => {
return {
...item,
enabled: !this.props.disabledItems.includes(item.id),
}
}))
}

onDone() {
this.props.close()
}

onChange(checked, changedItem) {
changedItem.enabled = checked;
const newDisabledItems = Object.values(this.items).filter(
(item) => !item.enabled
).map((item) => item.id)

browser.localStorage.setItem(
"disabledDashboardItems",
newDisabledItems,
);
this.props.onUpdateConfiguration(newDisabledItems);
}
}

registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard);
48 changes: 48 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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 type="button" class="btn btn-primary o-kanban-button-new" t-on-click="openCustomers">
Customer
</button>
<button type="button" class="btn btn-primary" t-on-click="openLeads">
Leads
</button>
<button type="button" class="btn btn-light" t-on-click="openConfiguration">
<i class="fa fa-cog"></i>
</button>
</t>
<div class="dashboard-items">
<div class="d-flex flex-wrap">
<t t-foreach="items" t-as="item" t-key="item.id">
<DashboardItem size="item.size || 1" t-if="!dialog_state.disabledItems.includes(item.id)">
<span class="o_dashboard_title_block">
<t t-set="itemProp"
t-value="item.props ? item.props(this.statistics) : {'data': this.statistics}"/>
</span>
<span class="o_dashboard_value_block">
<t t-component="item.Component" t-props="itemProp"/>
</span>
</DashboardItem>
</t>
</div>
</div>
</Layout>
</t>
<t t-name="awesome_dashboard.ConfigurationDialog">
<Dialog title="'Dashboard items configuration'">
Which cards do you wish to see?
<t t-foreach="items" t-as="item" t-key="item.id">
<CheckBox value="item.enabled" onChange="(ev) => this.onChange(ev, item)">
<t t-esc="item.description"/>
</CheckBox>
</t>
<t t-set-slot="footer">
<button class="btn btn-primary" t-on-click="onDone">
Done
</button>
</t>
</Dialog>
</t>
</templates>
72 changes: 72 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard_items.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/** @odoo-module **/

import { PieChartCard } from "./piechartcard/piechartcard";
import { NumberCard } from "./numbercard/numbercard";
import { registry } from "@web/core/registry";

export const items = [
{
id: "average_quantity",
description: "Average amount of t-shirt by order this month",
Component: NumberCard,
size: 1.5,
props: (data) => ({
title: "Average amount of t-shirt by order this month",
value: data.average_quantity,
}),
},
{
id: "average_time",
description: "Average time for an order to go from 'new' to 'sent' or 'cancelled'",
Component: NumberCard,
size: 1.2,
props: (data) => ({
title: "Avg. time: 'sent'/'cancelled'",
value: data.average_time,
}),
},
{
id: "nb_new_orders",
description: "Number of new orders this month",
Component: NumberCard,
size: 1,
props: (data) => ({
title: "New Orders This Month",
value: data.nb_new_orders,
}),
},
{
id: "nb_cancelled_orders",
description: "Number of cancelled orders this month",
Component: NumberCard,
size: 1.1,
props: (data) => ({
title: "Cancelled Orders This Month",
value: data.nb_cancelled_orders,
}),
},
{
id: "total_amount",
description: "Total amount of new orders this month",
Component: NumberCard,
size: 1.1,
props: (data) => ({
title: "Total New Order Amount ",
value: data.total_amount,
}),
},
{
id: "sales_distribution",
description: "Sales Distribution by T-Shirt Size",
Component: PieChartCard,
size: 1.5,
props: (data) => ({
title: "Sales Distribution by Size",
value: data.orders_by_size,
}),
},
];

items.forEach(item => {
registry.category("awesome_dashboard").add(item.id, item);
});
Loading