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'],
'application': True,
'installable': True,
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_property_type_views.xml',
'views/estate_property_tag_views.xml',
'views/estate_property_offer_views.xml',
'views/estate_menu.xml',
],
'author': 'macai',
'license': 'LGPL-3',
}
4 changes: 4 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import estate_property
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offer
52 changes: 52 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from odoo import models, fields


class EstateProperty(models.Model):
_name = 'estate.property'
_description = 'Real Estate property model'

# Property information
name = fields.Char('Name', required=True)
description = fields.Text('Description')
postcode = fields.Char('Postcode', required=True)
date_availability = fields.Date('Availability', copy=False, default=lambda self: fields.Date.add(fields.Date.today(), months=3))
expected_price = fields.Float('Expected Price', required=True)
selling_price = fields.Float('Selling Price', readonly=True, copy=False)
bedrooms = fields.Integer('Bedrooms', default=2)
living_area = fields.Integer('Living Area')
facades = fields.Integer('Facades')
has_garage = fields.Boolean('Garage')
has_garden = fields.Boolean('Garden')
garden_area = fields.Integer('Garden Area')
garden_orientation = fields.Selection(
string='Garden Orientation',
selection=[('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West'),
]
)
active = fields.Boolean('Active', default=True)
state = fields.Selection(
string='State',
selection=[('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer accepted'),
('sold', 'Sold'),
('cancelled', 'Cancelled'),
],
required=True,
copy=False,
default='new'
)
Comment on lines +21 to +28

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 one line on the selection field is okay but when you have many values, it's better to have it like this.
Also, it's preferable to have the key as all small letters, so no confusion happens when they are used inside the code in if statements for example.

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
But I see you have all single quotes so good for me but thought to mention it so you know.

Suggested change
garden_orientation = fields.Selection(
string='Garden Orientation',
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')
]
)

property_type_id = fields.Many2one("estate.property.type", string='Property Type')

# Other Information
salesman_id = fields.Many2one('res.users', string='Salesman', default=lambda self: self.env.user)
buyer_id = fields.Many2one('res.partner', string='Buyer', copy=False)

# Tags
tag_ids = fields.Many2many('estate.property.tag', string='Tags')

# Offers
offer_ids = fields.One2many('estate.property.offer', 'property_id', string='Offer')
14 changes: 14 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from odoo import models, fields


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

price = fields.Float(string='Price')
status = fields.Selection([
('accepted', 'Accepted'),
('refused', 'Refused')
], copy=False, string='Status')
partner_id = fields.Many2one('res.partner', required=True, string='Partner')
property_id = fields.Many2one('estate.property', required=True)
8 changes: 8 additions & 0 deletions estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from odoo import models, fields


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

name = fields.Char(string='Name', required=True)
8 changes: 8 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from odoo import models, fields


class EstatePropertyType(models.Model):
_name = 'estate.property.type'
_description = 'Define the Real Estate Property Type'

name = fields.Char(string='Name', required=True)
5 changes: 5 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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
access_estate_property_type_user,access.estate.property.type,model_estate_property_type,base.group_user,1,1,1,1
access_estate_property_tag_user,access.estate.property.tag,model_estate_property_tag,base.group_user,1,1,1,1
access_estate_property_offer_user,access.estate.property.offer,model_estate_property_offer,base.group_user,1,1,1,1
12 changes: 12 additions & 0 deletions estate/views/estate_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_application_menu_root" name="Real Estate">
<menuitem id="estate_advertisement_menu" name="Advertisements" sequence="1">
<menuitem id="estate_menu_action" action="estate_property_action"/>
</menuitem>
<menuitem id="setting_menu" name="Settings" sequence="2">
<menuitem id="estate_property_type_menu_action" action="estate_property_type_action"/>
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_action"/>
</menuitem>
</menuitem>
</odoo>
30 changes: 30 additions & 0 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<odoo>

<record id="estate_property_offer_view_list" model="ir.ui.view">
<field name="name">estate.property.offer.list</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<list>
<field name="price"/>
<field name="partner_id"/>
<field name="status"/>
</list>
</field>
</record>

<record id="estate_property_offer_view_form" model="ir.ui.view">
<field name="name">estate.property.offer.form</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<form>
<group>
<field name="price"/>
<field name="partner_id"/>
<field name="status"/>
</group>
</form>
</field>
</record>

</odoo>
10 changes: 10 additions & 0 deletions estate/views/estate_property_tag_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<odoo>

<record id="estate_property_tag_action" model="ir.actions.act_window">
<field name="name">Tags</field>
<field name="res_model">estate.property.tag</field>
<field name="view_mode">list,form</field>
</record>

</odoo>
10 changes: 10 additions & 0 deletions estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<odoo>

<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>
107 changes: 107 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0"?>
<odoo>

<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,search</field>
</record>

<record id="estate_property_view_list" model="ir.ui.view">
<field name="name">estate.properties.list</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list>
<field name="name" string="Title"/>
<field name="postcode" string="Postcode"/>
<field name="tag_ids" string="Tags" widget="many2many_tags"/>
<field name="bedrooms" string="Bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="expected_price" string="Expected Price"/>
<field name="selling_price" string="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.properties.form</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<form string="Properties">
<sheet>
<h1>
<field name="name"/>
</h1>
<h2>
<field name="tag_ids" widget="many2many_tags"/>
</h2>
<div class="row align-items-start">
<div class="col">
<group>
<field name="property_type_id"/>
<field name="postcode" string="Postcode"/>
<field name="date_availability" string="Available From"/>
</group>
</div>
<div class="col">
<group>
<field name="expected_price" string="Expected Price"/>
<field name="selling_price" string="Selling Price"/>
</group>
</div>
</div>
<notebook>
<page string="Description">
<group>
<field name="description" string="Description"/>
<field name="bedrooms" string="Bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="facades" string="Facades"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it's totally correct to have string attribute on the field in the xml view but you can have it on the field definition on the python model and don't use it here so you don't have to add the string attribute every time you use it in a view (unless you want to show it differently in certain views)

<field name="has_garage" string="Garage"/>
<field name="has_garden" string="Garden"/>
<field name="garden_area" string="Garden Area (sqm)"/>
<field name="garden_orientation" string="Garden Orientation"/>
<field name="state" string="State"/>
</group>
</page>
<page string="Offers">
<list>
<field name="offer_ids"/>
</list>
</page>
<page string="Other Info">
<group>
<field name="salesman_id"/>
<field name="buyer_id"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<record id="estate_property_view_search" model="ir.ui.view">
<field name="name">estate.properties.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search string="Properties">
<field name="name" string="Title"/>
<field name="postcode" string="Postcode"/>
<field name="expected_price" string="Expected Price"/>
<field name="bedrooms" string="Bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="facades" string="Facades"/>
<separator/>
<filter name="active" string="Available" domain="[('state', 'in', ('new', 'offer_received'))]"/>
<separator/>
<group>
<filter string="Postcode" name="postcode" context="{'group_by':'postcode'}"/>
</group>
</search>
</field>
</record>


</odoo>