Skip to content

ADD: Real Estate Module Added #730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: 18.0
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models

17 changes: 17 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Real Estate",
"depends": [
"base",
],
"author": "Youssef Abdelmoneim",
"description": "A module for managing real estate properties.",
"application": True,
"data": [
"security/ir.model.access.csv",
"views/estate_views.xml",
"views/property_type_views.xml",
"views/property_tag_views.xml",
"views/estate_menus.xml",
"views/settings_menu.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 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import estate, property_tag, propery_type, property_offer
54 changes: 54 additions & 0 deletions estate/models/estate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models
from dateutil.relativedelta import relativedelta


class Estate(models.Model):
_name = "estate_property"
Comment on lines +7 to +8

Choose a reason for hiding this comment

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

_name is defined with dots, not underscores + the class name should reflect the name

Suggested change
class Estate(models.Model):
_name = "estate_property"
class EstateProperty(models.Model):
_name = "estate.property"

_description = "RE Initial Model"
name = fields.Char(required=True)
Comment on lines +9 to +10

Choose a reason for hiding this comment

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

Use a space to separate this

Suggested change
_description = "RE Initial Model"
name = fields.Char(required=True)
_description = "RE Initial Model"
name = fields.Char(required=True)

active = fields.Boolean(default=True)
description = fields.Text()
postcode = fields.Text()

Choose a reason for hiding this comment

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

Maybe better use a Char here

date_availability = fields.Date(
copy=False, default=fields.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(
string="Garden Orientation",
selection=[
("north", "North"),
("south", "South"),
("east", "East"),
("west", "West"),
],
)

state = fields.Selection(
string="State",
required=True,
default="new",
copy=False,
selection=[
("new", "New"),
("offer_received", "Offer Received"),
("offer_accepted", "Offer Accepted"),
("sold", "Sold"),
("cancelled", "Canceled"),
],
)
property_type_id = fields.Many2one("property_type", string="property_type")
buyer = fields.Many2one("res.partner", copy=False)
salesperson = fields.Many2one("res.users", default=lambda self: self.env.user)
property_tag_ids = fields.Many2many("property_tag", string="property_tag")
property_offer_ids = fields.One2many(
"property_offer", "property_id", string="property_offer"
)
21 changes: 21 additions & 0 deletions estate/models/property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models


class PropertyOffer(models.Model):
_name = "property_offer"
_description = "Property Offer Model"
name = fields.Char(required=True)
price = fields.Float()
state = fields.Selection(
string="State",
required=True,
default="new",
copy=False,
selection=[
("accepted", "Accepted"),
("refused", "Refused"),
],
)
partner_id = fields.Many2one("res.partner", required=True)
property_id = fields.Many2one("estate_property", required=True)
8 changes: 8 additions & 0 deletions estate/models/property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models


class PropertyTag(models.Model):
_name = "property_tag"
_description = "Property Tag Model"
name = fields.Char(required=True)
10 changes: 10 additions & 0 deletions estate/models/propery_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models


class PropertyType(models.Model):
_name = "property_type"
_description = "Property Types"
name = fields.Char(required=True)
6 changes: 6 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
estate.access_property_type,access_property_type,estate.model_property_type,base.group_user,1,1,1,1
estate.access_property_offer,access_property_offer,estate.model_property_offer,base.group_user,1,1,1,1
estate.access_property_type,access_property_type,estate.model_property_type,base.group_user,1,1,1,1
estate.access_property_tag,access_property_tag,estate.model_property_tag,base.group_user,1,1,1,1
7 changes: 7 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<odoo>
<menuitem id="menu_root" name="Real Estate">
<menuitem id="first_level_menu" name="Advertisement">
<menuitem id="model_menu_action" action="re_action_model"/>
</menuitem>
</menuitem>
</odoo>
92 changes: 92 additions & 0 deletions estate/views/estate_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0"?>
<odoo>
<!-- Action -->
<record id="re_action_model" model="ir.actions.act_window">
<field name="name">Real Estate Listings</field>
<field name="res_model">estate_property</field>
<field name="view_mode">list,form</field>
</record>
<!-- List -->
<record id="re_view_list" model="ir.ui.view">
<field name="name">Estate List</field>
<field name="model">estate_property</field>
<field name="arch" type="xml">
<list string = "Listings">
<field name="name"/>
<field name="expected_price"/>
<field name="postcode"/>
<field name="bedrooms"/>
<field name="state"/>
</list>
</field>
</record>
<!-- Form -->
<record id="re_view_form" model="ir.ui.view">
<field name="name">name</field>
<field name="model">estate_property</field>
<field name="arch" type="xml">
<form string="Estate_Forms">
<sheet>
<h1>
<field name="name" placeholder="My new house"/>
</h1>
<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"/>
</group>
</page>
</notebook>

</sheet>
</form>
</field>
</record>

<!-- Search -->
<record id="re_view_search" model="ir.ui.view">
<field name="name">search</field>
<field name="model">estate_property</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field name="garage"/>
<filter string="Archived" name="inactive" domain="[('active', '=', False)]"/>
<filter string="New" name="new" domain="[('state', '=', 'new')]"/>
<filter string="Offer Received" name="Offer Received" domain="[('state', '=', 'offer_received')]"/>
<group expand="1" string="Group By">
<filter string="Group" name="Groupby" context="{'group_by':'postcode'}"/>
</group>
</search>
</field>
</record>
<!-- Offer List -->
<record id="offer_list" model="ir.ui.view">
<field name="name">offers List</field>
<field name="model">property_offer</field>
<field name="arch" type="xml">
<list string = "offers">
<field name="name" />
</list>
</field>
</record>
</odoo>
37 changes: 37 additions & 0 deletions estate/views/property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<odoo>

<!-- List -->
<record id="offer_list" model="ir.ui.view">
<field name="name">offers List</field>
<field name="model">property_offer</field>
<field name="arch" type="xml">
<list string = "offers">
<field name="name" />
<field name="partner_id" />
<field name="status" />
</list>
</field>
</record>
<!-- Form -->
<!-- Offer form -->
<record id="offer_form" model="ir.ui.view">
<field name="name">offers Form</field>
<field name="model">property_offer</field>
<field name="arch" type="xml">
<form string="offer_Forms">
<sheet>
<notebook>
<page string="Offers">
<group>
<field name="price"/>
<field name="partner_id"/>
<field name="status"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
</odoo>
33 changes: 33 additions & 0 deletions estate/views/property_tag_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<odoo>
<!-- Action -->
<record id="property_tag_action_model" model="ir.actions.act_window">
<field name="name">Property Tags</field>
<field name="res_model">property_tag</field>
<field name="view_mode">list,form</field>
</record>
<!-- List -->
<record id="tag_list" model="ir.ui.view">
<field name="name">Tags List</field>
<field name="model">property_tag</field>
<field name="arch" type="xml">
<list string = "Tags">
<field name="name" widget="many2many_tags"/>
</list>
</field>
</record>
<!-- Form -->
<record id="tag_form" model="ir.ui.view">
<field name="name">Tags Form</field>
<field name="model">property_tag</field>
<field name="arch" type="xml">
<form string="Tag_Forms">
<sheet>
<h1>
<field name="name" widget="many2many_tags"/>
</h1>
</sheet>
</form>
</field>
</record>
</odoo>
28 changes: 28 additions & 0 deletions estate/views/property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<odoo>
<record id="property_type_action_model" model="ir.actions.act_window">
<field name="name">Property Types</field>
<field name="res_model">property_type</field>
<field name="view_mode">list</field>
</record>
<record id="re_view_list" model="ir.ui.view">
<field name="name">name</field>
<field name="model">property_type</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
</list>
</field>
</record>
<record id="re_view_form" model="ir.ui.view">
<field name="name">name</field>
<field name="model">property_type</field>
<field name="arch" type="xml">
<form>
<sheet>
<field name="name" placeholder="Property Type"/>
</sheet>
</form>
</field>
</record>
</odoo>
9 changes: 9 additions & 0 deletions estate/views/settings_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="menu_root" name="Real Estate">
<menuitem id="first_level_property_menu" name="Settings">
<menuitem id="property_type_menu" action="property_type_action_model"/>
<menuitem id="property_tag_menu" action="property_tag_action_model"/>
</menuitem>
</menuitem>
</odoo>