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
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

19 changes: 19 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "real estate",
"version": "1.0",
"summary": "Estate management",
"description": "Estate management",
"author": "Odoo S.A.",
"category": "tutorials",
"depends": ["base"],
"data": [
"security/ir.model.access.csv",
"views/estate_property_views.xml",
"views/estate_property_type_views.xml",
"views/estate_menus.xml"
],
"license": "LGPL-3",
"application": True,
"installable": True
}

3 changes: 3 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import estate_property
from . import estate_property_type

49 changes: 49 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from dateutil.relativedelta import relativedelta

from odoo import fields, models
Comment on lines +1 to +3
Copy link
Copy Markdown

Choose a reason for hiding this comment

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



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

name = fields.Char(required=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should be one line empty before the field declaration.

description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(
default=lambda self: (
# Without lambda, date would be fixed permanently
fields.Date.today() + relativedelta(months=3)
)
)
expected_price = fields.Float()
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([
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West'),
])
active = fields.Boolean(default=True)
state = fields.Selection(
[
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'),
('canceled', 'Canceled')
],
required=True,
copy=False,
default='new'
)
buyer_id = fields.Many2one("res.partner",string="buyer",copy=False)
salesperson_id = fields.Many2one("res.users",string="salesperson",default=lambda self:self.env.user)
property_id= fields.Many2one("estate.property.type",string="Property Type")

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 = "Property Types"

name = fields.Char(required=True)

4 changes: 4 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1

37 changes: 37 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<odoo>
<!-- Main App Menu -->
<menuitem
id="estate_menu_root"
name="Real Estate"
/>
<!--First
Level Menu-->
<menuitem
id="estate_property_menu"
name="Advertisement"
parent="estate_menu_root"
/>
<!--Action
Menu-->
<menuitem
id="estate_property_action_menu"
name="Property List"
parent="estate_property_menu"
action="estate_property_action"
/>
<!--Action
Menu-->
<menuitem
id="estate_property_type_menu"
name="Settings"
parent="estate_menu_root"
/>
<!--Action
Menu-->
<menuitem
id="estate_property_type_list_menu"
name="Property Type"
parent="estate_property_type_menu"
action="estate_property_type_action"
/>
</odoo>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should be one empty line at the end of the file.

9 changes: 9 additions & 0 deletions estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!--ACTION-->
<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>
</odoo>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should be one empty line at the end of the file.

100 changes: 100 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<odoo>
<!--List View-->
<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="Properties" delete="False">
<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" />
<field name="property_id" />
</list>
</field>
</record>
<!--Form
View-->
<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="Properties">
<sheet>
<div>
<h1>
<field name="name" />
</h1>
</div>

<group>
<group>
<field name="property_id" />
<field name="postcode" />
<field name="expected_price" />
</group>

<group>
<field name="date_availability" />
<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="active" />
<field name="state" />
</group>
</page>

<page string="Other Info">
<group>
<field name="buyer_id" />
<field name="salesperson_id" />
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<!--Search
View-->
<record id="estate_property_search_view" model="ir.ui.view">
<field name="name">estate.property.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search>
<field name="name" string="xyz" />
<field name="postcode" />
<field name="expected_price" />
<field name="bedrooms" />
<field name="living_area" />
<field name="facades" />
<filter string="Available" name="state"
domain="['|',('state','=','new'),('state','=','offer_received')]" />
<filter string="Postcode" name="postcode" context="{'group_by':'postcode'}" />
</search>
</field>
</record>

<!--ACTION-->
<record id="estate_property_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>