Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
b378de7
[ADD] estate: define property model, security, actions, and menu
tshe-odoo Aug 18, 2025
c53de94
[ADD] estate: add list, form, and search views with filters and group by
tshe-odoo Aug 19, 2025
343fdf9
[ADD] estate: property relations:-type, tags, offers, buyer, salesperson
tshe-odoo Aug 19, 2025
0e57fac
[ADD] estate: add compute/inverse fields and onchange for property au…
tshe-odoo Aug 20, 2025
f9d70ab
[ADD] estate: add buttons and logic to manage property and offer stat…
tshe-odoo Aug 21, 2025
6e7c75f
[IMP] estate: add validation rules to enforce price constraints and u…
tshe-odoo Aug 22, 2025
1a0c139
[IMP] estate: improve property screens to guide users and reduce errors
tshe-odoo Aug 26, 2025
5bb7d7a
[ADD] estate: restrict property deletion, validate offers, update ui
tshe-odoo Aug 29, 2025
3804985
[ADD] estate_account: generate invoice automatically upon property sale
tshe-odoo Sep 1, 2025
3341c41
[ADD] estate: organize Kanban view by property type with pricing details
tshe-odoo Sep 1, 2025
609b834
[IMP] estate: auto-move offer to rejected stage after deadline expires
tshe-odoo Sep 5, 2025
aa85774
[ADD] awesome_owl: counter, card, and basic todo list with user features
tshe-odoo Sep 5, 2025
e32063a
[IMP] awesome_owl: make Card component generic with slot and add togg…
tshe-odoo Sep 8, 2025
0647ad3
[ADD] awesome_dashboard: improve layout and add dashboard features
tshe-odoo Sep 8, 2025
78912a0
[ADD] awesome_dashboard: show stats, chart, and allow user customization
tshe-odoo Sep 15, 2025
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
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
17 changes: 17 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Real Estate",
"category": "Real Estate/Brokerage",
"application": True,
"installable": True,
"depends": ["base"],
"data": [
"security/estate_security.xml",
"security/ir.model.access.csv",
"views/estate_property_offers_views.xml",
"views/estate_property_tag_views.xml",
"views/estate_property_type_views.xml",
"views/estate_property_views.xml",
"views/estate_menus.xml",
],
"license": "LGPL-3",
}
4 changes: 4 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import estate_property
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offers
112 changes: 112 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
from odoo import api, fields, models, exceptions
from odoo.tools.float_utils import float_compare, float_is_zero


class EstateProperty(models.Model):
_name = "estate.property"
_description = "Estate Property"

name = fields.Char(required=True)
description = fields.Text()
postcode = fields.Char()
date_availaility = fields.Date(
default=(fields.Date.add(fields.Date.today(), days=90)), copy=False
)

expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True, copy=False)
bedrooms = fields.Integer(default=2)
living_area = fields.Integer()
facades = fields.Integer()
garage = fields.Boolean()
garden = fields.Boolean()
garden_area = fields.Integer()
garden_orientation = fields.Selection(
string="Type",
selection=[
("North", "north"),
("South", "south"),
("East", "east"),
("West", "west"),
],
help="Type is used to know the direction of the Garden ",
)
active = fields.Boolean(default=True)
state = fields.Selection(
[
("new", "New"),
("offer_received", "Offer Received"),
("offer_accepted", "Offer Accepted"),
("sold", "Sold"),
("cancelled", "Cancelled"),
],
required=True,
copy=False,
default="new",
)
property_type = fields.Many2one("estate.property.type", string="Property Type")
salesman = fields.Many2one("res.users", default=lambda self: self.env.user)
buyer = fields.Many2one("res.partner", readonly=True, copy=False)
tag_ids = fields.Many2many("estate.property.tag", string="Tags")
offers_ids = fields.One2many("estate.property.offers", "property_id")
total_area = fields.Integer(compute="_compute_area")
best_price = fields.Float(compute="_compute_bestprice")

_sql_constraints = [
(
"check_positive_prices",
"CHECK(expected_price > 0 AND selling_price > 0)",
"Prices must be positive",
)
]

# it's calculate the total area
@api.depends("living_area", "garden_area")
def _compute_area(self):
for area in self:
area.total_area = area.living_area + area.garden_area

# it's taking the best offer from among all
@api.depends("offers_ids.price")
def _compute_bestprice(self):
for record in self:
record.best_price = max(record.offers_ids.mapped("price"), default=0)

# change the values on the basis of the garden True or False
@api.onchange("garden")
def _onchnage_garden(self):
if self.garden:
self.garden_area = 10
self.garden_orientation = "North"
else:
self.garden_area = 0
self.garden_orientation = ""

def action_cancel(self):
for record in self:
if record.state != "sold":
record.state = "cancelled"
else:
raise exceptions.UserError("A sold property cannot be cancelled")

def action_sold(self):
for record in self:
if record.state != "cancelled":
record.state = "sold"
else:
raise exceptions.UserError("A cancelled property cannot be set as sold")

Choose a reason for hiding this comment

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

If state=cancelled then we should hide sold button.


@api.constrains("expected_price", "selling_price")
def _check_selling_price(self):
for record in self:
if not float_is_zero(record.selling_price, precision_digits=2):
min_acceptable_price = record.expected_price * 0.9
if (
float_compare(
record.selling_price, min_acceptable_price, precision_digits=2
)
< 0
):
raise exceptions.UserError(
"Selling price must be at least 90% of the expected price."
)
61 changes: 61 additions & 0 deletions estate/models/estate_property_offers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from odoo import fields, models, api, exceptions


class EstatePropertyOffer(models.Model):
_name = "estate.property.offers"
_description = "Estate Property Offer"

price = fields.Float()
status = fields.Selection(
[("Accepted", "accepted"), ("refused", "Refused")], copy=False
Copy link

Choose a reason for hiding this comment

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

Suggested change
[("Accepted", "accepted"), ("refused", "Refused")], copy=False
[("accepted", "Accepted"), ("refused", "Refused")], copy=False

)
partner_id = fields.Many2one("res.partner", required=True)
property_id = fields.Many2one("estate.property", required=True)
validity = fields.Integer(default=7)
date_deadline = fields.Date(
compute="_compute_deadline", inverse="_inverse_deadline", store=True
)

_sql_constraints = [
("postive_price", "CHECK(price > 0)", "Prices must be positive")
]

# date_deadline
@api.depends("create_date", "validity")
def _compute_deadline(self):
for record in self:
if record.create_date:
record.date_deadline = fields.Date.add(
record.create_date, days=record.validity
)
# if user adding new data then their is no available of create_date then use today
else:
record.date_deadline = fields.Date.add(
fields.Date.today(), days=record.validity
)

def _inverse_deadline(self):
for record in self:
if record.create_date:
record.validity = (
record.date_deadline - record.create_date.date()
).days
else:
record.validity = (
record.date_deadline - record.fields.Date.today()
).days

def action_accepted(self):
for record in self:
# selling price is default 0 and field is readonly then when the selling_price 0 so their is no offer is accepted yet
if record.property_id.selling_price == 0:
record.status = "Accepted"
record.property_id.selling_price = record.price
record.property_id.buyer = record.partner_id
record.property_id.state = "offer_accepted"
else:
raise exceptions.UserError("Already One Offer is Accepted")

Choose a reason for hiding this comment

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

No need of usererror, we can hide the accept and refuse buttons.


def action_refused(self):
for record in self:
record.status = "refused"

Choose a reason for hiding this comment

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

should not be able to refuse, once this offer is approved.

10 changes: 10 additions & 0 deletions estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models


class EstatePropertyTag(models.Model):
_name = "estate.property.tag"
_description = "Estate Property Tag"

name = fields.Char(required=True)

_sql_constraints = [("unique_tag", "UNIQUE(name)", "Tag name must be unique")]
10 changes: 10 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models


class EstatePropertyType(models.Model):
_name = "estate.property.type"
_description = "Property Type"

name = fields.Char(required=True)

_sql_constraints = [("unique_type", "UNIQUE(name)", "Type name must be unique")]
17 changes: 17 additions & 0 deletions estate/security/estate_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="estate_group_user" model="res.groups">
<field name="name">Agent</field>
<field name="category_id" ref="base.module_category_real_estate_brokerage" />
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>

<record id="estate_group_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="base.module_category_real_estate_brokerage" />
<field name="implied_ids" eval="[(4, ref('estate_group_user'))]" />
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
<field name="comment">The user will be able to approve document created by employees.</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_estate_property_user,estate.property user,model_estate_property,estate.estate_group_user,1,0,0,0
access_estate_property_admin,estate.property admin,model_estate_property,estate.estate_group_manager,1,1,1,1
access_estate_property_type_admin,estate.property.type admin,model_estate_property_type,estate.estate_group_manager,1,1,1,1
access_estate_property_tag_admin,estate.property.tag admin,model_estate_property_tag,estate.estate_group_manager,1,1,1,1
access_estate_property_offers_admin,estate.property.offers admin,model_estate_property_offers,estate.estate_group_manager,1,1,1,1
15 changes: 15 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_first_level_menu" name="Advertisements">
<menuitem id="estate_property_menu_action" action="estate_property_action" />
</menuitem>

<menuitem id="estate_setting" name="Setting">
<menuitem id="estate_setting_menu_action" action="estate_property_type_action" />
<menuitem id="estate_setting_tag_action" action="estate_property_tag_action" />
</menuitem>
</menuitem>


</odoo>
39 changes: 39 additions & 0 deletions estate/views/estate_property_offers_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="estate_property_offers_action" model="ir.actions.act_window">
<field name="name">Property Offers</field>
<field name="res_model">estate.property.offers</field>
<field name="view_mode">list,form</field>
</record>

<record id="estate_property_offers_list_view" model="ir.ui.view">
<field name="name">estate.property.offers.list</field>
<field name="model">estate.property.offers</field>
<field name="arch" type="xml">
<list>
<field name="partner_id" />
<field name="price" />
<field name="validity" />
<field name="date_deadline" />
<button name="action_accepted" type="object" string="Accepted" icon="fa-check" />
<button name="action_refused" type="object" string="Refused" icon="fa-times" />
<field name="status" />
</list>
</field>
</record>

<record id="estate_property_offers_form_view" model="ir.ui.view">
<field name="name">estate.property.offers.form</field>
<field name="model">estate.property.offers</field>
<field name="arch" type="xml">
<form>
<group>
<field name="partner_id" />
<field name="price" />
<field name="validity" />
<field name="date_deadline" />
</group>
</form>
</field>
</record>
</odoo>
8 changes: 8 additions & 0 deletions estate/views/estate_property_tag_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="estate_property_tag_action" model="ir.actions.act_window">
<field name="name">Property Tag</field>
<field name="res_model">estate.property.tag</field>
<field name="view_mode">list,form</field>
</record>
</odoo>
8 changes: 8 additions & 0 deletions estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="estate_property_type_action" model="ir.actions.act_window">
<field name="name">Property Types</field>
<field name="res_model">estate.property.type</field>
<field name="view_mode">list,form</field>
</record>
</odoo>
Loading