Skip to content

Commit

Permalink
[IMP] estate: updated controller-added property as menu-item
Browse files Browse the repository at this point in the history
Added images to demo data for card view of properties on the
website. configured menu item named properties in the navbar.
  • Loading branch information
dija-odoo committed Jan 16, 2025
1 parent 284dcb3 commit 3b3e869
Show file tree
Hide file tree
Showing 31 changed files with 241 additions and 317 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"python.languageServer": "None"
}
}
2 changes: 1 addition & 1 deletion estate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import models,wizard,controllers
from . import models,wizard,controllers
8 changes: 1 addition & 7 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
'depends': [
'base', 'website'
],

'data':[
'security/security.xml',
'security/ir.model.access.csv',
Expand All @@ -26,18 +25,13 @@
'report/estate_property_templates.xml',
'report/estate_property_reports.xml',
'wizard/estate_property_make_bulk_offer.xml',

],

'demo':[
'demo/estate_property.xml',
'demo/estate_property_offer.xml'

],

'application': True,
'installable':True,
'auto_install':True,
'license': 'LGPL-3',

}
}
2 changes: 1 addition & 1 deletion estate/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import main
from . import main
5 changes: 2 additions & 3 deletions estate/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import http, fields, tools, models
from odoo import http
from odoo.http import request

class list_properties_website(http.Controller):
Expand All @@ -18,7 +18,6 @@ def properties(self, page=1):
], limit=items_per_page, offset=(page - 1) * items_per_page)
pager = request.website.pager(
url="/properties",

total=total_properties,
page=page,
step=items_per_page,
Expand All @@ -38,4 +37,4 @@ def property_details(self, property):

return request.render('estate.property_details_template', {
'property': property,
})
})
165 changes: 104 additions & 61 deletions estate/demo/estate_property.xml
Original file line number Diff line number Diff line change
@@ -1,74 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="big_villa" model="estate.property">
<field name="name">Big Villa</field>
<field name="state">new</field>
<field name="description">A nice and big villa</field>
<field name="postcode">12345</field>
<field name="date_availability">2020-02-02</field>
<field name="expected_price">1600000</field>
<field name="selling_price">0</field>
<field name="bedrooms">6</field>
<field name="living_area">100</field>
<field name="facades">4</field>
<field name="garage">True</field>
<field name="garden">True</field>
<field name="garden_area">100000</field>
<field name="garden_orientation">south</field>
<field name="property_type_id" ref="1" />
</record>
<record id="big_villa" model="estate.property">
<field name="name">Big Villa</field>
<field name="state">new</field>
<field name="description">A nice and big villa</field>
<field name="postcode">12345</field>
<field name="date_availability">2020-02-02</field>
<field name="expected_price">1600000</field>
<field name="selling_price">0</field>
<field name="bedrooms">6</field>
<field name="living_area">100</field>
<field name="facades">4</field>
<field name="garage">True</field>
<field name="garden">True</field>
<field name="garden_area">100000</field>
<field name="garden_orientation">south</field>
<field name="property_type_id" ref="1" />
<field name="property_image" type="base64" file="estate/static/images/oneimage.jpg"/>
</record>

<record id="trailer_home" model="estate.property">
<field name="name">Trailer home</field>
<field name="state">cancelled</field>
<field name="description">Home in a trailer park</field>
<field name="postcode">54321</field>
<field name="date_availability">1970-01-01</field>
<field name="expected_price">100000</field>
<field name="selling_price">120000</field>
<field name="bedrooms">1</field>
<field name="living_area">10</field>
<field name="facades">4</field>
<field name="garage">False</field>
<field name="property_type_id" ref="1" />
</record>
<record id="trailer_home" model="estate.property">
<field name="name">Trailer home</field>
<field name="state">cancelled</field>
<field name="description">Home in a trailer park</field>
<field name="postcode">54321</field>
<field name="date_availability">1970-01-01</field>
<field name="expected_price">100000</field>
<field name="selling_price">120000</field>
<field name="bedrooms">1</field>
<field name="living_area">10</field>
<field name="facades">4</field>
<field name="garage">False</field>
<field name="property_type_id" ref="1" />
<field name="property_image" type="base64" file="estate/static/images/twoimage.jpg"/>

<record id="penthouse_airy" model="estate.property">
<field name="name">Super Ventilated Pent house</field>
<field name="state">new</field>
<field name="description">airy and ventilated penthouse</field>
<field name="postcode">54321</field>
<field name="date_availability">1970-01-01</field>
<field name="expected_price">12000</field>
<field name="selling_price">1400000</field>
<field name="bedrooms">6</field>
<field name="living_area">120</field>
<field name="facades">4</field>
<field name="garage">False</field>
<field name="property_type_id" ref="1" />
<!-- <field name="offer_ids" eval="[
</record>

<record id="penthouse_airy" model="estate.property">
<field name="name">Super Ventilated Pent house</field>
<field name="state">new</field>
<field name="description">airy and ventilated penthouse</field>
<field name="postcode">54321</field>
<field name="date_availability">1970-01-01</field>
<field name="expected_price">12000</field>
<field name="selling_price">1400000</field>
<field name="bedrooms">6</field>
<field name="living_area">120</field>
<field name="facades">4</field>
<field name="garage">False</field>
<field name="property_type_id" ref="1" />
<field name="property_image" type="base64" file="estate/static/images/threeimage.jpg"/>
<!-- <field name="offer_ids" eval="[
Command.create({'partner_id': ref('base.res_partner_1'), 'price': 100000}),
Command.create({'partner_id': ref('base.res_partner_3'), 'price': 9877655})
]" /> -->
</record>
</record>


<record id="forty_acre_land" model="estate.property">
<field name="name">Forty Acre Land</field>
<field name="state">new</field>
<field name="description">Widespread and lush green land area</field>
<field name="postcode">12254</field>
<field name="date_availability">2024-01-15</field>
<field name="expected_price">1500</field>
<field name="selling_price">1600</field>
<field name="bedrooms">0</field>
<field name="living_area">0</field>
<field name="facades">4</field>
<field name="garage">False</field>
<field name="property_type_id" ref="4" />
<field name="property_image" type="base64" file="estate/static/images/fourimage.jpg"/>
</record>

<record id="dragon_isle" model="estate.property">
<field name="name">Dragon Isle Villa</field>
<field name="state">new</field>
<field name="description">Super Luxurious white marble villas</field>
<field name="postcode">12641</field>
<field name="date_availability">2024-01-15</field>
<field name="expected_price">250000</field>
<field name="selling_price">26000</field>
<field name="bedrooms">10</field>
<field name="living_area">2500</field>
<field name="facades">4</field>
<field name="garage">False</field>
<field name="property_type_id" ref="1" />
<field name="property_image" type="base64" file="estate/static/images/fiveimage.jpg"/>
</record>

<record id="Whole_wood_Castle" model="estate.property">
<field name="name">Premium Wood Castle</field>
<field name="state">new</field>
<field name="description">Giant Pure sag wood Castle</field>
<field name="postcode">52110</field>
<field name="date_availability">2024-01-15</field>
<field name="expected_price">35000</field>
<field name="selling_price">36200</field>
<field name="bedrooms">6</field>
<field name="living_area">5000</field>
<field name="facades">6</field>
<field name="garage">False</field>
<field name="property_type_id" ref="1" />
<field name="property_image" type="base64" file="estate/static/images/siximage.jpg"/>
</record>

<record id="forty_acre_land" model="estate.property">
<field name="name">Forty Acre Land</field>
<field name="state">new</field>
<field name="description">Widespread and lush green land area</field>
<field name="postcode">12254</field>
<field name="date_availability">2024-01-15</field>
<field name="expected_price">1500</field>
<field name="selling_price">1600</field>
<field name="bedrooms">0</field>
<field name="living_area">0</field>
<field name="facades">4</field>
<field name="garage">False</field>
<field name="property_type_id" ref="4" />

</record>
<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">60</field>
</record>


</odoo>
6 changes: 1 addition & 5 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
from . import estate_property
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offer
from . import inherited_model
from . import estate_property,estate_property_offer,estate_property_tag,estate_property_type,inherited_model
77 changes: 32 additions & 45 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,45 @@ class EstateProperty(models.Model):
string='State',
required=True,
default='new',
copy=False,
)
copy=False)
property_type_id = fields.Many2one(comodel_name="estate.property.type", string="Property Type", auto_join=True, ondelete="cascade")
user_id = fields.Many2one('res.users', string='Salesman', index=True, ondelete="cascade")
partner_id = fields.Many2one('res.partner', string='Buyer', index=True, ondelete="cascade")
tag_ids=fields.Many2many(comodel_name="estate.property.tag", string="Property Tags", ondelete="cascade" )
offer_ids = fields.One2many(
comodel_name='estate.property.offer',
inverse_name='property_id',
string='Offers' ,
)

total_area = fields.Float(compute="_compute_total_area")
best_price = fields.Float(compute="_compute_best_price")
string='Offers')
status_button=fields.Char()
estate_id = fields.Many2one("estate.property.type")
company_id = fields.Many2one('res.company', required=True, default=lambda self: self.env.company)
property_image=fields.Image()
total_area = fields.Float(compute="_compute_total_area")
best_price = fields.Float(compute="_compute_best_price")


@api.onchange("garden")
def _onchange_garden(self):
if not self.garden:
self.garden_area = 0
self.garden_orientation=None
else:
self.garden_area=10
self.garden_orientation='north'


_sql_constraints = [
(
"check_expected_price",
"CHECK(expected_price > 0)",
"Expected price must be strictly positive",
),
(
"check_selling_price",
"CHECK(selling_price >= 0)",
"Selling price must be non-negative",
),
]


@api.depends("garden_area","living_area")
Expand All @@ -71,19 +90,14 @@ def _compute_best_price(self):
record.best_price=0
continue
record.best_price = max(record.offer_ids.mapped('price'))


@api.ondelete(at_uninstall=False)
def _unlink_if_state_new_cancelled(self):
for record in self:
if record.state in ['offer_accepted', 'sold', 'offer_received']:
raise UserError("Can't delete this Record either property is sold or Offer is received or accepted")

@api.onchange("garden")
def _onchange_garden(self):
if not self.garden:
self.garden_area = 0
self.garden_orientation=None
else:
self.garden_area=10
self.garden_orientation='north'




def sell_action(self):
for record in self:
Expand All @@ -95,7 +109,6 @@ def sell_action(self):
return True



def cancel_action(self):
for record in self:
if record.status_button != 'sold':
Expand All @@ -104,30 +117,8 @@ def cancel_action(self):
else:
raise UserError("SOLD properties can not be CANCELLED")
return True



_sql_constraints = [
(
"check_expected_price",
"CHECK(expected_price > 0)",
"Expected price must be strictly positive",
),
(
"check_selling_price",
"CHECK(selling_price >= 0)",
"Selling price must be non-negative",
),
]


@api.ondelete(at_uninstall=False)
def _unlink_if_state_new_cancelled(self):
for record in self:
if record.state in ['offer_accepted', 'sold', 'offer_received']:
raise UserError("Can't delete this Record either property is sold or Offer is received or accepted")


def print_quotation(self):
return self.env.ref('estate.action_report_estate_property_sold').report_action(self)

Expand All @@ -144,7 +135,3 @@ def action_make_offer(self):
'default_property_id': self.ids,
}
}




Loading

0 comments on commit 3b3e869

Please sign in to comment.