Skip to content

Commit

Permalink
[IMP] estate: properties menu with grid view and property details page
Browse files Browse the repository at this point in the history
- Added a 'Properties' menu on the website to display available properties in a
  grid.
- Implemented image display for properties on the front-end.
- Added a pager with a maximum of 6 properties per page.
- Created a dedicated, mobile-friendly page for each property using Bootstrap
  components.
  • Loading branch information
yasp-odoo committed Sep 3, 2024
1 parent 3abb2df commit 1cd5df5
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 2 deletions.
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import models
from . import wizard
from . import report
from . import controller
4 changes: 3 additions & 1 deletion estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
'author': 'YASP',
'website': 'https://www.yaspestate.com',
'sequence': 1,
'depends': ['base'],
'depends': ['base', 'website'],
'license': 'LGPL-3',
'data': [
'security/security.xml',
'security/ir.model.access.csv',
'data/data.xml',
'report/estate_property_offer_template.xml',
'report/estate_property_template.xml',
'report/estate_property_report.xml',
Expand All @@ -21,6 +22,7 @@
'views/estate_property_offers_views.xml',
'views/estate_property_types_views.xml',
'views/estate_property_tags_views.xml',
'views/estate_property_website_templates_views.xml',
'views/res_users_views.xml',
'views/estate_menus.xml'
],
Expand Down
2 changes: 2 additions & 0 deletions estate/controller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

from . import available_properties
27 changes: 27 additions & 0 deletions estate/controller/available_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from odoo import http
from odoo.http import request


class PropertyController(http.Controller):

@http.route(['/properties', '/properties/page/<int:page>'], auth='public', website=True)
def terms_conditions(self, page=1, **kwargs):
domain = [('state', 'not in', ['sold', 'cancelled'])]
total_properties = request.env["estate.property"].search_count(domain)
pager = request.website.pager(
url='/properties',
total=total_properties,
page=page,
step=6,
)
properties = request.env['estate.property'].search(domain, limit=6, offset=pager['offset'])
return request.render('estate.available_properties', {
'properties': properties,
'pager': pager,
})

@http.route('/property/<model("estate.property"):property_avail>', auth='public', website=True)
def property(self, property_avail, **kwargs):
return request.render('estate.property_template', {
'property': property_avail
})
11 changes: 11 additions & 0 deletions estate/data/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="menu_property" model="website.menu">
<field name="name">Properties</field>
<field name="url">/properties</field>
<field name="parent_id" ref="website.main_menu"/>
<field name="sequence" type="int">100</field>
</record>
</data>
</odoo>
2 changes: 1 addition & 1 deletion estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<menuitem id="estate_menu_properties" name="Property">
<menuitem id="estate_property_menu" action="estate_property_action"/>
</menuitem>
<menuitem id="estate_menu_properties_types" name="Settings">
<menuitem id="estate_menu_properties_types" name="Settings" groups="estate.estate_group_manager">
<menuitem id="estate_property_type_menu" action="estate_property_type_action"/>
<menuitem id="estate_property_tag_menu" action="estate_property_tag_action"/>
</menuitem>
Expand Down
76 changes: 76 additions & 0 deletions estate/views/estate_property_website_templates_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template id="available_properties" name="Properties Page">
<t t-call="website.layout">
<div class="container">
<h1><center>Available Properties</center></h1>
<div class="row">
<t t-foreach="properties" t-as="property">
<div class="col-md-4">
<div class="card">
<div class="card-body">
<img src="/estate/static/description/icon.png"/>
<h5 class="card-title"><t t-esc="property.name"/></h5>
<p class="card-text"><t t-esc="property.expected_price"/></p>
<p class="card-text"><strong>Price:</strong> <t t-esc="property.selling_price"/> USD</p>
<a t-att-href="'/property/%s' % property.id" class="btn btn-primary">View Property</a>
</div>
</div>
</div>
</t>
</div>
<br/>
<div class="col-12">
<t t-call="website.pager">
<t set="pager-url" t-value="'/properties'"/>
</t>
</div>
</div>
</t>
</template>

<template id="property_template">
<t t-call="website.layout">
<div class="container mt-3">
<div class="row">
<div class="col-md-12">
<h1 class="text-center mb-4">
<t t-esc="property.name"/>
</h1>
<div class="row">
<div class="col-md-6">
<img src="/estate/static/description/icon.png" alt="Property Image"/>
</div>
<div class="col-md-6">
<p>
<strong>Description:</strong>
<t t-esc="property.description"/>
</p>
<p>
<strong>Price:</strong>
<t t-esc="property.expected_price"/>
</p>
<p>
<strong>Bedrooms:</strong>
<t t-esc="property.bedrooms"/>
</p>
<p>
<strong>Living Area:</strong>
<t t-esc="property.living_area"/>sqm</p>
<t t-if="property.garden">
<p>
<strong>Garden Area:</strong>
<t t-esc="property.garden_area"/> sqm</p>
<p>
<strong>Garden Orientation:</strong>
<t t-esc="property.garden_orientation"/>
</p>
</t>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
</odoo>

0 comments on commit 1cd5df5

Please sign in to comment.