Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d2a042c
[ADD] estate: added estate module
radhr-odoo Apr 3, 2026
3ffb953
[IMP] estate: added model to estate module
radhr-odoo Apr 3, 2026
fe7d4dc
[IMP] estate: added estate_property model to module
radhr-odoo Apr 3, 2026
3850148
[IMP] estate: improved module by adding security
radhr-odoo Apr 6, 2026
b3e3a0f
[IMP] estate: improved security feature
radhr-odoo Apr 6, 2026
bc40317
[IMP] estate: added action in estate
radhr-odoo Apr 6, 2026
04229c3
[IMP] estate: added menu XML
radhr-odoo Apr 6, 2026
25407f8
[IMP] estate: added active and state for better visibility
radhr-odoo Apr 6, 2026
22b6c56
[IMP] estate: added list view to property module
radhr-odoo Apr 7, 2026
ea3c8ce
[IMP] estate: added form view to property module
radhr-odoo Apr 7, 2026
8db7e88
[IMP] estate: added search view to property module
radhr-odoo Apr 8, 2026
fc48f23
[IMP] estate: module link
radhr-odoo Apr 9, 2026
d64021b
[IMP] estate: added property tags many2many
radhr-odoo Apr 10, 2026
3e626b7
[IMP] estate: add page for property offer
radhr-odoo Apr 10, 2026
a79d97d
[IMP] estate: computed field total area added
radhr-odoo Apr 13, 2026
2d76721
[IMP] estate: added garden onchange feature
radhr-odoo Apr 14, 2026
217b4f7
[IMP] estate: computed field best price added
radhr-odoo Apr 13, 2026
89f31b4
[IMP] estate: added inverse for validity and deadline
radhr-odoo Apr 14, 2026
37dc1c1
[IMP] estate: confirm and reject added in offer list view
radhr-odoo Apr 14, 2026
45c4529
[IMP] estate: save and cancel restricting feature added
radhr-odoo Apr 14, 2026
a8dc03b
[IMP] estate: added constraint using SQL
radhr-odoo Apr 16, 2026
0e27beb
[IMP] estate: added python constraint
radhr-odoo Apr 16, 2026
56a6568
[IMP] estate: added inline view, status bar and order
radhr-odoo Apr 19, 2026
fa6668f
[IMP] estate: add invisible attribute
radhr-odoo Apr 20, 2026
371019c
[IMP] estate: stat button added
radhr-odoo Apr 27, 2026
0724a0f
[IMP] estate: stat button added for property count
radhr-odoo Apr 27, 2026
2fe10e0
[IMP] estate: handling offer creation and prices
radhr-odoo Apr 27, 2026
b4848d4
[IMP] estate: view and architectural inheritance
radhr-odoo Apr 27, 2026
d43058b
[ADD] estate account: get automatic invoices
radhr-odoo Apr 27, 2026
eac3b2b
[IMP] estate_account: invoice feature introduced
radhr-odoo Apr 28, 2026
4b4de22
[IMP] estate: property Management with Kanban View & Smart Fields
radhr-odoo Apr 30, 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
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": "estate",
"depends": ["base"],
"category": "tutorials",
"installable": True,
"application": True,
"data": [
"security/ir.model.access.csv",
"views/estate_property_view.xml",
"views/estate_property_offer_view.xml",
"views/estate_property_type_view.xml",
"views/estate_property_tag_view.xml",
"views/estate_menu.xml",
"views/user_res_view.xml",
],
"author": "RADHR",
"license": "LGPL-3",
}
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_model
133 changes: 133 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
from odoo import fields, models, api
from odoo.exceptions import UserError, ValidationError


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

name = fields.Char(required=True)
description = fields.Text()
date_availability = fields.Date(
string="Available From",
copy=False,
default=lambda self: fields.Date.add(fields.Date.today(), months=3),
)
postcode = fields.Char(required=True)
expected_price = fields.Float()
selling_price = fields.Float(readonly=True)
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(
selection=[
("north", "North"),
("east", "East"),
("west", "West"),
("south", "South"),
],
)
active = fields.Boolean("Active", default=True)
state = fields.Selection(
selection=[
("new", "New"),
("offer_received", "Offer Received"),
("accepted", "Accepted"),
("sold", "Sold"),
("cancelled", "Cancelled"),
],
default="new",
copy=False,
)
property_type_id = fields.Many2one("estate.property.type", string="Property type")
buyer_id = fields.Many2one(
comodel_name="res.partner",
string="Buyer",
copy=False,
default=lambda self: self.env.user.partner_id,
)
sales_person = fields.Many2one(
comodel_name="res.users",
string="Sales person",
index=True,
default=lambda self: self.env.user,
)
property_tag = fields.Many2many(
comodel_name="estate.property.tag",
)
offer_ids = fields.One2many(
comodel_name="estate.property.offer",
inverse_name="property_id",
)
total_area = fields.Integer(
string="total_area", name="Total area", compute="_compute_total"
)
best_price = fields.Integer(
compute="_compute_best_price",
store=True,
)

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

@api.depends("offer_ids.price")
def _compute_best_price(self):

for record in self:
prices = record.mapped("offer_ids.price")
record.best_price = max(prices) if prices else 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.ondelete(at_uninstall=False)
def _ondelete_property(self):
for record in self:
if record.state != "new" or record.state != "cancelled":
raise UserError(
"You can't delete the record which is not new or cancelled"
)

def action_cancel_offer(self):
for record in self:
if record.state == "sold":
raise UserError("Saved properties can't be cancelled")
else:
record.state = "cancelled"

def action_sold_offer(self):
for record in self:
if record.state == "cancelled":
raise UserError("Cancelled properties can't be saved")
else:
record.state = "sold"

def action_approve_best(self):
self.offer_ids[0].status = "accepted"

_check_expected_price = models.Constraint(
"CHECK(expected_price > 0 and selling_price > 0)",
"Expected price and selling price must be positive",
)
Comment on lines +74 to +123
Copy link
Copy Markdown

Choose a reason for hiding this comment

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


@api.constrains("selling_price", "expected_price")
def _check_selling_expected_price(self):
for record in self:
base = record.expected_price * 0.9
# value = str(base)
if record.selling_price and record.selling_price < base:
raise ValidationError(
f"Selling Price must be greater than 90 percent of expected price and atleast {base}"
)
80 changes: 80 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from odoo import fields, models, api
from odoo.exceptions import UserError


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

name = fields.Char(string="Property Offer", required=True)
price = fields.Integer(string="Price", required=True)
status = fields.Selection(
string="Status",
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(string="Validity", default=7)
date_deadline = fields.Date(
string="Deadline",
compute="_compute_deadline",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can you followe the coding guidelines for naming?

inverse="_inverse_deadline",
readonly=False,
)
property_type_id = fields.Many2one(
related="property_id.property_type_id", store=True
)

@api.model
def create(self, vals):
for val in vals:
property = self.env["estate.property"].browse(val["property_id"])
if property.best_price > val.get("price", 0):
raise UserError("Better offer than this already exist")
property.state = "offer_received"
return super().create(vals)

# It gets changed on each changes because it works based on cache
@api.depends("create_date", "validity")
def _compute_deadline(self):
for records in self:
default_date = (
records.create_date.date()
if records.create_date
else fields.Date.today()
)
records.date_deadline = fields.Date.add(default_date, days=records.validity)

# Inverse is triggered when the computed field is written (usually during save),not during live editing.
def _inverse_deadline(self):
for records in self:
default_date = (
records.create_date.date()
if records.create_date
else fields.Date.today()
)
if records.date_deadline:
records.validity = (records.date_deadline - default_date).days

def save_offer(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you followe the coding guidelines for naming?

for record in self:
if record.status == "accepted":
raise UserError("Property is already accepted")
record.status = "accepted"
record.property_id.selling_price = record.price
record.property_id.buyer_id = record.partner_id
record.property_id.state = "accepted"

def cancel_offer(self):
for record in self:
if record.status != "accepted" or record.status != "refused":
record.status = "refused"
if record.property_id.buyer_id == record.partner_id:
record.property_id.selling_price = False
record.property_id.state = False

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


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

name = fields.Char(string="name", required=True)
color = fields.Integer(string="color")

_check_name = models.Constraint(
"UNIQUE (name)", "Please give different tag as it is taken"
)
26 changes: 26 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from odoo import fields, models, api


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

name = fields.Char(string="name", required=True)
property_ids = fields.One2many(
comodel_name="estate.property",
inverse_name="property_type_id",
string="Property Type",
)
offer_ids = fields.One2many(
"estate.property.offer", inverse_name="property_type_id"
)
offer_count = fields.Integer(string="Total Offer", compute="_compute_offer_count")
sequence = fields.Integer("Sequence", default=1)

_name_check = models.Constraint("UNIQUE (name)", "Please add unique type")

@api.depends("offer_ids")
def _compute_offer_count(self):
for record in self:
record.offer_count = len(record.offer_ids)
7 changes: 7 additions & 0 deletions estate/models/inherited_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import models, fields


class ResUsers(models.Model):
_inherit = "res.users"

property_ids = fields.One2many("estate.property", inverse_name="sales_person")
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,acess_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
11 changes: 11 additions & 0 deletions estate/views/estate_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<odoo>
<menuitem id="estate_property_menu_root" name="Estate">
<menuitem id="estate_property_first_level_menu" name="first_level_menu">
<menuitem id="estate_property_menu_action" action="estate_property_action"/>
</menuitem>
<menuitem id="estate_property_settings" name="Settings">
<menuitem id="estate_property_setting_property_type" action="estate_property_type_action" name="Property Type"/>
<menuitem id="estate_property_setting_property_tag" action="estate_property_tags_action" name="Property Tag"/>
</menuitem>
</menuitem>
</odoo>
39 changes: 39 additions & 0 deletions estate/views/estate_property_offer_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<odoo>
<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>
<record id="estate_property_offer_view" model="ir.ui.view">
<field name="name">estate.property.offer.list.view</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<list decoration-success="status==&apos;accepted&apos;" decoration-danger="status==&apos;refused&apos;">
<field name="name"/>
<field name="price"/>
<field name="partner_id"/>
<button name="save_offer" string="Confirm" type="object" icon="fa-check" invisible="status in (&apos;accepted&apos;, &apos;refused&apos;)"/>
<button name="cancel_offer" string="Cancel" type="object" icon="fa-times" invisible="status in (&apos;accepted&apos;, &apos;refused&apos;)"/>
<field name="validity"/>
<field name="date_deadline"/>
</list>
</field>
</record>
<record id="estate_property_offer_form_view" model="ir.ui.view">
<field name="name">estate.property.offer.form.view</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
<field name="price"/>
<field name="partner_id"/>
<field name="validity"/>
<field name="date_deadline"/>
</group>
</sheet>
</form>
</field>
</record>
</odoo>
7 changes: 7 additions & 0 deletions estate/views/estate_property_tag_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<odoo>
<record id="estate_property_tags_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>
Loading