Skip to content

Commit

Permalink
[IMP] estate: added web controller
Browse files Browse the repository at this point in the history
After this commit:
-added properties tab on home page
-added property description display cards
  • Loading branch information
smee-odoo committed Sep 2, 2024
1 parent 737fe19 commit 0e03e08
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 3 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 @@ -4,13 +4,14 @@
'category': 'Real Estate/Brokerage',
'description': "",
'depends': [
'base_setup',
'base_setup', 'website'
],
'data': [
'security/security.xml',
'security/ir.model.access.csv',

'data/estate_property_type_data.xml',
'data/data.xml',

'wizard/estate_property_offer_wizard_view.xml',

Expand All @@ -23,6 +24,7 @@
'views/estate_property_type_menu.xml',
'views/estate_property_tag_view.xml',
'views/estate_property_tag_menu.xml',
'views/estate_portal_templates.xml',
'views/res_users_view.xml'
],
'demo': [
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 property
18 changes: 18 additions & 0 deletions estate/controller/property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from odoo.http import route, Controller, request


class PropertyController(Controller):

@route('/properties', auth='public', website='True')
def handlePropertyPortal(self):
values = {
"properties": request.env['estate.property'].search([])
}
return request.render('estate.portal_estate_property_list', values)

@route("/property/<model('estate.property'):prop>", auth='public', website='True')
def handlePropertyDetailPortal(self, prop):
values = {
"property": prop
}
return request.render('estate.portal_estate_property_detail', values)
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"?>
<odoo>
<data noupdate="1">
<record id="menu_properties" 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>
1 change: 1 addition & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class EstateProperty(models.Model):
required=True,
default=lambda self: self.env.company.id
)
image = fields.Image("Image")

@api.depends("living_area", "garden_area")
def _compute_total_area(self):
Expand Down
6 changes: 4 additions & 2 deletions estate/security/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<field name="comment">The user will be the manager.</field>
<field name="category_id" ref="base.module_category_real_estate_brokerage" />
<field name="implied_ids" eval="[(4, ref('group_estate_user'))]" />
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>

<record id="rule_agent_property_access" model="ir.rule">
Expand All @@ -23,6 +24,7 @@
<field name="groups" eval="[(4, ref('group_estate_user'))]" />
<field name="domain_force">['|', ('seller_id', '=', False), ('seller_id', '=', user.id)]</field>
</record>

<record id="rule_manager_property_access" model="ir.rule">
<field name="name">Manager access rule</field>
<field name="model_id" ref="model_estate_property" />
Expand All @@ -41,7 +43,7 @@
<field name="perm_write" eval="0" />
<field name="perm_create" eval="0" />
<field name="perm_unlink" eval="0" />
<field name="groups" eval="[(4, ref('group_estate_user'))]" />
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
<!-- <field name="groups" eval="[(4, ref('group_estate_user'))]" /> -->
<field name="domain_force">[('company_id', 'in', company_ids)]</field>
</record>
</odoo>
Binary file added estate/static/Description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions estate/views/estate_portal_templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0"?>
<odoo>
<template id="portal_estate_property_list" name="All Available Property">
<t t-call="website.layout">
<div id="wrap">
<h1>Properties</h1>
<div class="container">
<div class="row">
<t t-foreach="properties" t-as="property">
<div class="col-md-4 mb-4">
<div class="card h-100">
<img src="/estate/static/Description/icon.png" class="card-img-top img-thumbnail" loading="lazy" />
<div class="card-body">
<h5 class="card-title">
<t t-esc="property.name"/>
</h5>
<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>
</div>
</div>
</t>
</template>

<template id="portal_estate_property_detail" name="Property Detail">
<t t-call="website.layout">
<div class="container mt-5">
<div class="row">
<div class="col-md-12">
<h1 class="text-center">
<t t-esc="property.name"/>
</h1>
<div class="row">
<div class="col-md-6">
<img src="/estate/static/Description/icon.png" class="img-fluid"/>
</div>
<div class="col-md-6">
<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 0e03e08

Please sign in to comment.