Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d87cc90
[ADD] estate: initial module setup
amtha-odoo Jul 2, 2026
350ef88
[IMP] estate: added estate_property model
amtha-odoo Jul 2, 2026
bdaafbc
[LINT] Fix Code Formatting
amtha-odoo Jul 3, 2026
95e2760
[LINT] Fix Code Formatting and add module license
amtha-odoo Jul 3, 2026
5371919
[LINT] Fix Code Formatting and add lincense data and add security fil…
amtha-odoo Jul 3, 2026
f888899
[LINT] Fix Code Formatting and add lincense data and add security fil…
amtha-odoo Jul 3, 2026
a6e7ce2
[IMP] estate: add basic UI and property defaults
amtha-odoo Jul 3, 2026
2f23484
[IMP] estate: add basic UI and property defaults
amtha-odoo Jul 3, 2026
6583a65
[IMP] estate: add custom list and form views
amtha-odoo Jul 6, 2026
7481584
[IMP] estate: Add search view for estate properties
amtha-odoo Jul 7, 2026
5da110c
[ADD] estate: add property type model and relation
amtha-odoo Jul 8, 2026
9533150
[IMP] estate: add menus for property type and tag and custom search view
amtha-odoo Jul 9, 2026
bab61c0
[IMP] estate: add security access rules and update __init__.py and ma…
amtha-odoo Jul 9, 2026
f9dce55
[IMP] estate: Add property types, tags, offers, and model relations
amtha-odoo Jul 9, 2026
9f22c07
[IMP] estate: Add computed total_area field using @api.depends
amtha-odoo Jul 13, 2026
0b416ba
[IMP] estate: add total-area, best-price, offer validity and deadline
amtha-odoo Jul 23, 2026
9d5c18a
[IMP] estate: Add actions for property and offer management
amtha-odoo Jul 28, 2026
cb60158
[IMP] estate: add Sql constraints for selling price,expected price,pr…
amtha-odoo Jul 31, 2026
05d7e93
[LINT] estate: fix check type error
amtha-odoo Jul 31, 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
2 changes: 2 additions & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# estate/__init__.py
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": "Estate",
"version": "1.0",
"depends": ["base"],
"application": True,
"category": "Tutorials",
"author": "Thakor Anish",
"license": "LGPL-3",
"data": [
"security/ir.model.access.csv",
"view/estate_property_views.xml",
"view/estate_property_type_views.xml",
"view/estate_property_tag_views.xml",
"view/estate_property_offer_views.xml",
"view/estate_menus.xml",
],
}
6 changes: 6 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# estate/models/__init__.py

from . import estate_property
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offer
143 changes: 143 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
from datetime import timedelta

from odoo import fields, models, api
from odoo.exceptions import UserError


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

name = fields.Char(required=True)
total_area = fields.Integer(compute="_compute_total_area")

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

def action_sold(self):
for record in self:
if record.state == "cancelled":
raise UserError("Cancelled property cannot be sold.")

record.state = "sold"

return True

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

record.state = "cancelled"

return True

best_price = fields.Float(
string="Best Offer",
compute="_compute_best_price",
store=True,
)

@api.depends("offer_ids.price")
def _compute_best_price(self):
for property in self:
if property.offer_ids:
property.best_price = max(property.offer_ids.mapped("price"))
else:
property.best_price = 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

property_type_id = fields.Many2one(
"estate.property.type",
string="Property Type",
)

buyer_id = fields.Many2one(
"res.partner",
string="Buyer",
copy=False,
)
salesperson_id = fields.Many2one(
"res.users",
string="Salesperson",
default=lambda self: self.env.user,
)
tag_ids = fields.Many2many(
"estate.property.tag",
string="Tags",
)
offer_ids = fields.One2many(
"estate.property.offer",
"property_id",
string="Offers",
)

description = fields.Text()

postcode = fields.Char()

date_availability = fields.Date(
copy=False,
default=lambda self: fields.Date.today() + timedelta(days=90),
)

expected_price = fields.Float()

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(
[
("north", "North"),
("south", "South"),
("east", "East"),
("west", "West"),
]
)

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",
)
_check_selling_price = models.Constraint(
"CHECK(selling_price >= 0)",
"A property selling price must be positive",
)
_check_expected_price = models.Constraint(
"CHECK(expected_price > 0)",
"A property expected price must be strictly positive",
)
71 changes: 71 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from odoo import fields, models, api
from datetime import timedelta


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

price = fields.Float()

def action_confirm(self):
for record in self:
record.status = "accepted"
record.property_id.selling_price = record.price
record.property_id.buyer_id = record.partner_id

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

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

partner_id = fields.Many2one(
"res.partner",
required=True,
)

property_id = fields.Many2one(
"estate.property",
required=True,
)
offer_ids = fields.One2many(
"estate.property.offer",
"property_id",
string="Offers",
)
validity = fields.Integer(
string="Validity (days)",
default=7,
)
deadline = fields.Date(
string="Deadline",
compute="_compute_date_deadline",
inverse="_inverse_date_deadline",
store=True,
)
create_date = fields.Datetime()

@api.depends("create_date", "validity")
def _compute_date_deadline(self):
for record in self:
create_date = (
record.create_date.date() if record.create_date else fields.Date.today()
)
record.deadline = create_date + timedelta(days=record.validity)

def _inverse_date_deadline(self):
for record in self:
if record.create_date and record.deadline:
record.validity = (record.deadline - record.create_date.date()).days

_sql_constraints = models.Constraint(
"CHECK(price>0)",
"Offer price must be strictly positive.",
)
12 changes: 12 additions & 0 deletions estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import fields, models


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

name = fields.Char(required=True)
_check_tag_name = models.Constraint(
"UNIQUE(name)",
"A property tag name must be unique",
)
12 changes: 12 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import fields, models


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

name = fields.Char(required=True)
_check_property_type_name = models.Constraint(
"UNIQUE(name)",
"A property type name must be unique",
)
5 changes: 5 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
access_estate_property_tag,estate.property.tag,model_estate_property_tag,base.group_user,1,1,1,1
access_estate_property_offer,estate.property.offer,model_estate_property_offer,base.group_user,1,1,1,1
access_estate_property_type,estate.property.type,model_estate_property_type,base.group_user,1,1,1,1
31 changes: 31 additions & 0 deletions estate/view/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!--TOP MENU-->
<menuitem id="estate_menu_root" name="Real Estate"/>
<!--CATEGORY MENU-->
<menuitem id="estate_property_menu"
name="Advertisements"
parent="estate_menu_root"/>
<menuitem id="estate_property_menu1"
name="Setting"
parent="estate_menu_root"/>

<menuitem id="estate_property_menu_action"
name="Properties"
parent="estate_property_menu"
action="estate_property_action"/>

<menuitem
id="estate_property_type_menu"
name="Property Types"
parent="estate_property_menu1"
action="estate_property_type_action"/>
<menuitem
id="estate_property_tag_menu"
name="Property Tags"
parent="estate_property_menu1"
action="estate_property_tag_action"
/>


</odoo>
50 changes: 50 additions & 0 deletions estate/view/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>

<!-- Action -->
<record id="estate_property_offer_action" model="ir.actions.act_window">
<field name="name">Property Offers</field>
<field name="res_model">estate.property.offer</field>
<field name="view_mode">list,form</field>
</record>

<!-- List View -->
<record id="estate_property_offer_view_list" model="ir.ui.view">
<field name="name">estate.property.offer.list</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<list string="Property Offers">
<field name="property_id"/>
<field name="price"/>
<field name="partner_id"/>
<field name="validity"/>
<field name="deadline"/>
<button name="action_confirm" string="Confirm" type="object" icon="fa-check"/>
<button name="action_cancel" string="Cancel" type="object" icon="fa-times"/>
<field name="status"/>
</list>
</field>
</record>

<!-- Form View -->
<record id="estate_property_offer_view_form" model="ir.ui.view">
<field name="name">estate.property.offer.form</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<form string="Property Offer">
<sheet>
<group>
<field name="property_id"/>
<field name="price"/>
<field name="partner_id"/>
<field name="validity"/>
<field name="deadline"/>

<field name="status" readonly="True"/>
</group>
</sheet>
</form>
</field>
</record>

</odoo>
37 changes: 37 additions & 0 deletions estate/view/estate_property_tag_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>

<!-- Action -->
<record id="estate_property_tag_action" model="ir.actions.act_window">
<field name="name">Property Tags</field>
<field name="res_model">estate.property.tag</field>
<field name="view_mode">list,form</field>
</record>

<!-- List View -->
<record id="estate_property_tag_view_list" model="ir.ui.view">
<field name="name">estate.property.tag.list</field>
<field name="model">estate.property.tag</field>
<field name="arch" type="xml">
<list string="Property Tags">
<field name="name"/>
</list>
</field>
</record>

<!-- Form View -->
<record id="estate_property_tag_view_form" model="ir.ui.view">
<field name="name">estate.property.tag.form</field>
<field name="model">estate.property.tag</field>
<field name="arch" type="xml">
<form string="Property Tag">
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>

</odoo>
Loading