Skip to content
Open
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
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
12 changes: 12 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
'name': 'Real Estate',
'author': 'Odoo S.A.',
'license': 'LGPL-3',
'depends': ['base'],
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_menu.xml',
],
'application': True,
}
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
51 changes: 51 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from odoo import fields, models


class Property(models.Model):
_name = 'estate.property'
_description = 'Estate property'

name = fields.Char(required=True)
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(
copy=False,
default=lambda self: fields.Date.add(
fields.Date.today(),
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()
has_garage = fields.Boolean()
has_garden = fields.Boolean()
garden_area = fields.Integer()
garden_orientation = fields.Selection(
string='Garden Orientation',
selection=[
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West')
]
)
active = fields.Boolean(default=True)
state = fields.Selection(
string='State',
selection=[
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'),
('cancelled', 'Cancelled')
],
default='new',
required=True,
copy=False
)
Comment on lines +29 to +37

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The styling is fine by me but when we have multiple values it's better to have them on separate files.

Suggested change
garden_orientation = fields.Selection(
string='Type',
selection=[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')]
)
garden_orientation = fields.Selection(
string='Garden Orientation',
selection=[
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West'),
]
)

nitpick: some teams might stick to single quotes being only on technical strings (the ones that the user don't see) and double quotes are for the strings that the user can see)
so for example the selection can be ('east', "East") instead of ('east', 'East') but some teams don't do this, they just stick to their own convention which is all single quotes (if possible) or all double quotes.
I see you are stick to single quotes, fine be me (though it's not always possible :) )

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_user","access_estate_property","model_estate_property","base.group_user",1,1,1,1
7 changes: 7 additions & 0 deletions estate/views/estate_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_first_level_menu" name="Advertisements">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Better to make ids more descriptive so that they indicate what they are without having to read the definition

<menuitem id="estate_menu_action_property_list" action="estate_action" name="Properties"/>
</menuitem>
</menuitem>
</odoo>
83 changes: 83 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<odoo>
<record id="estate_action" model="ir.actions.act_window">
<field name="name">Porperties</field>
<field name="res_model">estate.property</field>
<field name="view_mode">list</field>
</record>

<record id="estate_property_view_search" model="ir.ui.view">
<field name="name">estate.property.view.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search string="Search Property">
<field name="name" string="Title"/>
<field name="postcode"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="facades"/>
<separator/>
<filter string="Available" name="date_availability" domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]"/>
<filter string="Post Code" name="postcode" context="{'group_by':'postcode'}"/>
</search>
</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="Properties" editable="bottom" open_form_view="True">
<field name="name"/>
<field name="postcode"/>
<field name="bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="expected_price"/>
<field name="selling_price"/>
<field name="date_availability" string="Available from"/>
</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="Properties">
<sheet>
<group>
<h1>
<field name="name"/>
</h1>
</group>
<group>
<group>
<field name="postcode"/>
<field name="date_availability" string="Available From"/>
</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" string="Living Area (sqm)"/>
<field name="facades"/>
<field name="has_garage"/>
<field name="has_garden"/>
<field name="garden_area" string="Garden Area (sqm)"/>
<field name="garden_orientation"/>
<field name="state"/>
<field name="active"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
</odoo>