Skip to content

[ADD] estate: Real Estate Property Management Module #889

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 12 commits into
base: 18.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 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
13 changes: 13 additions & 0 deletions awesome_owl/static/src/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component } from "@odoo/owl";

export class Card extends Component {
static template = "awesome_owl.Card"
static props = {
title: {
type: String,
},
content: {
type: String,
}
}
}
15 changes: 15 additions & 0 deletions awesome_owl/static/src/card/card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_owl.Card">
<div class="card d-inline-block m-2" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">
<t t-esc="props.title"/>
</h5>
<p class="card-text">
<t t-out="props.content"/>
</p>
</div>
</div>
</t>
</templates>
25 changes: 25 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Component, useState } from "@odoo/owl";

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

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

increment() {
this.state.value++;
if (this.props.onChange) {
this.props.onChange();
}
}
}
11 changes: 11 additions & 0 deletions awesome_owl/static/src/counter/counter.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.Counter">
<div class="d-flex align-items-center border p-4 gap-4">
<p class="mb-0">
<t t-esc="props.title"/>: <t t-esc="state.value"></t>
</p>
<button class="btn btn-primary text-white" style="background: #714b67" t-on-click="increment">Increment</button>
</div>
</t>
</templates>
16 changes: 15 additions & 1 deletion awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
/** @odoo-module **/

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 components = { Counter, Card, TodoList }
html = ('<h3>hello world</h3>');
markup_html = markup(this.html);

setup() {
this.state = useState({ sum: 2 });
}

incrementSum() {
this.state.sum++;
}
}
24 changes: 22 additions & 2 deletions awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,28 @@
<templates xml:space="preserve">

<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
<div class="d-flex justify-content-center">
<div class="border m-5">
<div class="d-flex gap-4 p-3" style="max-width: fit-content;">
<Counter title="'Counter 1'" onChange.bind="incrementSum"/>
<Counter title="'Counter 2'" onChange.bind="incrementSum"/>
</div>
<p class="ms-3">Sum is: <t t-esc="state.sum"></t></p>
</div>

<!-- Card Component -->
<div class="p-3 border m-5" style="max-width: fit-content;">
<h1>Cards</h1>
<div class="d-flex gap-3">
<Card title="'Gandhinagar'" content="html"/>
<Card title="'Ahmedabad'" content="markup_html"/>
</div>
</div>
</div>

<!-- Todo List Component -->
<div class="mt-5">
<TodoList/>
</div>
</t>

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

export class TodoItem extends Component {
static template = "awesome_owl.TodoItem";
static props = {
todo: {
type: Object,
shape: {
id: Number,
description: String,
isCompleted: Boolean,
}
},
toggleTaskState: {
type: Function,
},
taskDelete: {
type: Function,
}

}

toggleTaskState() {
this.props.toggleTaskState(this.props.todo.id);
}

taskDelete() {
this.props.taskDelete(this.props.todo.id);
}
}
13 changes: 13 additions & 0 deletions awesome_owl/static/src/todo/todo_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="awesome_owl.TodoItem">
<div class="d-flex align-items-center gap-2">
<input t-att-id="props.todo.id" type="checkbox" class="form-check-input mb-2" t-att-checked="props.todo.isCompleted" t-on-change="toggleTaskState"/>
<div class="d-flex mb-1 p-1 ps-2 flex-grow-1" t-att-for="props.todo.id" t-att-style="!props.todo.isCompleted ? 'border-radius: 8px; background: #eaeaea;' : ''" t-att-class="{'text-muted text-decoration-line-through': props.todo.isCompleted}">
<span class="pe-2" style="border-right: 1px solid #999;"><t t-esc="props.todo.id"></t>.</span>
<span class="ms-2"><t t-esc="props.todo.description"></t></span>
</div>
<span class="fa fa-trash-o text-danger mb-2" t-on-click="taskDelete"/>
</div>
</t>
</templates>
38 changes: 38 additions & 0 deletions awesome_owl/static/src/todo/todo_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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 components = { TodoItem }
id = 1;

setup () {
this.todos = useState([]);
useAutoFocus();
}

addTask(event) {
const { target: { value }, keyCode } = event;
if (keyCode != 13 || !value.trim()) return;
this.todos.push({
id: this.id++,
description: value,
isCompleted: false,
});
event.target.value = '';
}

toggleTaskState(todo_id) {
const task = this.todos.find((t) => t.id === todo_id);
if (!task) return;
task.isCompleted = !task.isCompleted;
}

taskDelete(todo_id) {
const taskIndex = this.todos.findIndex((t) => t.id === todo_id)
if (taskIndex >= 0) {
this.todos.splice(taskIndex, 1);
}
}
}
12 changes: 12 additions & 0 deletions awesome_owl/static/src/todo/todo_list.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_owl.TodoList">
<div class="border p-2 m-5" style="width: 400px;">
<h3 class="mb-3">Todo List</h3>
<input id="task-entry" placeholder="Enter a new task" class="form-control mb-3" t-on-keyup="addTask" t-ref="focus-input"></input>
<t t-foreach="todos" t-as="todo" t-key="todo.id">
<TodoItem todo="todo" toggleTaskState.bind="toggleTaskState" taskDelete.bind="taskDelete"/>
</t>
</div>
</t>
</templates>
8 changes: 8 additions & 0 deletions awesome_owl/static/src/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useRef, onMounted } from "@odoo/owl";

export const useAutoFocus = () => {
const inputRef = useRef("focus-input");
onMounted(() => {
inputRef.el?.focus();
})
}
Copy link

Choose a reason for hiding this comment

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

Should be one empty line at the end of the file.

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
21 changes: 21 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
'name': 'Real Estate',
'description': 'Real Estate Application.',
'summary': 'Real Estate Application for beginner.',
'depends': ['base'],
'author': 'Aaryan Parpyani (aarp)',
'category': 'Tutorials/RealEstate',
'version': '1.0',
'application': True,
'installable': True,
'license': 'LGPL-3',
'data': [
'views/estate_property_offer_views.xml',
'views/estate_property_type_views.xml',
'views/estate_property_tags_views.xml',
'views/res_users_views.xml',
'views/estate_property_views.xml',
'views/estate_menus_views.xml',
'security/ir.model.access.csv',
]
}
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 inherited_user
Loading