Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions estate/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.languageServer": "None"
}
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 Management",
"depends": ["base"],
"application": True,
"data": [
"security/ir.model.access.csv",
"views/estate_property_tag_views.xml",
"views/estate_property_type_views.xml",
"views/estate_property_offer_views.xml",
"views/estate_property_views.xml",
"views/estate_property_menus.xml",
],
"license": "AGPL-3",
"installable": True,
}
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
62 changes: 62 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from datetime import timedelta

from odoo import api, fields, models


class EstateProperty(models.Model):
_name = "real_estate"
_description = "Real Estate Properties"

name = fields.Char(required=True)
description = fields.Text()
state = fields.Selection(
selection=[
("new", "New"),
("offer", "Offer"),
("received", "Received"),
("offer_accepted", "Offer Accepted"),
("sold", "Sold"),
("cancelled", "Cancelled"),
],
default="new",
)
postcode = fields.Char()
date_availability = fields.Date(copy=False, default=lambda self: fields.Date.today() + timedelta(days=90))
expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True)
active = fields.Boolean(default=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(
string="Orientation", selection=[("north", "North"), ("south", "South"), ("east", "East"), ("west", "West")]
)
property_type_id = fields.Char()
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The 'property_type_id' field should be a Many2one relationship to 'estate.property.type' model instead of a Char field to maintain referential integrity.

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

Copilot uses AI. Check for mistakes.
sales_person = fields.Many2one("res.users", string="Salesperson", default=lambda self: self.env.user)
buyer = fields.Many2one("res.partner", string="Buyer")
tag_ids = fields.Many2many("estate.property.tag")
offer_ids = fields.One2many("estate.property.offer", "property_id")
total_area = fields.Float(compute="_compute_total_area")
best_price = fields.Float(compute="_compute_best_price")

@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("best_price")
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The @api.depends decorator references 'best_price' but the method computes 'best_price'. This creates a circular dependency. It should depend on 'offer_ids.price' instead.

Suggested change
@api.depends("best_price")
@api.depends("offer_ids.price")

Copilot uses AI. Check for mistakes.
def _compute_best_price(self):
for record in self:
record.best_price = max(record.offer_ids.mapped("price") or [0])

@api.onchange("garden")
def _onchange_garden_stuff(self):
if self.garden:
self.garden_area = 10
self.garden_orientation = "north"
else:
self.garden_area = 0
self.garden_orientation = False
27 changes: 27 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from datetime import timedelta

from odoo import api, fields, models


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

price = fields.Float()
status = fields.Selection(selection=[("accepted", "Accepted"), ("refused", "Refused")])
partner_id = fields.Many2one("res.partner", string="Partner", required=True)
property_id = fields.Many2one("real_estate", required=True)
validity = fields.Integer(default=7)
date_deadline = fields.Date(compute="_compute_deadline", inverse="_inverse_date_deadline")

@api.depends("validity", "create_date")
def _compute_deadline(self):
for rec in self:
base_date = rec.create_date.date() if rec.create_date else fields.Date.today()
rec.date_deadline = base_date + timedelta(days=rec.validity)

def _inverse_date_deadline(self):
for rec in self:
if rec.date_deadline:
base_date = rec.create_date.date() if rec.create_date else fields.Date.today()
rec.validity = (rec.date_deadline - base_date).days
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 fields, models


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

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


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

name = fields.Char(required=True)
description = fields.Text()
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_real_estate,access_real_estate,estate.model_real_estate,base.group_user,1,1,1,0
estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,0
estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,0
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,0
12 changes: 12 additions & 0 deletions estate/views/estate_property_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<odoo>
<menuitem id="test_menu_root" name="Real Estate">
<menuitem id="ad_menu" name="Advertisements">
<menuitem id="ad_menu_action" action="estate_property_action"/>
</menuitem>
<menuitem id="settings_menu" name="Settings">
<menuitem id="settings_action_menu_1" action="estate_property_type_action"/>
<menuitem id="settings_action_menu_2" action="estate_property_tag_action"/>

</menuitem>
</menuitem>
</odoo>
32 changes: 32 additions & 0 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<odoo>
<record id="estate_property_offer_view_tree" 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="Channel">
<field name="price"/>
<field name="partner_id"/>
<field name="status"/>
<field name="validity"/>
<field name="date_deadline"/>
</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="status"/>
<field name="validity"/>
<field name="date_deadline"/>
</group>
</sheet>
</form>
</field>
</record>
</odoo>
16 changes: 16 additions & 0 deletions estate/views/estate_property_tag_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<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>
<record id="estate_property_tag_view_tree" 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="Channel">
<field name="name"/>
</list>
</field>
</record>
</odoo>
16 changes: 16 additions & 0 deletions estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<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_tree" 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="Channel">
<field name="name"/>
</list>
</field>
</record>
</odoo>
114 changes: 114 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<odoo>
<record id="estate_property_action" model="ir.actions.act_window">
<field name="name">Properties</field>
<field name="res_model">real_estate</field>
<field name="view_mode">list,form</field>
</record>
<record id="estate_property_view_search" model="ir.ui.view">
<field name="name">estate_property.search</field>
<field name="model">real_estate</field>
<field name="arch" type="xml">
<search string="Search Properties">
<field name="name"/>
<filter string="Available Properties" name="available" domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]"/>
<group expand="0" string="Group by">
<filter string="Postcode" name="postcode" context="{'group_by':'postcode'}"/>
</group>
</search>
</field>
</record>
<record id="estate_property_view_tree" model="ir.ui.view">
<field name="name">real_estate.list</field>
<field name="model">real_estate</field>
<field name="arch" type="xml">
<list string="Channel">
<field name="name"/>
<field name="postcode"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="expected_price"/>
<field name="selling_price"/>
<field name="date_availability"/>
</list>
</field>
</record>
<record id="real_estate_view_form" model="ir.ui.view">
<field name="name">real_estate.form</field>
<field name="model">real_estate</field>
<field name="arch" type="xml">
<form string="Real Estate">
<sheet>
<div class="oe_title">
<h1>
<field name="name" placeholder="Property Name"/>
</h1>
</div>
<field name="tag_ids" widget="many2many_tags"/>
<group>
<group>
<field name="postcode"/>
</group>
<group>
<field name="date_availability"/>
</group>
<group>
<field name="expected_price"/>
</group>
<group>
<field name="selling_price"/>
</group>
<group>
<field name="best_price"/>
</group>
</group>
<notebook>
<page string="Description">
<group>
<field name="description"/>
</group>
<group>
<field name="state"/>
</group>
<group>
<field name="bedrooms"/>
</group>
<group>
<field name="living_area"/>
</group>
<group>
<field name="facades"/>
</group>
<group>
<field name="garage"/>
</group>
<group>
<field name="garden"/>
</group>
<group>
<field name="garden_area"/>
</group>
<group>
<field name="garden_orientation"/>
</group>
<group>
<field name="total_area"/>
</group>
</page>
<page string="Offers">
<field name="offer_ids"/>
</page>
<page string="Other Info">
<group>
<field name="sales_person"/>
</group>
<group>
<field name="buyer"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

</odoo>
Loading