Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a6ca236
[ADD] estate: created the model and Initalized it with the postgre db
japat-odoo Dec 31, 2025
26ff004
[IMP] estate: done ui major search, list, form
japat-odoo Jan 1, 2026
dbcf3f0
[IMP] estate: improvement in the code structure
japat-odoo Jan 1, 2026
833d4f5
[IMP] estate: add property offer model and relations
japat-odoo Jan 2, 2026
7c49cc7
[IMP] estate: added computed fields
japat-odoo Jan 5, 2026
37413c2
[IMP] estate: add onchange and fix parseError
japat-odoo Jan 6, 2026
364860c
[IMP] estate: added property and offer state management
japat-odoo Jan 7, 2026
217814f
[IMP] estate: add SQL and Python constraints
japat-odoo Jan 8, 2026
e49fcb1
[IMP] estate: improve UI/UX with widgets, ordering, and conditional a…
japat-odoo Jan 12, 2026
115f009
[IMP] estate: add offer stat button on property types
japat-odoo Jan 15, 2026
68148e2
[FIX] estate: add missing imports for UserError and translation
japat-odoo Jan 16, 2026
7e4b9e3
[IMP] estate: implement business logic and extend res.users
japat-odoo Jan 19, 2026
8215c2c
[ADD] estate_account: create invoice when property is sold
japat-odoo Jan 21, 2026
58fd009
[IMP] estate: add kanban view for properties
japat-odoo Jan 24, 2026
9f970c7
[ADD] estate: add PDF report for property
japat-odoo Jan 27, 2026
905bd3a
[ADD] awesome_owl: implemented todo, card and counter
japat-odoo Feb 2, 2026
05e5fbd
[IMP] awesome_owl: add autofocus to todo input using useRef
japat-odoo Feb 3, 2026
aadbad3
[IMP] awesome_owl: implemented todo toggling and deletion
japat-odoo Feb 5, 2026
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
9 changes: 9 additions & 0 deletions awesome_owl/static/src/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Component } from "@odoo/owl";

export class Card extends Component {
static template = "awesome_owl.Card";
static props = {
title: String,
content: String,
};
}
13 changes: 13 additions & 0 deletions awesome_owl/static/src/card/card.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.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-esc="props.content"/>
</p>
</div>
</div>
</t>
</templates>
19 changes: 19 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component, useState } from "@odoo/owl";

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

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

increment() {
this.state.value = this.state.value + 1;
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="border p-3 m-2 d-inline-block">
<span class="me-2">Counter: <t t-esc="state.value"/></span>
<button class="btn btn-primary" t-on-click="increment">Increment</button>
</div>
</t>

</templates>
17 changes: 15 additions & 2 deletions awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import { Component } from "@odoo/owl";
import { markup, Component, useState } from "@odoo/owl";
import { Counter } from "./counter/counter";
import { Card } from "./card/card";
import { TodoList } from "./todo_list/todo_list";

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

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

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

<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
</div>
</t>
<div>
<div class="p-3">
Hello World
<Counter onChange="() => this.incrementSum()"/>
<Counter onChange="() => this.incrementSum()"/>

</templates>
<div class="h3">Total Sum: <t t-esc="state.sum"/></div>
</div>
<div class="d-flex flex-wrap">
<Card title="'Hello'" content="'value'"/>
<Card title="'Bye'" content="'value'"/>
</div>
</div>
<TodoList />
</t>

</templates>
19 changes: 19 additions & 0 deletions awesome_owl/static/src/todo_list/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: {
type: Object,
shape: { id: Number, description: String, isCompleted: Boolean }
},
toggleState: Function,
removeTodo: Function,
};
onChange() {
this.props.toggleState(this.props.todo.id);
}
onRemove() {
this.props.removeTodo(this.props.todo.id);
}
}
13 changes: 13 additions & 0 deletions awesome_owl/static/src/todo_list/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="form-check">
<input class="form-check-input" type="checkbox" t-att-id="props.todo.id" t-att-checked="props.todo.isCompleted" t-on-change="onChange"/>
<label t-att-for="props.todo.id" t-att-class="props.todo.isCompleted ? 'text-decoration-line-through text-muted' : '' ">
<t t-esc="props.todo.id"/>.
<t t-esc="props.todo.description"/>
</label>
<span role="button" class="fa fa-trash ms-3 text-danger" t-on-click="onRemove"/>
</div>
</t>
</templates>
38 changes: 38 additions & 0 deletions awesome_owl/static/src/todo_list/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 };

setup() {
this.nextId = 0;
this.todos = useState([]);
useAutofocus("input")
}

addTodo(ev) {
if (ev.keyCode === 13 && ev.target.value != "") {
this.todos.push({
id: this.nextId++,
description: ev.target.value,
isCompleted: false
});
ev.target.value = "";
}
}
toggleTodo(todoId) {
const todo = this.todos.find((todo) => todo.id === todoId);
if (todo) {
todo.isCompleted = !todo.isCompleted;
}
}

removeTodo(todoId) {
const todoIndex = this.todos.findIndex((todo) => todo.id === todoId);
if (todoIndex >= 0) {
this.todos.splice(todoIndex, 1);
}
}
}
11 changes: 11 additions & 0 deletions awesome_owl/static/src/todo_list/todo_list.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.TodoList">
<div class="d-inline-block border p-2 m-2">
<input class="form-control mb-3" type="text" placeholder="Add a todo" t-on-keyup="addTodo" t-ref="input"/>
<t t-foreach="todos" t-as="todo" t-key="todo.id">
<TodoItem todo="todo" toggleState.bind="toggleTodo" removeTodo.bind="removeTodo"/>
</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 function useAutofocus(refName) {
const ref = useRef(refName);
onMounted(() => {
ref.el.focus();
});
}
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
23 changes: 23 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "Estate",
"version": "1.0",
"depends": ["base"],
"author": "japat",
"category": "Category",
"description": """
Hello , Real Estate for everyone
""",
"data": [
"security/ir.model.access.csv",
"report/estate_property_reports.xml",
"report/estate_property_templates.xml",
"views/estate_property_views.xml",
"views/estate_property_type_views.xml",
"views/estate_property_tag_views.xml",
"views/estate_menus.xml",
"views/estate_property_offer.xml",
"views/res_users_views.xml",
],
"license": "LGPL-3",
"application": True,
}
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
130 changes: 130 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
from datetime import timedelta

from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
from odoo.tools.float_utils import float_compare, float_is_zero


class Property(models.Model):
_name = "estate.property"
_description = "estate property details"
_order = "id desc"

name = fields.Char(required=True)
description = fields.Text()
postcode = fields.Char()
Copy link

Choose a reason for hiding this comment

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

Why is this field char() ?

Copy link
Author

Choose a reason for hiding this comment

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

Because, Sir, here in Chapter 3, we are told to have this field as a Character
https://www.odoo.com/documentation/19.0/developer/tutorials/server_framework_101/03_basicmodel.html#types
I have done the other changes
Thank You.

date_availability = fields.Date(
copy=False, default=lambda self: fields.Date.today() + timedelta(days=90)
)
expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True, copy=False)
bedrooms = fields.Integer(default=2)
living_area = fields.Integer(string="Living Area(sqm)")
facades = fields.Integer()
garage = fields.Boolean()
garden = fields.Boolean()
garden_area = fields.Integer(string="Garden Area(sqm)", store=True)
garden_orientation = fields.Selection(
selection=[
("north", "North"),
("west", "West"),
("east", "East"),
("south", "South"),
]
)
active = fields.Boolean(default=True)
state = fields.Selection(
selection=[
("new", "New"),
("offer_received", "Offer Received"),
("offer_accepted", "Offer Accepted"),
("sold", "Sold"),
("cancelled", "Cancelled"),
],
default="new",
copy=False,
required=True,
)

property_type_id = fields.Many2one("estate.property.type", string="Property Type")
salesperson_id = fields.Many2one(
"res.users", string="Salesman", default=lambda self: self.env.user
)
buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False, readonly=True)
tag_ids = fields.Many2many("estate.property.tag", string="Property Tags")
offer_ids = fields.One2many("estate.property.offer", "property_id")
total_area = fields.Float(string="Total Area(sqm)", compute="_compute_total_area")
best_price = fields.Float(
string="Best Offer", compute="_compute_best_offer", readonly=True, copy=False
)
_check_expected_price = models.Constraint(
"CHECK(expected_price > 0)",
"The expected price should be strictly positive",
)
_check_selling_price = models.Constraint(
"CHECK(selling_price >= 0)",
"The selling price should be strictly positive",
)

@api.depends("living_area", "garden_area")
def _compute_total_area(self):
for record in self:
record.total_area = record.living_area + record.garden_area

@api.depends("offer_ids")
def _compute_best_offer(self):
for record in self:
prices = record.offer_ids.mapped("price")
if prices:
record.best_price = max(prices)
else:
record.best_price = 0.0

@api.onchange("garden")
def _onchange_garden(self):
if self.garden:
self.garden_area = 10
self.garden_orientation = "north"
else:
self.garden_area = 0
self.garden_orientation = False

@api.constrains("selling_price", "expected_price")
def _check_price(self):
if not float_is_zero(self.selling_price, precision_rounding=0.001) and (
float_compare(
self.selling_price,
self.expected_price * 0.9,
precision_rounding=0.01,
)
== -1
):
raise ValidationError(
"The selling price must be at least 90% of the expected price"
)

def action_sold_button(self):
if self.filtered(lambda x: x.state == "cancelled"):
raise UserError(_("Cancelled Property cannot be sold."))
else:
self.state = "sold"
return {
"effect": {
"fadeout": "no",
"message": "helloo",
"type": "rainbow_man",
}
}

def action_cancel_button(self):
if self.filtered(lambda x: x.state == "sold"):
raise UserError(_("Sold Property cannot be Cancelled."))
self.state = "cancelled"

@api.ondelete(at_uninstall=False)
def _unlink_check_state_before_deletion(self):
for record in self:
if record.state not in ["new", "cancelled"]:
raise UserError(
_("You can only delete properties that are 'New' or 'Cancelled'.")
)
Loading