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 .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",
"version": "1.0",
"license": "LGPL-3",
"author": "Mauryan Kansara",
"category": "Tutorials",
"depends": ["base"],
"application": True,
"installable": True,
"data": [
"security/ir.model.access.csv",
"views/estate_property_views.xml",
"views/estate_menus.xml",
]
}
2 changes: 2 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import estate_property
from . import estate_property_type
43 changes: 43 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from odoo import models, fields
from odoo.tools.rendering_tools import relativedelta_proxy


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

title = fields.Char(required=True, default="Unknown")
last_seen = fields.Datetime("Last Seen", default=fields.Datetime.now)
description = fields.Text()
postcode = fields.Char("Postcode")
date_availability = fields.Date("Available From",
default=lambda self: fields.Date.today() + relativedelta_proxy(months=3)
)
expected_price = fields.Float("Expected Price", required=True)
selling_price = fields.Float("Selling Price", readonly=True, copy=False)
bedrooms = fields.Integer("Bedrooms", default=2)
living_area = fields.Integer("Living Area (sqm)")
facades = fields.Integer()
garage = fields.Boolean()
garden = fields.Boolean()
active = fields.Boolean(default=True)
garden_area = fields.Integer("Garden Area (sqm)")
garden_orientation = fields.Selection(
selection=[('north', 'North'), ('south', 'South'), ('east', 'East')],
)
state = fields.Selection(
[
("new", "New"),
("offer_received", "Offer Received"),
("offer_accepted", "Offer Accepted"),
("sold", "Sold"),
("cancelled", "Cancelled"),
],
required=True,
copy=False,
default="new",
)

property_type_id = fields.Many2one("estate.property.types", string="Property Type")
buyer_id = fields.Many2one("res.partner", string="Buyer")
seller_id = fields.Many2one("res.partner", string="Seller")
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 EstatePropertyType(models.Model):
_name = "estate.property.types"
_description = "Estate Property Types"

name = fields.Char("Property Type", required=True)
2 changes: 2 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_estate_model,access_estate_property,model_estate_property,base.group_user,1,1,1,1
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 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="estate.property_menu_root" name="Real Estate">
<menuitem id="estate.property_first_level_menu" name="Advertisements">
<menuitem id="estate.property_model_menu_action" action="estate.property_model_action"/>
</menuitem>
<menuitem id="estate.property_settings" name="Settings">
<menuitem id="estate.property_settings_menu_action" action="estate.property_settings_action" />
</menuitem>
</menuitem>
</odoo>
105 changes: 105 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="estate.property_model_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>

<record id="estate.property_settings_action" model="ir.actions.act_window">
<field name="name">Property Types</field>
<field name="res_model">estate.property.types</field>
<field name="view_mode">list,form</field>
</record>

<record id="estate.property_view_tree" model="ir.ui.view">
<field name="name">estate.property.list</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Tests">
<field name="title"/>
<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="estate.property_view_form" model="ir.ui.view">
<field name="name">estate.property_form</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<form string="Test">
<sheet>
<group>
<h1><field name="title"/></h1>
</group>
<group>
<group>
<field name="postcode" />
<field name="date_availability" />
</group>
<group>
<field name="expected_price"/>
<field name="selling_price"/>
</group>
</group>
<notebook>
<page string="Description">
<group>
<field name="description"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="facades"/>
<field name="garage"/>
<field name="garden"/>
<field name="garden_area"/>
<field name="garden_orientation"/>
<field name="state"/>
</group>
</page>
<page string="Other Info">
<group>
<field name="seller_id"/>
<field name="buyer_id"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<record id="estate.property_view_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="Searchbar">
<field name="title"/>
<field name="postcode"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="facades"/>

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

<separator />
<filter
string="Postcode"
name="group_by_postcode"
context="{'group_by': 'postcode'}"/>
</search>
</field>
</record>
</odoo>