Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
Empty file added estate /__init__.py
Empty file.
Empty file added estate /__manifest__.py
Empty file.
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
17 changes: 17 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
'name': 'Odoo Tutorial Real Estate',
'category': 'Real Estate',
'version': '19.0.1.0',
'author': 'Hazei',
'license': 'LGPL-3',
'summary': 'Real Estate Management Tutorial',
'application': True,
'depends': [
'base',
],
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/menu_views.xml',
],
}
1 change: 1 addition & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import estate_property
30 changes: 30 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from odoo import models, fields
from datetime import date
from dateutil.relativedelta import relativedelta


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

name = fields.Char(string="Title", required=True)
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(copy=False, readonly=True, default=date.today() + relativedelta(months=3))

Choose a reason for hiding this comment

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

Suggested change
date_availability = fields.Date(copy=False, readonly=True, default=date.today() + relativedelta(months=3))
date_availability = fields.Date(copy=False, readonly=True, default=lambda self: date.today() + relativedelta(months=3))

If you don't do this, it will only be evaluated one time and not work tomorrow on a long running instance.

expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True, copy=False)
bedrooms = fields.Integer(default=2)
living_area = fields.Integer(string='Living Area (m2)')
facades = fields.Integer()
garage = fields.Boolean()
garden = fields.Boolean()
garden_area = fields.Integer(string='Garden Area (m2)')
garden_orientation = fields.Selection(
string='garden_orientation',
selection=[('north', 'North'), ('south', 'South'),
('east', 'East'), ('west', 'West')])
active = fields.Boolean(default=False)

Choose a reason for hiding this comment

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

Suggested change
active = fields.Boolean(default=False)
active = fields.Boolean()

False is already the default for Boolean

status = fields.Selection(copy=False, readonly=True, default='new',
string='status',
selection=[('new', 'New'), ('offer_received', 'Offer Received'), ('offer_accepted', 'Offer Accepted'), ('sold', 'Sold'), ('cancelled', 'Cancelled')],
)
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_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
77 changes: 77 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_action" model="ir.actions.act_window">
<field name="name">Property</field>
<field name="res_model">estate.property</field>
<field name="view_mode">list,form</field>
</record>
<record id="estate_property_view_list" model="ir.ui.view">
<field name="name">estate.property.list</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Property">
<field name="name"/>
<field name="bedrooms"/>
<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="Property Form">
<sheet>
<div class="oe_title">
<h1>
<field name="name"/>
</h1>
</div>
<seperator/>
<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>
<record id="estate_property_view_search" model="ir.ui.view">
<field name="name">estate.property.views.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search string="Estate Property">
<field name="name"/>
<field name="living_area"/>
<separator/>
<filter string="Archived" name="active" domain="[('active', '=', False)]"/>
<filter string="status" name="status" domain="[('status', 'in', ('new', 'offer_received'))]"/>
<filter string="active" name="group_active" context="{'group_by':'active'}"/>
<filter string="postcode" name="group_active" context="{'group_by':'postcode'}"/>
<filter string="bedrooms" name="group_bedrooms" context="{'group_by':'bedrooms'}"/>
</search>
</field>
</record>
</odoo>
10 changes: 10 additions & 0 deletions estate/views/menu_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>

<odoo>
<menuitem id="estate_menu_root" name="RealEstate">
<menuitem id="estate_first_level_menu" name="First Level">
<menuitem id="estate_model_menu_action" action="estate_property_action"/>
</menuitem>
</menuitem>
</odoo>