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
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",
"version": "1.0",
"depends": ["base"],
"author": "Odoo S.A.",
"category": "Productivity",
"description": """
Our brand new real estate app!
""",
"application": True,
"data": [
"security/ir.model.access.csv",
"views/estate_property_views.xml",
"views/estate_menus.xml",
],
"license": "OPL-1",
}
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
50 changes: 50 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from datetime import datetime

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No need to leave empty lines after each import line.
If you must, you can leave a line between the external import lines and the odoo import line, but that's just a nitpick from me

from dateutil.relativedelta import relativedelta

from odoo import fields, models


class Property(models.Model):
Comment thread
msho-odoo marked this conversation as resolved.
_name = "estate.property"
_description = "Real Estate Property"

name = fields.Char("Property Name", required=True)
description = fields.Text("Property Description")
postcode = fields.Char("Postcode")

date_availability = fields.Date("Available Date", copy=False, default=lambda _x: datetime.now() + relativedelta(months=+3))

expected_price = fields.Float("Expected Price")
selling_price = fields.Float("Selling Price", copy=False, readonly=True)

bedrooms = fields.Integer("Number of Bedrooms", default=2)
living_area = fields.Integer("Living Area")
facades = fields.Integer("Number of Facades")

has_garage = fields.Boolean("Has a Garage")
has_garden = fields.Boolean("Has a Garden")
garden_area = fields.Integer("Garden Area")
garden_orientation = fields.Selection(
string="Garden Orientation",
selection=[
("north", "North"),
("south", "South"),
("east", "East"),
("west", "West"),
],
)
Comment thread
msho-odoo marked this conversation as resolved.

state = fields.Selection(
string="Property State",
selection=[
("new", "New"),
("offer_received", "Offer Received"),
("offer_accepted", "Offer Accepted"),
("sold", "Sold"),
("cancelled", "Cancelled"),
],
default="new",
Comment thread
msho-odoo marked this conversation as resolved.
)

active = fields.Boolean(default=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_property_model,access_estate_property_model,model_estate_property,base.group_user,1,1,1,1
8 changes: 8 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_main_menu_button" name="Real_Estate">
<menuitem id="estate_app_top_bar_property_model_button" 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.

I wouldn't add _button at the end of the id of the menuitem, it could get misunderstood with a real action button, I would stick to the naming guidelines here

<menuitem id="estate_app_property_model_action" action="estate_property_model_action"/>
</menuitem>
</menuitem>
</odoo>
96 changes: 96 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0"?>
<odoo>

<record id="estate_property_model_search_view" model="ir.ui.view">
<field name="name">Property Lookup</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search string="Properties">
<field name="name"/>
<field name="postcode"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="facades"/>
<separator/>
<filter string="Available" name="active" domain="[('active', '=', True)]"/>
<filter string="New" name="active" domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Usually, we write the name attribute before the string :)
Your domain is correct, but I think this is more readable:

Suggested change
<filter string="New" name="active" domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]"/>
<filter name="active" string="New" domain="[('state', 'in', ('new', 'offer_received'))]"/>

<group>
<filter string="Postcode" name="postcode" context="{'group_by':'postcode', 'residual_visible':True}"/>
</group>
</search>
</field>
</record>

<record id="estate_property_model_list_view" model="ir.ui.view">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
<record id="estate_property_model_list_view" model="ir.ui.view">
<record id="estate_property_view_list" model="ir.ui.view">

just to align with the naming guidelines
You can have a quick check for the id names in the files in general

<field name="name">Properties</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Properties">
<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"/>
</list>
</field>
</record>

<record id="estate_property_model_form_view" model="ir.ui.view">
<field name="name">Properties</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<form string="Property">
<sheet>
<field name="name" style="font-size:20pt;"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

in-line styling is not encouraged, you can use the tag <h1> </h1> instead for this case or the ready to use classes (you can check some views in the codebase if you like)

<group>
<group>
<field name="postcode"/>
<field name="date_availability"/>
</group>
<group>
<field name="expected_price"/>
<field name="selling_price"/>
</group>
</group>
<notebook>
<page string="Information">
<group>
<field name="description"/>
</group>
<group>
<field name="bedrooms"/>
</group>
<group>
<field name="living_area"/>
</group>
<group>
<field name="facades"/>
</group>
<group>
<field name="has_garage"/>
</group>
<group>
<field name="has_garden"/>
</group>
<group>
<field name="garden_area"/>
</group>
<group>
<field name="garden_orientation"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

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