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
18 changes: 18 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

{
'name': 'estate',
'depends': [
'base',
],
"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_offers_views.xml",
"views/estate_property_menus.xml",
"views/estate_property_type_menus.xml",
"views/estate_property_tag_menus.xml",
],
'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_tag
from . import estate_property_offer
49 changes: 49 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from odoo import fields, models

def get_date_in_3_months() -> fields.Date:
'''
This function calculates the date that is three months from the current date.

returns:
A date object representing the date that is three months from today.
'''
today_data = fields.Date.today()
three_months_later = fields.Date.add(today_data, months=3)
return three_months_later

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

name = fields.Char(required=True)
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(copy=False, default=get_date_in_3_months())
expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True, copy=False)
bedrooms = fields.Integer(default=2)
living_area = fields.Integer()
facades = fields.Integer()
garage = fields.Boolean()
garden = fields.Boolean()
garden_area = fields.Integer()
garden_orientation = fields.Selection([
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West'),
])
state = fields.Selection([
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'),
('canceled', 'Canceled'),
], default="new", required=True, copy=False)
active = fields.Boolean(default=True)

property_type_id = fields.Many2one("estate.property.type", string="Property Type")
salesperson_id = fields.Many2one("res.users", string="Salesperson", default=lambda self: self.env.user)
buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False)
tag_ids = fields.Many2many("estate.property.tag", string="Tags")
offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers")
10 changes: 10 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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')], string='Status', copy=False)
partner_id = fields.Many2one('res.partner', string='Partner')
property_id = fields.Many2one('estate.property', string='Property')
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 fields, models

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

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 fields, models

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

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
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1
estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1
9 changes: 9 additions & 0 deletions estate/views/estate_property_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_first_level_menu" name="Advertisements" >
<menuitem id="estate_property_menu_action" action="estate_property_action"/>
</menuitem>
</menuitem>

</odoo>
33 changes: 33 additions & 0 deletions estate/views/estate_property_offers_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_offer_property_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="Property Offer">
<sheet>
<group>
<field name="price"/>
<field name="status"/>
<field name="partner_id"/>
</group>
</sheet>
</form>
</field>
</record>


<record id="estate_offer_property_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 string="Property Offers">
<field name="price"/>
<field name="status"/>
<field name="partner_id"/>
</list>
</field>
</record>


</odoo>
4 changes: 4 additions & 0 deletions estate/views/estate_property_tag_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_action" parent="settings_menu"/>
</odoo>
31 changes: 31 additions & 0 deletions estate/views/estate_property_tag_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_tag_property_view_form" model="ir.ui.view">
<field name="name">estate.property.tag.form</field>
<field name="model">estate.property.tag</field>
<field name="arch" type="xml">
<form string="Property Tag">
<sheet>
<h1>
<field name="name"/>
</h1>
</sheet>
</form>
</field>
</record>



<record id="estate_property_tag_action" 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>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Define a new estate property tag.
</p><p>
You can specify the name of each property tag.
</p>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions estate/views/estate_property_type_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="settings_menu" name="Settings" parent="estate_menu_root">
<menuitem id="estate_property_type_menu_action" action="estate_property_type_action"/>
</menuitem>
</odoo>
31 changes: 31 additions & 0 deletions estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_type__property_view_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 string="Property Type">
<sheet>
<h1>
<field name="name"/>
</h1>
</sheet>
</form>
</field>
</record>



<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>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Define a new estate property type.
</p><p>
You can specify the name and description of each property type.
</p>
</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 @@
<?xml version="1.0"?>
<odoo>

<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 string="Search 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"/>
<filter name="available" string="Available" domain="[('state', 'in', ['new', 'offer_received'])]"/>
<separator/>
<filter string="Postcode" name="group_by_postcode" context="{'group_by': 'postcode'}"/>
<separator/>
<filter string="Property Type" name="group_by_property_type" context="{'group_by': 'property_type_id'}"/>
</search>
</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="Property">
<sheet>
<h1>
<field name="name"/>
</h1>
<field name="tag_ids" widget="many2many_tags" placeholder="Add tags..."/>
<group>
<group>
<field name="property_type_id" string="Property Type"/>
<field name="postcode" string="Postcode"/>
<field name="date_availability" string="Available From"/>
</group>
<group>
<field name="expected_price" string="Expected Price"/>
<field name="selling_price" string="Selling Price"/>
</group>
</group>
<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"/>
<field name="garage" string="Garage"/>
<field name="garden" string="Garden"/>
<field name="garden_area" string="Garden Area (sqm)"/>
<field name="garden_orientation" string="Garden Orientation"/>
</group>
</page>
<page string="Offers">
<field name="offer_ids"/>
</page>
<page string="Other Info">
<group>
<field name="buyer_id" string="Buyer"/>
<field name="salesperson_id" string="Salesperson"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<record id="estate_property_view_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" string="Title"/>
<field name="postcode" string="Postcode"/>
<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"/>
<field name="property_type_id" string="Property Type"/>
</list>
</field>
</record>

<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>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Define a new estate property to sell or rent.
</p><p>
You can specify the expected price and the selling/renting price, the buyer/tenant, the salesperson, and the status of the property.
</p>
</field>
</record>
</odoo>