Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f8e1bc0
[ADD] Estate:createthe app
jedel-odoo Oct 20, 2025
c558c6b
[IMP] estate : set application to True
jedel-odoo Oct 20, 2025
cd52496
[IMP] Estate : Chapter 3
jedel-odoo Oct 20, 2025
8cb8dc5
[IMP] estate : add security model
jedel-odoo Oct 20, 2025
a0182ea
[IMP] estate : adding menus and fields
jedel-odoo Oct 20, 2025
a449045
[IMP] estate : adding custom views (chapter 6)
jedel-odoo Oct 21, 2025
ded2b66
[IMP] estate : adding types, tags and offers (chapter 7)
jedel-odoo Oct 21, 2025
286c828
[IMP] estate: Add notes.
Mathilde411 Oct 21, 2025
fa3f1ea
[IMP] estate: adding computed fields and onchanges (chapter 8)
jedel-odoo Oct 21, 2025
f9ed8a6
[IMP] estate: adding computed fields and onchanges (chapter8)
jedel-odoo Oct 21, 2025
2ff906f
[IMP] estate: style corrections
jedel-odoo Oct 21, 2025
67147af
[IMP] estate: tutorials corrections
jedel-odoo Oct 21, 2025
a0a6f39
[IMP] estate: tutorials corrections
jedel-odoo Oct 21, 2025
abc4cdf
[IMP] estate: adding buttons (chapter 9
jedel-odoo Oct 21, 2025
1c19652
[IMP] estate: corrections
jedel-odoo Oct 21, 2025
c5e045e
[IMP] estate: adding constraints (chapter 10)
jedel-odoo Oct 22, 2025
3ef6943
[IMP] estate: adding sprinkels (chapter 11)
jedel-odoo Oct 22, 2025
6a76b10
[IMP] estate: adding user inheritance (chapter 12)
jedel-odoo Oct 22, 2025
dd2110b
[IMP] estate: style corrections
jedel-odoo Oct 22, 2025
a4d520a
[ADD] estate_account: adding a child class
jedel-odoo Oct 23, 2025
25c5923
[IMP] estate, estate_account: style corrections
jedel-odoo Oct 23, 2025
383a8d6
[IMP] estate: kanban view
jedel-odoo Oct 23, 2025
f19a562
[IMP] estate: corrections
jedel-odoo Oct 23, 2025
1313f2b
[IMP] estate: corrections
jedel-odoo Oct 23, 2025
47aa27d
[IMP] estate: adding some tests
jedel-odoo Oct 24, 2025
92f8ce1
[FIX] estate: corrections
jedel-odoo Oct 24, 2025
7cc8a96
[IMP] estate: add demo data
jedel-odoo Nov 3, 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
15 changes: 15 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
'name': "Real Estate",
'depends': ['base'],
'application': True,
'author': "Jeanne Delneste",
'license': "LGPL-3",
'data': [
'views/estate_property_views.xml',
'views/estate_property_type_views.xml',
'views/estate_property_tag_views.xml',
'views/estate_property_offer_views.xml',
'views/estate_menus.xml',
'security/ir.model.access.csv'
],
}
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
87 changes: 87 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
from odoo import api, models, fields
from odoo.exceptions import UserError
import datetime
from dateutil.relativedelta import relativedelta
from odoo.tools.float_utils import float_compare, float_is_zero


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

Choose a reason for hiding this comment

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

Suggested change
_description = "Property for the Real Estate app"
_description = "Estate Property"

_description contains a short human-readable name for the model


name = fields.Char(required=True)
description = fields.Text()
postcode = fields.Char()
notes = fields.Html()
date_availability = fields.Date(copy=False, default=datetime.date.today() + relativedelta(months=+3))
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(selection=[("north", "North"), ("south", "South"), ("east", "East"), ("west", "West")])
active = fields.Boolean(default=True)
state = fields.Selection(selection=[("new", "New"), ("offer_received", "Offer Received"), ("offer_accepted", "Offer Accepted"), ("sold", "Sold"), ("cancelled", "Cancelled")], copy=False, required=True, default="new")
property_type_id = fields.Many2one("estate.property.type", string="Type")
buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False)
salesperson_id = fields.Many2one("res.users", string="Salesman", 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")
total_area = fields.Integer(compute="_compute_total_area", string="Total Area (sqm)")
best_price = fields.Float(compute="_compute_best_offer", string="Best Offer")

_positive_expected_price = models.Constraint(
'CHECK(expected_price > 0)',
'The expected price of a property must be strictly positive'
)
_positive_selling_price = models.Constraint(
'CHECK(selling_price >= 0)',
'The selling price of a property must be positive'
)

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

@api.depends("offer_ids.price")
def _compute_best_offer(self):
for record in self:
prices = record.offer_ids.mapped("price")
if len(prices) > 0:
record.best_price = max(prices)
else:
record.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 = None

def sell_property(self):
for record in self:
if record.state == "cancelled":
raise UserError("Error - You cannot sell a cancelled property !")
record.state = "sold"
return True

def cancel_property(self):
for record in self:
if record.state == "sold":
raise UserError("Error - You cannot cancel a sold property !")
record.state = "cancelled"
return True

@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=3):
if float_compare(record.selling_price, record.expected_price*0.9, precision_digits=3) < 0:
raise UserError(r"The selling price must be at least 90% of the expected price !")
Comment on lines 92 to 97

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Still

Copy link
Author

Choose a reason for hiding this comment

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

I don't understand the change I have to make

44 changes: 44 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from odoo import api, models, fields
from odoo.exceptions import UserError
import datetime


class EstatePropertyOffer(models.Model):
_name = "estate.property.offer"
_description = "Offers for properties"

price = fields.Float()
status = fields.Selection(copy=False, selection=[("accepted", "Accepted"), ("refused", "Refused")])
partner_id = fields.Many2one("res.partner", required=True, string="Partner")
property_id = fields.Many2one("estate.property", required=True)
validity = fields.Integer(default=7, string="Validity (days)")
create_date = fields.Date(copy=False, default=lambda self: datetime.date.today(), readonly=True)
date_deadline = fields.Date(compute="_compute_deadline", inverse="_inverse_deadline", string="Deadline")

_positive_price = models.Constraint(
'CHECK(price > 0)',
'The price of an offer must be strictly positive'
)

@api.depends("create_date", "validity")
def _compute_deadline(self):
for offer in self:
offer.date_deadline = fields.Date.add(offer.create_date, days=offer.validity)

def _inverse_deadline(self):
for offer in self:
delta = offer.date_deadline - offer.create_date
offer.validity = delta.days

def accept_offer(self):
for offer in self:
for other_offer in offer.property_id.offer_ids:
if other_offer.status == "accepted" and offer.id != other_offer.id:
raise UserError("An offer is already accepted...")
offer.status = "accepted"
offer.property_id.buyer_id = offer.partner_id
offer.property_id.selling_price = offer.price

def refuse_offer(self):
for offer in self:
offer.status = "refused"
Comment on lines +45 to +46

Choose a reason for hiding this comment

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

Suggested change
for offer in self:
offer.status = "refused"
self.status = "refused"
return True

Assigning attributes on recordsets works !

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


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

name = fields.Char(required=True)

_unique_tag = models.Constraint(
'unique(name)',
'The tag name must be unique',
)
13 changes: 13 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from odoo import models, fields


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

name = fields.Char(required=True)

_unique_type = models.Constraint(
'unique(name)',
'The 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
estate.access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
estate.access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1
estate.access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1
estate.access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1

Choose a reason for hiding this comment

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

Missing newline

11 changes: 11 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="first_level_advertissements_menu" name="Advertissements">
<menuitem id="property_action_menu" action="estate_property_first_action"/>
</menuitem>
<menuitem id="first_level_settings_menu" name="Settings">
<menuitem id="property_types_action_menu" action="estate_property_types"/>
<menuitem id="property_tags_action_menu" action="estate_property_tag"/>
</menuitem>
</menuitem>
</odoo>
18 changes: 18 additions & 0 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_offer_list_view" 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="List View">
<field name="price" width="200px"/>
<field name="partner_id" width="300px"/>
<field name="validity" width="100px"/>
<field name="date_deadline" width="100px"/>
<button name="accept_offer" type="object" string="Accept" icon="fa-check" width="50px"/>
<button name="refuse_offer" type="object" string="Refuse" icon="fa-times" width="50px"/>
<field name="status" width="100px"/>
</list>
</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"?>
<odoo>
<record id="estate_property_tag" model="ir.actions.act_window">
<field name="name">Property Tags</field>
<field name="res_model">estate.property.tag</field>
<field name="view_mode">list</field>
</record>
</odoo>
18 changes: 18 additions & 0 deletions estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_type_list_view" 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="List View">
<field name="name"/>
</list>
</field>
</record>

<record id="estate_property_types" model="ir.actions.act_window">
<field name="name">Property Types</field>
<field name="res_model">estate.property.type</field>
<field name="view_mode">list</field>
</record>
</odoo>
106 changes: 106 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_form_view" model="ir.ui.view">
<field name="name">estate.property.form</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<form string="Estate Property">
<header>
<button name="sell_property" type="object" string="Sold"/>
<button name="cancel_property" type="object" string="Cancel"/>
</header>
<sheet>
<div class="oe_title">
<h1><field name="name"/></h1>
</div>
<field name="tag_ids" widget="many2many_tags"/>
<separator/>
<group>
<group>
<field name="property_type_id"/>
<field name="postcode"/>
<field name="date_availability" string="Available From"/>
</group>
<group>
<field name="expected_price"/>
<field name="best_price"/>
<field name="selling_price"/>
</group>
</group>
<separator/>
<notebook>
<page string="Description">
<group>
<field name="description"/>
<field name="bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="facades"/>
<field name="garage"/>
<field name="garden"/>
<field name="garden_area" string="Garden Area (sqm)"/>
<field name="garden_orientation"/>
<field name="total_area"/>
<field name="state"/>
</group>
</page>
<page name="notes" string="Notes">
<field name="notes"/>
</page>
<page string="Offers">
<field name="offer_ids"/>
</page>
<page string="Other Info">
<group>
<field name="buyer_id"/>
<field name="salesperson_id"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<record id="estate_property_list_view" model="ir.ui.view">
<field name="name">estate.property.list</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Channel">
<field name="name" width="300px"/>
<field name="property_type_id" width="80px"/>
<field name="tag_ids" width="80px" widget="many2many_tags"/>
<field name="postcode" width="60px"/>
<field name="bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="expected_price"/>
<field name="selling_price"/>
<field name="date_availability" string="Available From"/>
</list>
</field>
</record>

<record id="estate_property_search" model="ir.ui.view">
<field name="name">estate.property.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search string="Estate Properties">
<field name="name" string="Title"/>
<field name="property_type_id"/>
<field name="postcode"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="facades"/>
<filter string="Available" name="available" domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]"/>

Choose a reason for hiding this comment

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

Suggested change
<filter string="Available" name="available" domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]"/>
<filter string="Available" name="available" domain="[('state', 'in', ('new', 'offer_received'))]"/>

Simpler way when comparing the same variable :)

<filter name="postcode" context="{'group_by':'postcode'}"/>
<filter name="property_type_id" context="{'group_by':'property_type_id'}"/>
</search>
</field>
</record>

<record id="estate_property_first_action" model="ir.actions.act_window">
<field name="name">Properties</field>
<field name="res_model">estate.property</field>
<field name="view_mode">list,form</field>
</record>
</odoo>