Skip to content

Commit c3096f6

Browse files
committed
[IMP] awesome_owl: added new layout, buttons and a dashboard item
-added a new layout -added some buttons for quick navigation -added a new dashboard item
1 parent 549c84e commit c3096f6

File tree

8 files changed

+76
-5
lines changed

8 files changed

+76
-5
lines changed
5.29 KB
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
11
import { Component } from "@odoo/owl";
22
import { registry } from "@web/core/registry";
3+
import { Layout } from "@web/search/layout";
4+
import { useService } from "@web/core/utils/hooks";
5+
import { DashboardItem } from "./dashboard_item/dashboard_item";
36

47
class AwesomeDashboard extends Component {
58
static template = "awesome_dashboard.AwesomeDashboard";
9+
static components = { Layout, DashboardItem };
10+
11+
setup() {
12+
this.action = useService("action");
13+
this.display = {
14+
controlPanel: {},
15+
};
16+
}
17+
18+
openCustomerView() {
19+
this.action.doAction("base.action_partner_form");
20+
}
21+
22+
openLeads() {
23+
this.action.doAction({
24+
type: "ir.actions.act_window",
25+
name: "All leads",
26+
res_model: "crm.lead",
27+
views: [
28+
[false, "list"],
29+
[false, "form"],
30+
],
31+
});
32+
}
633
}
734

835
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);

awesome_dashboard/static/src/dashboard.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22
<templates xml:space="preserve">
33

44
<t t-name="awesome_dashboard.AwesomeDashboard">
5-
hello dashboard
5+
<Layout display="display" className="'o_dashboard h-100'">
6+
<t t-set-slot="layout-buttons">
7+
<button class="btn btn-primary" t-on-click="openCustomerView">Customers</button>
8+
<button class="btn btn-primary" t-on-click="openLeads">Leads</button>
9+
</t>
10+
<div class="d-flex flex-wrap">
11+
<DashboardItem>
12+
some content
13+
</DashboardItem>
14+
<DashboardItem size="2">
15+
I love milk
16+
</DashboardItem>
17+
<DashboardItem>
18+
some content
19+
</DashboardItem>
20+
</div>
21+
</Layout>
622
</t>
723

824
</templates>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component } from "@odoo/owl";
2+
3+
export class DashboardItem extends Component {
4+
static template = "awesome_dashboard.DashboardItem"
5+
static props = {
6+
slots: {
7+
type: Object,
8+
shape: {
9+
default: Object
10+
},
11+
},
12+
size: {
13+
type: Number,
14+
default: 1,
15+
optional: true,
16+
},
17+
};
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
<t t-name="awesome_dashboard.DashboardItem">
4+
<div class="card m-2 border-dark" t-attf-style="width: {{18*props.size}}rem;">
5+
<div class="card-body">
6+
<t t-slot="default"/>
7+
</div>
8+
</div>
9+
</t>
10+
</templates>

estate/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
'name': 'Real Estate',
3-
'depends': ['base','sale'],
3+
'depends': ['base', 'sale'],
44
'application': True,
55
'installable': True,
66
'author': 'Odoo S.A.',

estate/models/estate_property_offer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def create(self, vals):
8080
for offer in records:
8181
offer.property_id.state = "offer_received"
8282
return records
83-
83+
8484
@api.model
8585
def _auto_refuse_pass_deadline_entry(self):
86-
current_date = fields.Date.today()+relativedelta(days=7)
86+
current_date = fields.Date.today() + relativedelta(days=7)
8787
invalid_offers = self.search([
8888
('date_deadline', '<=', current_date),
8989
('status', 'not in', ['accepted', 'refused']),

estate/models/sale_order.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
class SaleOrder(models.Model):
5-
_inherit="sale.order"
5+
_inherit = "sale.order"
66
property_type_id = fields.Many2one("estate.property")

0 commit comments

Comments
 (0)