Skip to content
Draft
Show file tree
Hide file tree
Changes from 16 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
32 changes: 32 additions & 0 deletions awesome_dashboard/static/src/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
import { Component } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { Layout } from "@web/search/layout";
import { useService } from "@web/core/utils/hooks";

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

setup() {
this.action = useService("action");
}

openCustomers() {
this.action.doAction({
type: "ir.actions.act_window",
name: "Customers",
res_model: "res.partner",
views: [
[false, "kanban"],
[false, "form"],
[false, "list"],
],
});
}

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

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

Choose a reason for hiding this comment

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

unnecessary diff.

<t t-name="awesome_dashboard.AwesomeDashboard">
hello dashboard
<Layout className="'o_dashboard h-100'" display="{ controlPanel: {} }">
<t t-set-slot="control-panel-always-buttons">
<button class="btn btn-primary me-2" t-on-click="openCustomers">
Customers
</button>
<button class="btn btn-primary me-2" t-on-click="openLeads">
Leads
</button>
</t>
</Layout>
</t>

Choose a reason for hiding this comment

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

unnecessary diff.

</templates>
23 changes: 23 additions & 0 deletions awesome_owl/static/src/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, useState } from "@odoo/owl";


export class Card extends Component {
static template = "awesome_owl.card";
static props = {
title: String,
slots: {
type: Object,
shape: {
default: {}
}
}
};

setup() {
this.state = useState({visible: true})
}

toggleContent() {
this.state.visible = !this.state.visible;
}
}
21 changes: 21 additions & 0 deletions awesome_owl/static/src/card/card.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_owl.card">
<style>
.card-main{
display: block;
border: 1px solid #ccc;
padding: 20px;
}
</style>
<button t-on-click="toggleContent">toggle visibility</button>
<div class="card-main">
<h2 class="card-title" t-esc="props.title"></h2>
<t t-if="this.state.visible">
<div class="card-body">
<t t-slot="default"/>
</div>

Choose a reason for hiding this comment

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

Wrong indentation.

</t>
</div>
</t>
</templates>
29 changes: 29 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, useState } from "@odoo/owl";


export class Counter extends Component {
static template = "awesome_owl.Counter";
static props = {
onChange: {
type: Function,
}
};

setup() {
this.state = useState({ value: 0 });
}

increment() {
this.state.value++;
if (this.props.onChange) {
this.props.onChange(this.state.value,true);
}
}

decrement() {
this.state.value--;
if (this.props.onChange) {
this.props.onChange(this.state.value,false);
}
}
}
37 changes: 37 additions & 0 deletions awesome_owl/static/src/counter/counter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="awesome_owl.Counter">
<style>
.primary-counter{
background-color: #FFFFE0;
border: 3px solid #ccc;
display: inline-block;
min-width: 300px;
padding: 20px;
margin: 20px;
}
.increment-button{
background: purple;
color: white;
padding: 8px;
border-radius: 5px;
}
.decrement-button{
background: purple;
color: white;
padding: 8px;
border-radius: 5px;
margin:5px
}
</style>
<div class="primary-counter">
<p>Counter: <t t-esc="state.value"/></p>
<button class="increment-button" t-on-click="increment">
Increment
</button>

Choose a reason for hiding this comment

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

same.

<button class="decrement-button" t-on-click="decrement">
Decrement
</button>
</div>
</t>
</templates>
23 changes: 22 additions & 1 deletion awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
import { Component } from "@odoo/owl";
import { Component, useState, markup } from "@odoo/owl";
import { Counter } from "./counter/counter";
import { Card } from "./card/card";
import { TodoList } from "./todo/todo_list";


export class Playground extends Component {
static template = "awesome_owl.playground";
static props = {};
static components = { Counter, Card, TodoList };

setup() {
this.state = useState({
content: markup('<h1>Welcome to dashboard</h1>'),
sum: 0,
});

}

totalSum(newVal,Checker){

Choose a reason for hiding this comment

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

Suggested change
totalSum(newVal,Checker){
totalSum(newVal,Checker) {

if(Checker)

Choose a reason for hiding this comment

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

Suggested change
if(Checker)
if (Checker) {

this.state.sum++;
else
this.state.sum--;
}
}
21 changes: 17 additions & 4 deletions awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

Choose a reason for hiding this comment

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

unnecessary diff.

<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
<t t-out="this.state.content"/>
<Counter onChange.bind="totalSum"/>
<Counter onChange.bind="totalSum"/>
<Counter onChange.bind="totalSum"/>
<div style="background-color: #90EE90; border: 3px solid #ccc; margin: 20px; padding: 20px">
<h3>Sum of Counters: <t t-esc="state.sum"/></h3>
</div>
<TodoList/>
<div>
<Card title="'Card with text'">
<p>This is arbitrary card content!</p>
</Card>
</div>
<div>
<Card title="'Card with a counter'">
<Counter onChange.bind="totalSum"/>
</Card>
</div>
</t>

Choose a reason for hiding this comment

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

unnecessary diff.

</templates>
19 changes: 19 additions & 0 deletions awesome_owl/static/src/todo/todo_item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component } from "@odoo/owl";


export class TodoItem extends Component {
static template = "awesome_owl.TodoItem";
static props = {
todo: Object,
toggleState: Function,
deleteTodo: Function,
};

onChangeToggle() {
this.props.toggleState(this.props.todo.id);
}

onChangeDelete() {
this.props.deleteTodo(this.props.todo.id);
}
}
11 changes: 11 additions & 0 deletions awesome_owl/static/src/todo/todo_item.xml
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_owl.TodoItem">
<div class="p-1" t-att-class="props.todo.isCompleted ? 'text-decoration-line-through text-muted' : ''">
<input class="form-check-input" type="checkbox" t-on-click="onChangeToggle"/>

Choose a reason for hiding this comment

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

indentation issue.

<span t-esc="props.todo.id"/> -
<span t-esc="props.todo.description"/>
<span style="margin-left:10px; cursor:pointer;" t-on-click="onChangeDelete">❌</span>
</div>
</t>
</templates>
40 changes: 40 additions & 0 deletions awesome_owl/static/src/todo/todo_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Component, useState } from "@odoo/owl";
import { TodoItem } from "./todo_item";
import { useAutofocus } from './../utils'


export class TodoList extends Component {
static template = "awesome_owl.TodoList";
static props = {};
static components = { TodoItem };

setup() {
this.todos = useState([])
useAutofocus('todoInputRef')
}

addTodo(ev) {
if(ev.keyCode == '13') {
if(ev.target.value != ""){
this.todos.push({
id: this.todos.length + 1,
description: ev.target.value,
isCompleted: false
})
ev.target.value = ''
}
}
}

toggleState(id) {
const todo = this.todos.find(todo => todo.id == id)
todo.isCompleted = !todo.isCompleted
}

deleteTodo(id) {
const index = this.todos.findIndex(todo => todo.id === id)
if (index >= 0){
this.todos.splice(index, 1)
}
}
}
26 changes: 26 additions & 0 deletions awesome_owl/static/src/todo/todo_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_owl.TodoList">
<style>
.todo-list-primary{
background-color: #ADD8E6;
border: 3px solid #ccc;
display: inline-block;
min-width: 300px;
padding: 20px;
margin: 20px;
}
.todo-item-arrangement{
padding: 20px;
margin: 20px;
}
</style>
<div class="todo-list-primary">
<h3>Todo List</h3>
<input type="text" t-ref="todoInputRef" placeholder="Enter a new task" t-on-keyup="addTodo" class="form-control mb-2"/>
<div t-foreach="todos" t-as="todo" t-key="todo.id" class="todo-item-arrangement">
<TodoItem todo="todo" toggleState.bind="toggleState" deleteTodo.bind="deleteTodo"/>
</div>
</div>
</t>
</templates>
13 changes: 13 additions & 0 deletions awesome_owl/static/src/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useRef, onMounted } from "@odoo/owl";


export function useAutofocus(refName) {
const ref = useRef(refName);

onMounted(() => {
if (ref.el) {
ref.el.focus();
}
});
return ref;
}
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
'author': 'Odoo S.A.',
'name': 'Estate',
'depends': ['base'],
'license': 'LGPL-3',
'data': [
'security/ir.model.access.csv',
'data/service_cron.xml',
'views/estate_property_views.xml',
'views/estate_property_offer_views.xml',
'views/estate_property_type_views.xml',
'views/estate_property_tag_views.xml',
'views/res_users_views.xml',
'views/estate_menus.xml'
],
'application': True,
'installable': True
}
11 changes: 11 additions & 0 deletions estate/data/service_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="ir_cron_auto_refuse_in_valid_entry" model="ir.cron">
<field name="name">Estate: Refuse Offer on passing deadline</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="model_id" ref="model_estate_property_offer"/>
<field name="code">model._cron_auto_refuse_pass_deadline_entry()</field>
<field name="state">code</field>
</record>
</odoo>
5 changes: 5 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import estate_property
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offer
from . import res_users
Loading