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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["odoo"]
}
Comment on lines +1 to +3
Copy link

Choose a reason for hiding this comment

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

Suggested change
{
"cSpell.words": ["odoo"]
}

This file should be removed. Editor-specific settings do not belong in the source code of an Odoo module.

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
11 changes: 11 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
'name': "Real Estate",
'application': True,
'installable': True,
'depends': ['base'],
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_menus_views.xml',
]
}
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
from . import estate_property_tag
65 changes: 65 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from odoo import fields, models
from datetime import timedelta


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

name = fields.Char('Name', required=True, default='My new house')
description = fields.Text('Description')
active = fields.Boolean(default=True)
postcode = fields.Char('Postcode')
date_availability = fields.Date('Available From',default=lambda self: fields.Date.today() + timedelta(days=90), copy=False)
Copy link

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('Available From',default=lambda self: fields.Date.today() + timedelta(days=90), copy=False)
date_availability = fields.Date('Available From',default=lambda self: fields.Date.context_today(self) + timedelta(days=90), copy=False)

Here, it's better to use fields.Date.context_today() for setting a default to the current date, because it correctly handles the user's timezones.

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 (sqm)')
facades = fields.Integer('#Facades')
garage = fields.Boolean('Garage')
garden = fields.Boolean('Garden')
garden_area = fields.Integer('Garden area')
garden_orientation = fields.Selection(
string='type',
Copy link

Choose a reason for hiding this comment

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

why "type" ?

selection=[
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West')
])

state = fields.Selection(
[
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'),
('cancelled', 'Cancelled'),
],
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_type_id = fields.Many2one(
"estate.property.type",
string="Property Type"
)


tag_ids = fields.Many2many(
"estate.property.tag",
string="Tags"
)
7 changes: 7 additions & 0 deletions estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import models, fields

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

name = fields.Char(required=True)
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 = "Estate property type"

name = fields.Char('Name', 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
access_estate_property_tag,access.estate.property.tag,model_estate_property_tag,base.group_user,1,1,1,1
23 changes: 23 additions & 0 deletions estate/views/estate_menus_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_menu_root" name="Estate">
<menuitem id="estate_property_menu" name="Property">
<menuitem
id="estate_property_menu_action"
action="estate_property_model_action"
/>
</menuitem>

<menuitem id="estate_property_type_menu" name="Settings">
<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>
146 changes: 146 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_model_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_type_action" model="ir.actions.act_window">
<field name="name">Settings</field>
<field name="res_model">estate.property.type</field>
<field name="view_mode">list,form</field>
</record>

<record id="estate_property_taf_action" model="ir.actions.act_window">
Copy link

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_taf_action" model="ir.actions.act_window">
<record id="estate_property_tag_action" model="ir.actions.act_window">

This is just a small typo, but it means that the estate_property_tag_menu_action menu item that references this action is not working

<field name="name">Settings</field>
<field name="res_model">estate.property.type</field>
<field name="view_mode">list,form</field>
</record>

<record id="estate_property_view_tree" model="ir.ui.view">
<field name="name">estate.property.list</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Title">
<field name="name" />
<field name="description" />
<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_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="Estate Property">
<sheet>
<div class="oe_title mb32">
<h1>
<field name="name" class="mb16" />
</h1>
</div>
<group class="d-flex justify-content-between">
<group>
<field name="postcode" class="mb16" />
</group>

<group>
<field name="expected_price" class="mb16" />
</group>
</group>

<group class="d-flex justify-content-between mb32">
<group>
<field name="date_availability" class="mb16" />
</group>

<group>
<field name="selling_price" class="mb16" />
</group>

<group>
<field name="tag_ids" widget="many2many_tags" />
</group>

<group>
<field name="tag_ids" widget="many2many_tags" />
</group>
Comment on lines +67 to +73
Copy link

Choose a reason for hiding this comment

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

why render the tag_ids field twice ?

</group>

<notebook>
<page string="Description">
<group class="d-flex flex-column">
<group>
<field name="description" class="mb4" />
</group>
<group>
<field name="bedrooms" class="mb4" />
</group>
<group>
<field name="living_area" class="mb4" />
</group>
<group>
<field name="facades" class="mb4" />
</group>
<group>
<field name="garage" class="mb4" />
</group>
<group>
<field name="garden" class="mb4" />
</group>
<group>
<field name="garden_area" class="mb4" />
</group>
<group>
<field name="garden_orientation" class="mb4" />
</group>
Comment on lines +79 to +102
Copy link

Choose a reason for hiding this comment

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

why make a new group for each field ?

</group>
</page>
<page string="Sales">
<group>
<field name="salesperson_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.property.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search string="Search Properties">
<field name="name" string="Title" />
<field name="postcode" string="Postcode" />
<field name="expected_price" string="Postcode" />
Copy link

Choose a reason for hiding this comment

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

Suggested change
<field name="expected_price" string="Postcode" />
<field name="expected_price" string="Expected Price" />

Small copy-paste error.

<field name="bedrooms" string="Bedrooms" />
<field name="living_area" string="Living Area" />

<filter
name="active"
string="Available"
domain="[
('active', '=', True)
]"
/>

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