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
3 changes: 3 additions & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import models
24 changes: 24 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
'name': 'Real Estate',
'description': 'A Module which covers all workflows related to real estate',
'summary': 'Module to track all things related to real estate of any company',
'version': '1.0',
'category': 'Estate',
'depends': [
'base'
],
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_property_tag_views.xml',
'views/estate_property_type_views.xml',
'views/estate_property_offer_views.xml',
'views/estate_property_menus.xml',
],
'license': 'LGPL-3',
'installable': True,
'application': True,
'auto_install': False
}
6 changes: 6 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import estate_property
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offer
88 changes: 88 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from datetime import datetime, timedelta
from odoo import api, models, fields, exceptions


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

name = fields.Char(string='Estate Property Name', required=True)
description = fields.Text(string='Estate Property Description')
postcode = fields.Char(string='Estate Property Postcode')
date_availability = fields.Date(string='Estate Property Date Availability', copy=False, default=lambda self: datetime.now() + timedelta(days=90))
expected_price = fields.Float(string='Expected Price Of Property', required=True)
selling_price = fields.Float(string='Selling Price of Property', readonly=True, copy=False)
bedrooms = fields.Integer(string='Number of Bedrooms in Property', default=2)
living_area = fields.Integer(string='Number of Living Room in Property')
facades = fields.Integer(string='Number of Facades in Property')
garage = fields.Boolean(string='Property have garage or not')
garden = fields.Boolean(string='Property have Garden or not')
garden_area = fields.Integer(string='Number of Garden Area')
garden_orientation = fields.Selection(
string='Orientation of Garden',
selection=[
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West')
],
help='Different Types of Directions')
active = fields.Boolean(default=True)
state = fields.Selection(
string='State',
default='new',
copy=False,
required=True,
selection=[
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'),
('cancel', 'Cancelled')
],
help='State of the property')
property_type_id = fields.Many2one('estate.property.type', string='Property Type Id')
buyer_id = fields.Many2one('res.partner', string='Buyer', copy=False)
salesman_id = fields.Many2one('res.users', string='Salesman', default=lambda self: self.env.user)
tag_ids = fields.Many2many('estate.property.tag', string='Estate property Tag')
offer_ids = fields.One2many('estate.property.offer', 'property_id', string='offer')
total_area = fields.Float(compute='_compute_total_area')
best_price = fields.Float(compute='_compute_best_price', string='Best Offer Price')

@api.depends('living_area', 'garden_area')
def _compute_total_area(self):
for record in self:
record.total_area = record.garden_area + record.living_area

@api.depends('offer_ids.price')
def _compute_best_price(self):
for record in self:
record.best_price = max(record.offer_ids.mapped('price'), default=0.0)

@api.onchange('garden')
def _on_change_garden(self):
for record in self:
if self.garden:
record.garden_area = 10
record.garden_orientation = 'north'
else:
record.garden_area = False
record.garden_orientation = False

def property_sold_action(self):
for record in self:
if record.state == 'cancel':
raise exceptions.UserError('Cancelled property can not be sold')
else:
record.state = 'sold'
return True

def property_cancel_action(self):
for record in self:
if record.state == 'sold':
raise exceptions.UserError('Sold property can not be cancelled')
else:
record.state = 'cancel'
return True
50 changes: 50 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from datetime import timedelta
from odoo import api, fields, models


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

price = fields.Float(string='Offer Price')
status = fields.Selection(
string='Status',
copy=False,
selection=[
('accepted', 'Accepted'),
('refused', 'Refused')
])
partner_id = fields.Many2one('res.partner', required=True)
property_id = fields.Many2one('estate.property', required=True)
created_date = fields.Date(default=fields.Date.context_today, string='Created Date')
validity = fields.Integer(default=7, string='Validity (Days)')
date_deadline = fields.Date(compute='_compute_date_deadline', inverse='_inverse_date_deadline', string='Deadline Date', store='True')

@api.depends('created_date', 'validity')
def _compute_date_deadline(self):
for record in self:
if record.created_date and record.validity:
record.date_deadline = record.created_date + timedelta(days=record.validity)
else:
record.date_deadline = False

def _inverse_date_deadline(self):
for record in self:
if record.date_deadline and record.created_date:
record.validity = (record.date_deadline - record.created_date).days
else:
record.validity = 0

def offer_accepted_action(self):
for record in self:
record.status = 'accepted'
record.property_id.buyer_id = record.partner_id
record.property_id.selling_price = record.price
return True

def offer_refused_action(self):
for record in self:
record.status = 'refused'
return True
10 changes: 10 additions & 0 deletions estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import models, fields


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

name = fields.Char(string='Estate Property Tag', required=True)
10 changes: 10 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import models, fields


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

name = fields.Char(string='Estate Property Type', 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_tag,access_estate_property_tag,model_estate_property_tag,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
18 changes: 18 additions & 0 deletions estate/views/estate_property_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

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

<!-- Advertisement Menu -->
<menuitem id="estate_advertisement_menu" name="Advertisement">
<menuitem id="estate_property_menu_action" action="estate_property_actions" />
</menuitem>

<!-- Settings Menu -->
<menuitem id="estate_settings_menu" name="Settings">
<menuitem id="estate_property_type_menu_action" action="estate_property_type_actions" />
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_actions" />
</menuitem>
</menuitem>
</odoo>
40 changes: 40 additions & 0 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<!-- List View -->
<record id="estate_property_offer_view" 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" string="Price" />
<field name="partner_id" string="Partner" />
<field name="validity" string="Validity (days)" />
<field name="date_deadline" string="Deadline" />
<button name="offer_accepted_action" string="Accept" type="object" icon="fa-check" />
<button name="offer_refused_action" string="Refuse" type="object" icon="fa-times" />
<field name="status" />
</list>
</field>
</record>

<!-- Form View -->
<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 string="Offer Price Form">
<sheet>
<group>
<field name="price" string="Price" />
<field name="partner_id" string="Partner" />
<field name="validity" string="Validity (days) " />
<field name="date_deadline" string="Deadline" />
<field name="status" />
</group>
</sheet>
</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" encoding="utf-8"?>
<odoo>

<record id="estate_property_tag_actions" model="ir.actions.act_window">
<field name="name">Property 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" encoding="utf-8"?>
<odoo>

<record id="estate_property_type_actions" 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>
Loading