Skip to content

Commit

Permalink
[IMP] estate: Implemented Controller
Browse files Browse the repository at this point in the history
after this commit:
     Implemented controller
  • Loading branch information
niku-odoo committed Sep 2, 2024
1 parent 896463e commit 180547e
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 1 deletion.
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import models
from . import wizard
from . import controller
4 changes: 3 additions & 1 deletion estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'category': 'Real Estate/Brokerage',
'summary': 'Module for managing real estate properties.',
'author': 'Your Name',
'depends': ['base'],
'depends': ['base', 'website'],
'license': 'LGPL-3',
'data': [
'security/security.xml',
Expand All @@ -17,6 +17,8 @@
'view/res_users_view.xml',
'view/estate_menus.xml',
'data/property_type.xml',
'data/data.xml',
'view/estate_property_controller_view.xml',
'report/estate_property_template.xml',
'report/estate_property_report.xml',
'report/estate_property_subtemplate.xml'
Expand Down
1 change: 1 addition & 0 deletions estate/controller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import estate_property_controller
30 changes: 30 additions & 0 deletions estate/controller/estate_property_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from odoo import http
from odoo.http import request


class EstatePropertyController(http.Controller):

@http.route(['/properties', '/properties/page/<int:page>'], type='http', auth='public', website=True)
def property_list(self, page=1, **searches):
Property = request.env['estate.property']
domain = [('state', 'in', ['new', 'offer Received', 'offer Accepted'])]

properties_count = Property.search_count(domain)
pager = request.website.pager(
url='/properties',
total=properties_count,
page=page,
step=6,
)

properties = Property.search(domain, limit=6, offset=pager['offset'])
return request.render('estate.property_listing', {
'properties': properties,
'pager': pager,
})

@http.route('/property/<model("estate.property"):estate_property>', type='http', auth='public', website=True)
def property_detail(self, estate_property, **kwargs):
return request.render('estate.property_detail', {
'property': estate_property,
})
18 changes: 18 additions & 0 deletions estate/data/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="menu_estate_property" model="website.menu">
<field name="name">Available Properties</field>
<field name="url">/properties</field>
<field name="parent_id" ref="website.main_menu" />
</record>
</data>

<data noupdate="1">
<record id="menu_estate_property1" model="website.menu">
<field name="name">Properties</field>
<field name="url">/properties</field>
<field name="parent_id" ref="website.main_menu" />
</record>
</data>
</odoo>
97 changes: 97 additions & 0 deletions estate/view/estate_property_controller_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="property_listing" name="Property Listing">
<t t-call="website.layout">
<div class="container mt-5">
<h1 class="text-center">
Available Properties
</h1>
<div class="row">
<t t-foreach="properties" t-as="property">
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">
<t t-esc="property.name" />
</h5>
<p class="card-text">
<t t-esc="property.description" />
</p>
<a t-att-href="'/property/%s' % property.id"
class="btn btn-primary">
View Property
</a>
</div>
<div class="card-footer">
<small class="text-muted"> Price: <t
t-esc="property.expected_price" />
</small>
</div>
</div>
</div>
</t>
</div>
<t t-call="website.pager" t-set="pager" />
</div>
</t>
</template>
<template id="property_detail" name="Property Detail">
<t t-call="website.layout">
<!-- <t t-set="title">Modern Apartment</t> -->
<t t-set="head">
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
</t>
<div class="container mt-5">
<div class="row">
<div class="col-md-12 text-center">
<h1 class="display-4">
<t t-esc="property.name" />
</h1>
</div>
</div>
<div class="row">
<!-- <div class="col-md-6">
<t t-if="property.image">
<img t-att-src="'data:image/png;base64,%s' % property.image.decode()"
class="img-fluid rounded shadow" alt="Property Image" />
</t>
</div> -->
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Property Details</h5>
<p class="card-text">
<strong>Description: </strong>
<t t-esc="property.description" />
</p>
<p class="card-text">
<strong>Price: </strong>
<t t-esc="property.expected_price" />
</p>
<p class="card-text">
<strong>Bedrooms: </strong>
<t t-esc="property.bedrooms" />
</p>
<p class="card-text">
<strong>Living Area: </strong>
<t t-esc="property.living_area" />
sqm </p>
<t t-if="property.garden">
<p class="card-text">
<strong>Garden Area: </strong>
<t
t-esc="property.garden_area" />sqm </p>
<p class="card-text">
<strong>Garden Orientation: </strong>
<t t-esc="property.garden_orientation" />
</p>
</t>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
</odoo>

0 comments on commit 180547e

Please sign in to comment.