Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8b6a081
Remove estate/models.py file as part of project restructuring.
KennethOfficial Sep 16, 2025
89b5a43
Update version number in __manifest__.py from 16.0.0 to 18.0.1.0.1
KennethOfficial Sep 16, 2025
e4f81a5
Update version number to 18.0.1.0.2 and add fields to EstateProperty …
KennethOfficial Sep 16, 2025
3519c09
Add security access rules by including 'security/ir.model.access.csv'…
KennethOfficial Sep 16, 2025
e3c918c
Update version number to 18.0.1.0.3 in __manifest__.py for the estate…
KennethOfficial Sep 16, 2025
cbe9c14
Update version number to 18.0.1.0.4 and add 'views/estate_property_vi…
KennethOfficial Sep 16, 2025
303b185
Add initial XML structure for estate_property_views.xml file in the e…
KennethOfficial Sep 16, 2025
147cd2e
Update version number to 18.0.1.0.6 in __manifest__.py and add estate…
KennethOfficial Sep 16, 2025
e2e36c6
Update version number to 18.0.1.0.7 in __manifest__.py and change mod…
KennethOfficial Sep 16, 2025
e6a74de
Update version number to 18.0.1.0.8 in __manifest__.py and add 'views…
KennethOfficial Sep 16, 2025
7dbed06
Update estate_property.py to set 'copy=False' for date_availability a…
KennethOfficial Sep 16, 2025
950045a
Update version number to 18.0.1.0.10 in __manifest__.py and set defau…
KennethOfficial Sep 16, 2025
28c2e6d
Add 'active' field to EstateProperty model and update view mode in es…
KennethOfficial Sep 16, 2025
e236589
Add 'state' field to EstateProperty model with selection options for …
KennethOfficial Sep 16, 2025
aef1496
Update version number to 18.0.1.0.13 in __manifest__.py, reorder data…
KennethOfficial Sep 16, 2025
a4d8c7f
Refactor EstateProperty model initialization to use _auto_init method…
KennethOfficial Sep 16, 2025
b930a24
Remove deprecated logging and XML view definitions from EstatePropert…
KennethOfficial Sep 16, 2025
af47b94
new
KennethOfficial Sep 16, 2025
1a9b8c0
Update version number to 18.0.1.0.17 in __manifest__.py and rename ac…
KennethOfficial Sep 16, 2025
864efc1
Enhance estate_property_views.xml by adding a detailed list view defi…
KennethOfficial Sep 16, 2025
8b5a3de
Update version number to 18.0.1.0.18 in __manifest__.py for the Estat…
KennethOfficial Sep 16, 2025
37d4d6a
Update version number to 18.0.1.0.19 in __manifest__.py and add a new…
KennethOfficial Sep 16, 2025
8d01890
Add search view definition for estate properties in estate_property_v…
KennethOfficial Sep 16, 2025
01de875
Update version number to 18.0.1.0.21 in __manifest__.py and remove th…
KennethOfficial Sep 16, 2025
71d2909
Update version number to 18.0.1.0.22 in __manifest__.py and remove re…
KennethOfficial Sep 16, 2025
b76bf7b
Update version number to 18.0.1.0.23 in __manifest__.py and comment o…
KennethOfficial Sep 16, 2025
7edb097
Uncomment view definitions in estate_property_views.xml to restore fo…
KennethOfficial Sep 16, 2025
7f4b01f
Add view ID and search view ID references in estate_property_views.xm…
KennethOfficial Sep 16, 2025
b310dd7
Update version number to 18.0.1.0.25 in __manifest__.py, add property…
KennethOfficial Sep 16, 2025
c8a0159
Update version number to 18.0.1.0.26 in __manifest__.py, add salesper…
KennethOfficial Sep 16, 2025
82f412a
Update version number to 18.0.1.0.27 in __manifest__.py, add tag_ids …
KennethOfficial Sep 16, 2025
cac6e32
Update version number to 18.0.1.0.28 in __manifest__.py, add offer_id…
KennethOfficial Sep 16, 2025
04010fd
Enhance EstatePropertyOffer and EstateProperty models with validity a…
KennethOfficial Sep 16, 2025
a2ab98a
Update version number to 18.0.1.0.30 in __manifest__.py and add oncha…
KennethOfficial Sep 16, 2025
4aa0c48
Update version number to 18.0.1.0.31 in __manifest__.py, implement ac…
KennethOfficial Sep 16, 2025
5ef1e7e
Update version number to 18.0.1.0.32 in __manifest__.py and add SQL c…
KennethOfficial Sep 16, 2025
2456615
Update version number to 18.0.1.0.33 in __manifest__.py and refactor …
KennethOfficial Sep 16, 2025
2fe6008
Refactor SQL constraints in EstatePropertyOffer, EstatePropertyTag, E…
KennethOfficial Sep 16, 2025
6fd7240
Update version number to 18.0.1.0.35 in __manifest__.py and add valid…
KennethOfficial Sep 16, 2025
053ca5e
Add property_ids relationship to EstatePropertyType model and enhance…
KennethOfficial Sep 16, 2025
2814a8f
Update version number to 18.0.1.0.37 in __manifest__.py and add order…
KennethOfficial Sep 16, 2025
1b90e46
Enhance EstatePropertyType model by adding a sequence field for order…
KennethOfficial Sep 16, 2025
d42d7fe
Update version number to 18.0.1.0.38 in __manifest__.py, add color fi…
KennethOfficial Sep 16, 2025
0cf2057
Update version number to 18.0.1.0.39 in __manifest__.py, make propert…
KennethOfficial Sep 16, 2025
02359f3
Enhance estate property views by adding conditional decorations for o…
KennethOfficial Sep 16, 2025
c002789
Add property_type_id field to EstatePropertyOffer model, enhance Esta…
KennethOfficial Sep 16, 2025
603d821
Refactor estate property views by commenting out unused button elemen…
KennethOfficial Sep 16, 2025
6a43192
Reorganize estate property views by moving the action window definiti…
KennethOfficial Sep 16, 2025
61864b4
Refactor estate property views by reintroducing the action window def…
KennethOfficial Sep 16, 2025
92003f6
Comment out the button box in estate_property_type_views.xml to tempo…
KennethOfficial Sep 16, 2025
2770cce
Update version number to 18.0.1.0.46 in __manifest__.py, reintroduce …
KennethOfficial Sep 16, 2025
10cccda
Add CRUD method overrides in EstatePropertyOffer and EstateProperty m…
KennethOfficial Sep 16, 2025
f594dbd
Update version number to 18.0.1.0.48 in __manifest__.py and add res_u…
KennethOfficial Sep 16, 2025
b45e63e
Refactor create method in EstatePropertyOffer to support batch creati…
KennethOfficial Sep 16, 2025
52b9c8b
Enhance EstatePropertyOffer model by adding validation for batch crea…
KennethOfficial Sep 16, 2025
9cf95e1
Update __manifest__.py to include security access file and modify __i…
KennethOfficial Sep 16, 2025
948d034
Import estate_property model in __init__.py to enhance module structu…
KennethOfficial Sep 16, 2025
f093f9c
Implement invoice creation in action_sold method of EstateProperty mo…
KennethOfficial Sep 16, 2025
76a685c
Add Kanban view for estate properties and update action window view m…
KennethOfficial Sep 16, 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
13 changes: 10 additions & 3 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
{
"name": "Estate", # The name that will appear in the App list
"version": "16.0.0", # Version
"version": "18.0.1.0.49", # Version
"application": True, # This line says the module is an App, and not a module
"depends": ["base"], # dependencies
"data": [

'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_property_offer_views.xml',
'views/estate_property_type_views.xml',
'views/estate_property_tag_views.xml',
'views/res_users_views.xml',
'views/estate_menus.xml',
],

"installable": True,
'license': 'LGPL-3',
}
Empty file removed estate/models.py
Empty file.
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

Choose a reason for hiding this comment

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

As a good practice, we leave a blank line at the end of the file

123 changes: 123 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError
from odoo.tools.float_utils import float_compare, float_is_zero

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

_sql_constraints = [
('check_expected_price', 'CHECK(expected_price > 0)', 'Expected price must be strictly positive'),
('check_selling_price', 'CHECK(selling_price >= 0)', 'Selling price must be positive'),
]

# Basic Information
name = fields.Char(required=True)
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(copy=False, default=lambda self: fields.Date.add(fields.Date.today(), months=2))
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')
property_type_id = fields.Many2one("estate.property.type", string="Property Type")
# Pricing
expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True, copy=False)
best_price = fields.Float(compute='_compute_best_price', string='Best Offer')

# Property Details
bedrooms = fields.Integer(default=2)
living_area = fields.Integer()
facades = fields.Integer()
total_area = fields.Integer(compute='_compute_total_area', string='Total Area')

# Features
garage = fields.Boolean()
garden = fields.Boolean()
garden_area = fields.Integer()
garden_orientation = fields.Selection(
selection=[
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West'),
]
)

# People
salesperson_id = fields.Many2one('res.users', string='Salesperson', default=lambda self: self.env.user)
buyer_id = fields.Many2one('res.partner', string='Buyer', copy=False)

# Tags
tag_ids = fields.Many2many('estate.property.tag', string='Tags')

# Offers
offer_ids = fields.One2many('estate.property.offer', 'property_id', string='Offers')

# Computed Methods
@api.depends('living_area', 'garden_area')
def _compute_total_area(self):
for record in self:

Choose a reason for hiding this comment

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

Suggested change
for record in self:
for property in self:

We tend to use a variable that reflects the model were are in

record.total_area = record.living_area + record.garden_area

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

# Onchange Methods
@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

# Button Action Methods (Public - no underscore prefix)
def action_cancel(self):
for record in self:
if record.state == 'sold':
raise UserError("Cannot cancel a sold property")
record.state = 'cancelled'
return True

def action_sold(self):
for record in self:
if record.state == 'cancelled':
raise UserError("Cannot sell a cancelled property")
record.state = 'sold'
return True

# Python Constraints
@api.constrains('selling_price', 'expected_price')
def _check_selling_price(self):
for record in self:
# Skip validation if selling price is zero (not yet sold)
if float_is_zero(record.selling_price, precision_digits=2):
continue

# Calculate 90% of expected price
min_selling_price = record.expected_price * 0.9

# Compare selling price with minimum allowed (90% of expected)
if float_compare(record.selling_price, min_selling_price, precision_digits=2) < 0:
raise ValidationError(
f"Selling price ({record.selling_price:.2f}) cannot be lower than 90% of expected price ({min_selling_price:.2f})"
)

# CRUD Method Overrides
@api.ondelete(at_uninstall=False)
def _check_property_deletion(self):
for record in self:
if record.state not in ['new', 'cancelled']:
raise UserError(f"Cannot delete property '{record.name}' because it is in '{record.state}' state. Only 'New' or 'Cancelled' properties can be deleted.")
97 changes: 97 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
from odoo import models, fields, api
from datetime import timedelta
from odoo.exceptions import UserError

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

_sql_constraints = [
('check_offer_price', 'CHECK(price > 0)', 'Offer price must be strictly positive'),
]

# Basic Information
price = fields.Float()
status = fields.Selection(
selection=[
('accepted', 'Accepted'),
('refused', 'Refused'),
], copy=False)
validity = fields.Integer(default=7, string='Validity (days)')
date_deadline = fields.Date(compute='_compute_date_deadline', inverse='_inverse_date_deadline', string='Deadline')

# Relationships
partner_id = fields.Many2one('res.partner', string='Partner', required=True)
property_id = fields.Many2one('estate.property', string='Property', required=True)
property_type_id = fields.Many2one('estate.property.type', related='property_id.property_type_id', string='Property Type', store=True)

# Computed Methods
@api.depends('create_date', 'validity')
def _compute_date_deadline(self):
for record in self:
# Use create_date if available, otherwise use today as fallback
base_date = record.create_date.date() if record.create_date else fields.Date.today()
record.date_deadline = base_date + timedelta(days=record.validity)

def _inverse_date_deadline(self):
for record in self:
if record.date_deadline and record.create_date:
# Calculate validity based on deadline and create_date
base_date = record.create_date.date()
delta = record.date_deadline - base_date
record.validity = delta.days
elif record.date_deadline:
# If no create_date, use today as fallback
today = fields.Date.today()
delta = record.date_deadline - today
record.validity = delta.days

# Button Action Methods (Public - no underscore prefix)
def action_accept(self):
for record in self:
# Refuse all other offers for this property first
other_offers = record.property_id.offer_ids.filtered(lambda o: o.id != record.id)
other_offers.write({'status': 'refused'})

# Accept this offer
record.status = 'accepted'

# Set buyer and selling price on the property
record.property_id.buyer_id = record.partner_id
record.property_id.selling_price = record.price
return True

def action_refuse(self):
for record in self:
record.status = 'refused'
return True

# CRUD Method Overrides
@api.model_create_multi
def create(self, vals_list):
# Handle both single record and batch creation
if not isinstance(vals_list, list):
vals_list = [vals_list]

# Process each record in the batch
for vals in vals_list:
# Get the property record
property_id = vals.get('property_id')
if property_id:
property_record = self.env['estate.property'].browse(property_id)

# Check if offer price is higher than existing offers
existing_offers = property_record.offer_ids
if existing_offers:
max_existing_price = max(existing_offers.mapped('price'))
if vals.get('price', 0) <= max_existing_price:
raise UserError(f"Offer price must be higher than existing offers. Current highest offer: {max_existing_price}")

# Set property state to 'Offer Received'
property_record.state = 'offer_received'

# Always call super() to maintain the flow
return super().create(vals_list)


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

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

_sql_constraints = [
('check_name_unique', 'UNIQUE(name)', 'Property tag name must be unique'),
]

# Basic Information
name = fields.Char(required=True)
color = fields.Integer()

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 models, fields, api

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

_sql_constraints = [
('check_name_unique', 'UNIQUE(name)', 'Property type name must be unique'),
]

# Basic Information
sequence = fields.Integer(default=10)
name = fields.Char(required=True)

# Relationships
property_ids = fields.One2many('estate.property', 'property_type_id', string='Properties')
offer_ids = fields.One2many('estate.property.offer', 'property_type_id', string='Offers')
offer_count = fields.Integer(compute='_compute_offer_count', string='Offers Count')

# Computed Methods
@api.depends('offer_ids')
def _compute_offer_count(self):
for record in self:
record.offer_count = len(record.offer_ids)

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

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

property_ids = fields.One2many('estate.property', 'salesperson_id', string='Properties', domain=[('state', 'in', ['new', 'offer_received'])])
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_user,access_estate_property_user,model_estate_property,base.group_user,1,1,1,1
access_estate_property_type_user,access_estate_property_type_user,model_estate_property_type,base.group_user,1,1,1,1
access_estate_property_tag_user,access_estate_property_tag_user,model_estate_property_tag,base.group_user,1,1,1,1
access_estate_property_offer_user,access_estate_property_offer_user,model_estate_property_offer,base.group_user,1,1,1,1
12 changes: 12 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<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_settings_menu" name="Settings">
<menuitem id="estate_property_type_menu_action" action="estate_property_type_action"/>
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_action"/>
</menuitem>
</menuitem>
</odoo>
42 changes: 42 additions & 0 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<odoo>
<!-- List View Definition -->
<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" editable="bottom" decoration-danger="status == 'refused'" decoration-success="status == 'accepted'">
<field name="price"/>
<field name="partner_id"/>
<field name="property_type_id"/>
<field name="validity"/>
<field name="date_deadline"/>
<field name="status" column_invisible="True"/>
</list>
</field>
</record>

<!-- Form View Definition -->
<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">
<header>
<button name="action_accept" string="Accept" type="object" icon="fa-check" invisible="status in ['accepted', 'refused']"/>
<button name="action_refuse" string="Refuse" type="object" icon="fa-times" invisible="status in ['accepted', 'refused']"/>
</header>
<sheet>
<group>
<field name="price"/>
<field name="partner_id"/>
<field name="validity"/>
<field name="date_deadline"/>
<field name="status"/>
</group>
</sheet>
</form>
</field>
</record>

</odoo>
Loading