Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6c46d87
[ADD] estate: add initial manifest for Real Estate module
HashemKhaled Oct 20, 2025
0f11cda
[IMP] estate: implement estate property model
HashemKhaled Oct 20, 2025
15ad935
[IMP] estate: add access control for estate property model
HashemKhaled Oct 20, 2025
c521487
[IMP] estate: add estate property views and menus
HashemKhaled Oct 20, 2025
761b7a2
[FIX] estate: remove the unnneeded installable field
HashemKhaled Oct 20, 2025
7c4b002
[IMP] estate: enhance property views with detailed form and search fu…
HashemKhaled Oct 21, 2025
04e7f84
[FIX] estate: remove the group on postcode filter for property search…
HashemKhaled Oct 21, 2025
d771be5
[IMP] estate: add property type, tag, and offer models with views and…
HashemKhaled Oct 21, 2025
582c69a
[FIX] estate: adjust style
HashemKhaled Oct 21, 2025
9d9a3a4
[FIX] estate: adjust style
HashemKhaled Oct 21, 2025
7148e7f
[IMP] estate: Add notes.
Mathilde411 Oct 21, 2025
ffc7f58
[IMP] estate: add computed fields and onchanges
HashemKhaled Oct 21, 2025
c0276dc
[IMP] estate: add buttons for some actions
HashemKhaled Oct 21, 2025
3423a10
[IMP] estate: add sql and python constraints
HashemKhaled Oct 22, 2025
ea1092d
[IMP] estate: enhance views
HashemKhaled Oct 23, 2025
e2e96ab
[FIX] estate: adjust style
HashemKhaled Oct 23, 2025
f974e96
[IMP] estate: use inheritance
HashemKhaled Oct 23, 2025
978fe3d
[ADD] estate_account: implement property sale invoicing
HashemKhaled Oct 23, 2025
887b34e
[IMP] estate: add kanban view for properties
HashemKhaled Oct 23, 2025
064eec3
[IMP] estate: address PR review comments
HashemKhaled Oct 27, 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
18 changes: 18 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
'name': 'Real Estate',
'summary': 'Manages real estate properties.',
'depends': ['base'],
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_menus.xml',
'views/estate_property_type_views.xml',
'views/estate_property_type_menus.xml',
'views/estate_property_tag_views.xml',
'views/estate_property_tag_menus.xml',
'views/estate_property_offer_views.xml',
],
'application': True,
'author': "Odoo",
'license': 'AGPL-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_offer
101 changes: 101 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from dateutil.relativedelta import relativedelta
from odoo import api, models, fields, exceptions


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

name = fields.Char(required=True)
description = fields.Text()
notes = fields.Html()
postcode = fields.Char()
date_availability = fields.Date(
default=fields.Date.today() + relativedelta(months=3), copy=False)
expected_price = fields.Float(required=True)
selling_price = fields.Float(
readonly=True, copy=False, compute="_compute_selling_price_and_buyer")
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'),
], default='new', required=True, copy=False)
property_type_id = fields.Many2one(
"estate.property.type", string="Property Type")
buyer_id = fields.Many2one("res.partner", string="Buyer",
copy=False, compute="_compute_selling_price_and_buyer")
salesperson_id = fields.Many2one(
"res.users", string="Salesperson", default=lambda self: self.env.uid)
tag_ids = fields.Many2many("estate.property.tag", string="Tags")
offer_ids = fields.One2many(
"estate.property.offer", "property_id", string="Offers")
total_area = fields.Integer(
compute="_compute_total_area", string="Total Area (sqm)")
best_offer = fields.Float(
compute="_compute_best_offer", string="Best Offer")

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

@api.depends('offer_ids.price')
def _compute_best_offer(self):
for property in self:
if property.offer_ids:
property.best_offer = max(property.offer_ids.mapped('price'))
else:
property.best_offer = 0.0

@api.onchange('garden')
def _onchange_garden(self):
if not self.garden:
self.garden_area = 0
self.garden_orientation = None
else:
self.garden_area = 10
self.garden_orientation = 'north'

def action_set_sold(self):
for property in self:
if property.state != 'cancelled':
property.state = 'sold'
else:
raise exceptions.UserError(
"Cancelled properties cannot be sold.")

def action_set_cancelled(self):
for property in self:
if property.state != 'sold':
property.state = 'cancelled'
else:
raise exceptions.UserError(
"Sold properties cannot be cancelled.")

@api.depends('offer_ids')
def _compute_selling_price_and_buyer(self):
for property in self:
accepted_offers = property.offer_ids.filtered(
lambda o: o.status == 'accepted')
if accepted_offers:
best_offer = max(accepted_offers, key=lambda o: o.price)
property.selling_price = best_offer.price
property.buyer_id = best_offer.partner_id
else:
property.selling_price = 0.0
property.buyer_id = None
53 changes: 53 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from odoo import api, models, fields


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

price = fields.Float()
status = fields.Selection(
[
("accepted", "Accepted"),
("refused", "Refused"),
],
copy=False,
)
partner_id = fields.Many2one(
"res.partner", string="Partner", required=True)
property_id = fields.Many2one(
"estate.property", string="Property", required=True)
validity = fields.Integer(default=7)
date_deadline = fields.Date(
compute="_compute_date_deadline", inverse="_inverse_date_deadline", string="Deadline")

@api.depends('validity', 'create_date')
def _compute_date_deadline(self):
for offer in self:
if offer.create_date:
offer.date_deadline = fields.Date.add(
offer.create_date.date(), days=offer.validity)
else:
offer.date_deadline = fields.Date.add(
fields.Date.today(), days=offer.validity)

def _inverse_date_deadline(self):
for offer in self:
if offer.create_date and offer.date_deadline:
delta = (offer.date_deadline - offer.create_date.date()).days
offer.validity = delta
elif offer.date_deadline:
delta = (offer.date_deadline - fields.Date.today()).days
offer.validity = delta

def action_accept_offer(self):
for offer in self:
offer.status = "accepted"

return True

def action_refuse_offer(self):
for offer in self:
offer.status = "refused"

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


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

name = fields.Char(required=True)
8 changes: 8 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from odoo import models, fields


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

name = fields.Char(required=True)
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_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1
access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1
access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1
8 changes: 8 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_menu_advertisements" name="Advertisements">
<menuitem id="estate_properties_menu_action" action="estate_property_action"/>
</menuitem>
</menuitem>
</odoo>
37 changes: 37 additions & 0 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<odoo>
<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>
<field name="price"/>
<field name="partner_id" width="200"/>
<field name="validity" string="Validity (days)" width="100%"/>
<field name="date_deadline"/>
<button name="action_accept_offer" type="object" string="Accept" icon="fa-check"/>
<button name="action_refuse_offer" type="object" string="Refuse" icon="fa-times"/>
<field name="status"/>
</list>
</field>
</record>

<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>
<sheet>
<group>
<field name="price"/>
<field name="partner_id"/>
<field name="validity" string="Validity (days)"/>
<field name="date_deadline"/>
<field name="status"/>
</group>
</sheet>
</form>
</field>

</record>
</odoo>
8 changes: 8 additions & 0 deletions estate/views/estate_property_tag_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_menu_settings" name="Settings">
<menuitem id="estate_property_tags_menu_action" action="estate_property_tag_action"/>
</menuitem>
</menuitem>
</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"?>
<odoo>
<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>
</odoo>
8 changes: 8 additions & 0 deletions estate/views/estate_property_type_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_menu_settings" name="Settings">
<menuitem id="estate_property_types_menu_action" action="estate_property_type_action"/>
</menuitem>
</menuitem>
</odoo>
44 changes: 44 additions & 0 deletions estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0"?>
<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>

<record id="estate_property_type_view_list" model="ir.ui.view">
<field name="name">estate.property.type.list</field>
<field name="model">estate.property.type</field>
<field name="arch" type="xml">
<list string="Property Types">
<field name="name"/>
</list>
</field>
</record>

<record id="estate_property_type_view_form" model="ir.ui.view">
<field name="name">estate.property.type.form</field>
<field name="model">estate.property.type</field>
<field name="arch" type="xml">
<form string="Property Type Form">
<sheet>
<div class="oe_title">
<h1>
<field name="name"/>
</h1>
</div>
</sheet>
</form>
</field>
</record>

<record id="estate_property_type_view_search" model="ir.ui.view">
<field name="name">estate.property.type.search</field>
<field name="model">estate.property.type</field>
<field name="arch" type="xml">
<search string="Property Types Search">
<field name="name"/>
</search>
</field>
</record>
</odoo>
Loading