Skip to content
Draft
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
21 changes: 21 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
'name': 'Estate',
'summary': 'Manage properties listing and offers',
'description': "A simple module to manage real estate properties and track offers made by buyers.",
'author': 'Mohit Ahir (moahi)',
'website': '',
'category': 'Estate',
'version': '1.0',
'license': 'LGPL-3',
'depends': ['base'],
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_property_type_views.xml',
'views/estate_property_tags_views.xml',
'views/estate_property_offer_views.xml',
'views/estate_menus.xml',
],
'installable': True,
'application': True,
}
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_tags
from . import estate_property_offer
46 changes: 46 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from odoo import models, fields

from datetime import timedelta


class EstateProperty(models.Model):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What are the different types of models which we can use?
Also why have you used models.Model here specifically?

_name = 'estate.property'
_description = 'Real Estate Property'

name = fields.Char(string="Title", required=True)
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(string="Available from", copy=False, default=lambda self: fields.Date.today() + timedelta(days=90))
expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True, copy=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do you know like where should we give readonly?

  1. While declaring a field in .py file
  2. While displaying it in UI side

bedrooms = fields.Integer(default=2)
living_area = fields.Integer(string="living Area (sqm)")
facades = fields.Integer()
garage = fields.Boolean()
garden = fields.Boolean()
garden_area = fields.Integer(string="Garden Area (sqm)")

garden_orientation = fields.Selection(
[
('north', "North"),
('south', "South"),
('east', "East"),
('west', "West")
]
)
active = fields.Boolean(default=True)
state = fields.Selection(
[
('new', "New"),
('offer_received', "Offer Received"),
('offer_accepted', "Offer Accepted"),
('sold', "Sold"),
('cancelled', "Cancelled")
],
string="Status", required=True, copy=False, default='new')

property_type_id = fields.Many2one('estate.property.type', string="Property Type")
buyer_id = fields.Many2one('res.partner', string="Buyer", copy=False)
seller_id = fields.Many2one('res.users', string="Seller", default=lambda self: self.env.user)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is a lambda function? And why do we need to use this function here?

tag_id = fields.Many2many('estate.property.tags', string="Property tags")
offer_ids = fields.One2many('estate.property.offer', 'property_id')
17 changes: 17 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import models, fields


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

price = fields.Float()
status = fields.Selection(
[
('Accepted', "Accepted"),
('Refused', "Refused")
]
, copy=False)
Comment on lines +9 to +14
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
status = fields.Selection(
[
('Accepted', "Accepted"),
('Refused', "Refused")
]
, copy=False)
status = fields.Selection(
[
('accepted', "Accepted"),
('refused', "Refused")
],
copy=False)

Try keeping the key in lowercase


partner_id = fields.Many2one('res.partner', required=True)
property_id = fields.Many2one('estate.property', required=True)
8 changes: 8 additions & 0 deletions estate/models/estate_property_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from odoo import models, fields


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

name = fields.Char(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 = 'Property Type'

name = fields.Char(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,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_tags,access_estate_property_tags,model_estate_property_tags,base.group_user,1,1,1,1
access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1
34 changes: 34 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<odoo>

<!-- Root Menu -->
<menuitem id="estate_menu_root"
name="Real Estate"/>

<!-- First Level Menu -->
<menuitem id="estate_menu_properties"
name="Advertisements"
parent="estate_menu_root"/>

<!-- Action Menu for properties -->
<menuitem id="estate_menu_properties_action"
name="Properties"
parent="estate_menu_properties"
action="estate_property_action"/>

<!-- First Level Menu -->
<menuitem id="estate_menu_properties_settings"
name="Settings"
parent="estate_menu_root"/>

<!-- Action Menu for properties type-->
<menuitem id="estate_menu_property_type"
name="Property Types"
parent="estate_menu_properties_settings"
action="estate_property_type_action"/>

<menuitem id="estate_menu_property_tags"
name="Property tags"
parent="estate_menu_properties_settings"
action="estate_property_tags_action"/>

</odoo>
32 changes: 32 additions & 0 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<odoo>

<record id="estate_property_offer_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_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>
<sheet>
<group>
<field name="price"/>
<field name="partner_id"/>
<field name="status"/>
<field name="property_id"/>
</group>
</sheet>
</form>
</field>
</record>

</odoo>
23 changes: 23 additions & 0 deletions estate/views/estate_property_tags_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<odoo>

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

<record id="view_estate_property_tag_form" model="ir.ui.view">
<field name="name">estate.property.tags.form</field>
<field name="model">estate.property.tags</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>

</odoo>
33 changes: 33 additions & 0 deletions estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<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>

<record id="view_estate_property_type_list" model="ir.ui.view">
<field name="name">estate.property.type.list</field>
<field name="model">estate.property.type</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
</list>
</field>
</record>

<record id="view_estate_property_type_form" model="ir.ui.view">
<field name="name">estate.property.type.form</field>
<field name="model">estate.property.type</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>

</odoo>
102 changes: 102 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<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</field>
</record>

<record id="estate_property_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">
<field name="name"/>
<field name="postcode"/>
<field name="date_availability"/>
<field name="selling_price"/>
<field name="bedrooms"/>
<field name="living_area"/>
</list>
</field>
</record>

<record id="estate_property_search" model="ir.ui.view">
<field name="name">estate.property.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<field name="postcode"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="facades"/>
<filter name="available" string="Available"
domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]"/>
Comment on lines +35 to +36
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you rewrite this domain in an optimized way?

<filter name="group_postcode" string="Postcode"
context="{'group_by':'postcode'}"/>
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
context="{'group_by':'postcode'}"/>
context="{'group_by': 'postcode'}"/>

</search>
</field>
</record>

<record id="estate_property_form" model="ir.ui.view">
<field name="name">estate.property.form</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<form>
<sheet>

<h1>
<field name="name" placeholder="Enter title..."/>
</h1>

<group>
<group>
<field name="tag_id" widget="many2many_tags"/>
<field name="postcode"/>
Comment on lines +48 to +57
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
<sheet>
<h1>
<field name="name" placeholder="Enter title..."/>
</h1>
<group>
<group>
<field name="tag_id" widget="many2many_tags"/>
<field name="postcode"/>
<sheet>
<h1>
<field name="name" placeholder="Enter title..."/>
</h1>
<group>
<group>
<field name="tag_id" widget="many2many_tags"/>
<field name="postcode"/>

Remove unnecessary empty lines from the entire file

<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"/>
<field name="property_type_id"/>
</group>
</page>

<page string="Other info">
<group>
<field name="buyer_id"/>
<field name="seller_id"/>
</group>
</page>

<page string="Offers">
<field name="offer_ids"/>
</page>

</notebook>

</sheet>
</form>
</field>
</record>

</odoo>