Skip to content

[ADD] first commit #1

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

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
37a398d
[ADD] first commit
hsal-odoo Feb 19, 2024
6bca354
[IMP] estate: Added first model
hsal-odoo Feb 19, 2024
64cc874
[IMP] estate: Added access rights to the model estate.property
hsal-odoo Feb 19, 2024
0d5c7c0
[IMP] estate: Used Pep8 auto formatter
hsal-odoo Feb 20, 2024
6e180d3
[FIX] estate: fixed the name having _ instead of .
hsal-odoo Feb 20, 2024
a1d6c0a
[IMP] estate: chapter 6 views and menus
hsal-odoo Feb 20, 2024
7a96d68
[IMP] estate: Chapter 7 tree, form, and search views
hsal-odoo Feb 21, 2024
6da3aa8
[IMP] estate: Added estate property type model
hsal-odoo Feb 21, 2024
6d66869
[IMP] estate: Added property type to tree and search views
hsal-odoo Feb 21, 2024
50711ef
[IMP] estate: Added buyer and salesman to property model
hsal-odoo Feb 21, 2024
5c3cad2
[IMP] estate: Added estate tag model
hsal-odoo Feb 21, 2024
882d38c
[FIX] estate: fixed xml styling and a single Group by condition
hsal-odoo Feb 21, 2024
0ac8df0
[IMP] estate: Added offers to properties
hsal-odoo Feb 21, 2024
82b24e4
[IMP] estate: added total area field to property model
hsal-odoo Feb 22, 2024
ab89e3d
[IMP] estate: Added best price field
hsal-odoo Feb 22, 2024
f7d8204
[IMP] estate: Added offer validity and deadline
hsal-odoo Feb 22, 2024
4745211
[IMP] estate: Added onchange method of garden field
hsal-odoo Feb 22, 2024
7afb5c3
[FIX] estate: fixed a problem in maximum offer computation
hsal-odoo Feb 22, 2024
d84c9f0
[IMP] estate: Added buttons to property and property offer
hsal-odoo Feb 22, 2024
0242796
[IMP] estate: Added a button to go to property types from prpoerty form
hsal-odoo Feb 22, 2024
e355601
[IMP] estate: Added SQL constraints on the existing models
hsal-odoo Feb 22, 2024
33bd4a9
[IMP] estate: Added python constraints
hsal-odoo Feb 22, 2024
ede8bdd
[IMP] estate: Added inline tree and status bar
hsal-odoo Feb 22, 2024
7e12a90
[IMP] estate: Added oder to all models
hsal-odoo Feb 22, 2024
64ed349
[IMP] estate: tested manual and view ordering
hsal-odoo Feb 22, 2024
70088ab
[IMP] estate: Added colors and no_create options
hsal-odoo Feb 22, 2024
4d4c82d
[IMP] estate: Added some invisible and readonly conditions
hsal-odoo Feb 22, 2024
ee287e9
[IMP] estate: Finished chapter 12
hsal-odoo Feb 22, 2024
a2a8a32
[IMP] estate: Added create and ondelete methods
hsal-odoo Feb 23, 2024
309de50
[FIX] estate: made the py files more organized
hsal-odoo Feb 23, 2024
66fa09e
[FIX] estate: ordered imports
hsal-odoo Feb 23, 2024
c2c00cf
[FIX] estate: made the code more concise
hsal-odoo Feb 23, 2024
0cfad4c
[IMP] estate: Added users properties
hsal-odoo Feb 23, 2024
c0b989e
[FIX] estate: fixed attribute
hsal-odoo Feb 23, 2024
8100064
[ADD] estate_account: Added new module
hsal-odoo Feb 23, 2024
6fbccb4
[FIX] estate: removed wrong store attribute
hsal-odoo Feb 23, 2024
90be25d
[FIX] estate_account: fixed estate account module not working
hsal-odoo Feb 23, 2024
5c2d7f6
[FIX] estate: fixed wrong logic of offer creation
hsal-odoo Feb 23, 2024
a0d0f00
[IMP] estate_account: Added invoice and invoice line creation
hsal-odoo Feb 23, 2024
d66c302
[IMP] estate: Added property kanban view
hsal-odoo Feb 23, 2024
8fa2227
[IMP] awesome_owl: Added card and counter components
hsal-odoo Feb 26, 2024
b8a692f
[IMP] awesome_owl: Used markup and explored t-out vs t-esc
hsal-odoo Feb 26, 2024
7d8f285
[IMP] awesome_owl: experimented props
hsal-odoo Feb 26, 2024
5ca5156
[IMP] awesome_owl: added todos
hsal-odoo Feb 26, 2024
ccb9d71
[IMP] awesome_owl: added todos new files
hsal-odoo Feb 26, 2024
1af69d9
[IMP] awesome_owl: dynamic todos
hsal-odoo Feb 26, 2024
4718470
[IMP] awesome_owl: auto focus and toggle state
hsal-odoo Feb 26, 2024
5d1eaad
[IMP] awesome_owl: delete todo item implemented
hsal-odoo Feb 26, 2024
c9e7519
[IMP] awesome_owl: Finished chapter 1 of the JS tutorial
hsal-odoo Feb 26, 2024
6322d17
[FIX] estate: fixed missing invoice line and default float value
hsal-odoo Feb 27, 2024
08ee6f1
[IMP] awesome_dashboard: Added initial dashboard view
hsal-odoo Feb 27, 2024
9747fa1
[IMP] awesome_dashboard: Added buttons Customers and leads
hsal-odoo Feb 27, 2024
9ee4d8e
[IMP] awesome_dashboard: Added dashboard_item
hsal-odoo Feb 27, 2024
52c9085
[IMP] awesome_dashboard: Added dashboard statistics
hsal-odoo Feb 28, 2024
4e0d841
[IMP] awesome_dashboard: cached network calls
hsal-odoo Feb 28, 2024
7cf8897
[FIX] awesome_dashboard: fixed directory name
hsal-odoo Feb 28, 2024
c3c19d8
[IMP] awesome_dashboard: Added pie chart
hsal-odoo Feb 28, 2024
9a5d46b
[IMP] awesome_dashboard: made the dashboard update every 10 mins
hsal-odoo Feb 28, 2024
280a552
[IMP] awesome_dashboard: Added lazy loading of the dashboard
hsal-odoo Feb 28, 2024
ead8d51
[FIX] awesome_dashboard: fixed loadJS not working properly from the f…
hsal-odoo Feb 28, 2024
21b2607
[FIX] awesome_dashboard: Made the dashboard generic
hsal-odoo Feb 28, 2024
2c8a425
[IMP] awesome_dashboard: made the dashboard extinsible
hsal-odoo Feb 28, 2024
0d5d941
[IMP] awesome_dashboard: Added dashboard dialog
hsal-odoo Feb 29, 2024
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
4 changes: 4 additions & 0 deletions awesome_dashboard/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
'assets': {
'web.assets_backend': [
'awesome_dashboard/static/src/**/*',
('remove', 'awesome_dashboard/static/src/dashboard/**/*'),
],
'awesome_dashboard.dashboard': [
'awesome_dashboard/static/src/dashboard/**/*',
]
},
'license': 'AGPL-3'
}
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.

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

import { useService } from "@web/core/utils/hooks";
import { Component, useState } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { Layout } from "@web/search/layout";
import { DashboardItem } from "../dashboard_item/dashboard_item";
import { PieChart } from "../pie_chart/pie_chart";
import { browser } from "@web/core/browser/browser";
import { DashboardDialog } from "./dashboard_dialog/dashboard_dialog";

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

setup() {
this.action = useService("action");
this.rpc = useService("rpc");
this.stats_service = useService("awesome_dashboard.statistics");
this.stats = useState(this.stats_service.load());
this.items = registry.category("awesome_dashboard_items").get("items");
this.dialog = useService("dialog");
this.state = useState({ uncheckedItems: browser.localStorage.getItem("uncheckedItems")?.split(",") || [], });
}

openConfiguration() {
this.dialog.add(DashboardDialog, {
items: this.items,
uncheckedItems: this.state.uncheckedItems,
updateConfiguration: this.updateConfiguration.bind(this),
});
}

updateConfiguration(uncheckedItems) {
this.state.uncheckedItems = uncheckedItems;
}

showCustomers() {
this.action.doAction("base.action_partner_form");
}

showLeads() {
this.action.doAction({
type: "ir.actions.act_window",
name: "Leads",
res_model: "crm.lead",
views: [
[false, "tree"],
[false, "form"],
],
});
}
}

registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard);
3 changes: 3 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.o_dashboard {
background-color: gray;
}
21 changes: 21 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

<t t-name="awesome_dashboard.AwesomeDashboard">
<button t-on-click="showCustomers" class="btn-primary m-1 rounded">Customers</button>
<button t-on-click="showLeads" class="btn-primary m-1 rounded">Leads</button>
<button class="btn btn-link" icon="fa fa-gear" t-on-click="openConfiguration">
<i class="fa fa-cog"/>
</button>

<Layout className="'o_dashboard h-100'" display="{controlPanel: {}}">
<t t-foreach="items" t-as="item" t-key="item.id">
<DashboardItem t-if="!this.state.uncheckedItems.includes(item.id)" size="item.size || 1">
<t t-esc="item.title"/>
<t t-component="item.Component" t-props="item.extract(stats)" />
</DashboardItem>
</t>
</Layout>
</t>

</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/** @odoo-module **/

import { Component, useState } from "@odoo/owl";
import { Dialog } from "@web/core/dialog/dialog";
import { CheckBox } from "@web/core/checkbox/checkbox";
import { browser } from "@web/core/browser/browser";

export class DashboardDialog extends Component {
static template = "awesome_dashboard.DashboardDialog";
static components = { Dialog, CheckBox };

setup() {
this.items = useState(
this.props.items.map((item) => ({
...item,
checked: !this.props.uncheckedItems.includes(item.id),
}))
);
}

done() {
this.props.close();
}

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

browser.localStorage.setItem("uncheckedItems", newUncheckedItems);
this.props.updateConfiguration(newUncheckedItems);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.DashboardDialog">
<Dialog title="'Dashboard Items Dialog'">
<t t-foreach="items" t-as="item" t-key="item.id">
<CheckBox value="item.checked" onChange="(ev) => this.onChange(ev, item)">
<t t-esc="item.title"/>
</CheckBox>
</t>

<t t-set-slot="footer">
<button class="btn btn-primary" t-on-click="done">
Done
</button>
</t>
</Dialog>
</t>
</templates>
62 changes: 62 additions & 0 deletions awesome_dashboard/static/src/dashboard/dashboard_items.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/** @odoo-module **/

import { PieChartCard } from "../pie_chart_card/pie_chart_card";
import { NumberCard } from "../number_card/number_card";
import { registry } from "@web/core/registry";

const items = [
{
id: 0,
size: 1.5,
Component: NumberCard,
title: 'Average amount of t-shirt by order this month',
extract: (data) => ({
value: data.average_quantity,
}),
},
{
id: 1,
size: 2,
Component: NumberCard,
title: 'Average time for an order to go from "new" to "sent" or "cancelled"',
extract: (data) => ({
value: data.average_time,
}),
},
{
id: 2,
size: 1,
Component: NumberCard,
title: 'Number of new orders this month',
extract: (data) => ({
value: data.nb_new_orders,
}),
},
{
id: 3,
size: 1,
Component: NumberCard,
title: 'Number of cancelled orders this month',
extract: (data) => ({
value: data.nb_cancelled_orders,
}),
},
{
id: 4,
Component: NumberCard,
title: 'Total amount of new orders this month',
extract: (data) => ({
value: data.total_amount,
}),
},
{
id: 5,
Component: PieChartCard,
title: 'Shirt orders by size',
extract: (data) => ({
value: data.orders_by_size,
}),
},
];

registry.category("awesome_dashboard_items").add("items", items);
27 changes: 27 additions & 0 deletions awesome_dashboard/static/src/dashboard/stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** @odoo-module **/

import { reactive } from "@odoo/owl";
import { registry } from "@web/core/registry";

const statistics_service = {
dependencies: ["rpc"],
start(env, { rpc }) {
let stats = reactive({});

async function updateStats() {
let data = await rpc("/awesome_dashboard/statistics");
Object.assign(stats, data);
};

updateStats();
setInterval(updateStats, 60 * 1000 * 10);

return {
load() {
return stats;
},
};
},
};

registry.category("services").add("awesome_dashboard.statistics", statistics_service);
12 changes: 12 additions & 0 deletions awesome_dashboard/static/src/dashboard_action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @odoo-module **/

import { LazyComponent } from "@web/core/assets";
import { registry } from "@web/core/registry";
import { Component } from "@odoo/owl";

class DashboardAction extends Component {
static components = { LazyComponent };
static template = "awesome_dashboard.DashboardAction";
}

registry.category("actions").add("awesome_dashboard.dashboard", DashboardAction);
6 changes: 6 additions & 0 deletions awesome_dashboard/static/src/dashboard_action.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.DashboardAction">
<LazyComponent bundle="'awesome_dashboard.dashboard'" Component="'AwesomeDashboard'" props="props"/>
</t>
</templates>
9 changes: 9 additions & 0 deletions awesome_dashboard/static/src/dashboard_item/dashboard_item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @odoo-module **/

import { Component } from "@odoo/owl";

export class DashboardItem extends Component {
static template = "awesome_dashboard.DashboardItem";
static defaultProps = { size: 1, };
static props = { size: { type: Number, optional: true, }, };
}
12 changes: 12 additions & 0 deletions awesome_dashboard/static/src/dashboard_item/dashboard_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

<t t-name="awesome_dashboard.DashboardItem">
<div class="card d-inline-block m-2" t-attf-style="width: {{ 18*this.props.size }}rem;">
<div class="card-body">
<t t-slot="default"/>
</div>
</div>
</t>

</templates>
10 changes: 10 additions & 0 deletions awesome_dashboard/static/src/number_card/number_card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @odoo-module **/

import { Component } from "@odoo/owl";

export class NumberCard extends Component {
static template = "awesome_dashboard.NumberCard";
static props = {
value: { required: true, },
};
}
10 changes: 10 additions & 0 deletions awesome_dashboard/static/src/number_card/number_card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

<t t-name="awesome_dashboard.NumberCard">
<p class="h1 text-success text-center">
<t t-esc="props.value"/>
</p>
</t>

</templates>
42 changes: 42 additions & 0 deletions awesome_dashboard/static/src/pie_chart/pie_chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** @odoo-module **/

import { Component, onWillStart, onWillUnmount, useEffect, useRef } from "@odoo/owl";
import { loadJS } from "@web/core/assets";

export class PieChart extends Component {
static template = "awesome_dashboard.PieChart";
static props = {
data: { required: true, },
};

setup() {
this.canvasRef = useRef("canvas");


onWillStart(async () => {
await loadJS("/web/static/lib/Chart/Chart.js");
});

useEffect(() => {
this.destroyChart();

this.chart = new Chart(this.canvasRef.el, {
type: 'pie',
data: {
labels: Object.keys(this.props.data),
datasets: [{
data: Object.values(this.props.data),
}],
},
});
});

onWillUnmount(this.destroyChart);
}

destroyChart() {
if (this.chart) {
this.chart.destroy();
}
}
}
6 changes: 6 additions & 0 deletions awesome_dashboard/static/src/pie_chart/pie_chart.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.PieChart">
<canvas t-ref="canvas" />
</t>
</templates>
12 changes: 12 additions & 0 deletions awesome_dashboard/static/src/pie_chart_card/pie_chart_card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @odoo-module **/

import { Component } from "@odoo/owl";
import { PieChart } from "../pie_chart/pie_chart";

export class PieChartCard extends Component {
static template = "awesome_dashboard.PieChartCard";
static props = {
value: { required: true, },
};
static components = { PieChart };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_dashboard.PieChartCard">
<PieChart data="props.value"/>
</t>
</templates>
Loading