-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] estate: implement demo data with valid property offers and part…
…ners - Added demo data for the estate module: - Created property records with valid details, including pricing and availability. - Added property offers linked to existing partner records to demonstrate functionality. - Ensured that the demo data complies with data integrity constraints.
- Loading branch information
Showing
11 changed files
with
202 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,28 @@ | ||
{ | ||
'name': 'estate', | ||
'version': '1.0', | ||
'summary': 'An real state management application', | ||
'description': 'Estate_property_module', | ||
'category': 'Sales', | ||
'summary': 'A real estate management application', | ||
'description': 'A module for managing real estate properties, offers, and related entities.', | ||
'category': 'Real Estate', | ||
'author': 'YASP', | ||
'website': 'https://www.yaspestate.com', | ||
'sequence': 1, | ||
'depends': ['base'], | ||
'license': 'LGPL-3', | ||
'data': [ | ||
'security/ir.model.access.csv', | ||
'wizard/estate_add_offer_wizard_views.xml', | ||
'data/estate_property_type_data.xml', | ||
'views/estate_property_views.xml', | ||
'views/estate_property_offers_views.xml', | ||
'views/estate_property_types_views.xml', | ||
'views/estate_property_tags_views.xml', | ||
'views/estate_property_offers_views.xml', | ||
'views/res_users_views.xml', | ||
'views/estate_menus.xml' | ||
], | ||
'demo': [ | ||
'demo/estate_property_demo.xml' | ||
], | ||
'installable': True, | ||
'application': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<odoo> | ||
<record id="estate.property_type_residential" model="estate.property.type"> | ||
<field name="name">Residential</field> | ||
<field name="sequence">10</field> | ||
</record> | ||
<record id="estate.property_type_commercial" model="estate.property.type"> | ||
<field name="name">Commercial</field> | ||
<field name="sequence">20</field> | ||
</record> | ||
<record id="estate.property_type_industrial" model="estate.property.type"> | ||
<field name="name">Industrial</field> | ||
<field name="sequence">30</field> | ||
</record> | ||
<record id="estate.property_type_land" model="estate.property.type"> | ||
<field name="name">Land</field> | ||
<field name="sequence">40</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<!-- Create partners if not present | ||
<record id="partner_azure_interior" model="res.partner"> | ||
<field name="name">Azure Interior</field> | ||
<field name="email">[email protected]</field> | ||
</record> | ||
<record id="partner_deco_addict" model="res.partner"> | ||
<field name="name">Deco Addict</field> | ||
<field name="email">[email protected]</field> | ||
</record> --> | ||
|
||
<!-- Property records --> | ||
<record id="property_big_villa" model="estate.property"> | ||
<field name="name">Big Villa</field> | ||
<field name="property_type_id" ref="estate.property_type_residential"/> | ||
<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">1440000</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> | ||
</record> | ||
|
||
<record id="property_trailer_home" model="estate.property"> | ||
<field name="name">Trailer home</field> | ||
<field name="property_type_id" ref="estate.property_type_residential"/> | ||
<field name="state">canceled</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">90000</field> | ||
<field name="bedrooms">1</field> | ||
<field name="living_area">10</field> | ||
<field name="facades">4</field> | ||
<field name="garage">False</field> | ||
<field name="garden">True</field> | ||
<field name="garden_area">500</field> | ||
<field name="garden_orientation">north</field> | ||
</record> | ||
|
||
<!-- Property offers --> | ||
<record id="offer_azure_1" model="estate.property.offer"> | ||
<field name="price">10000</field> | ||
<field name="property_id" ref="property_big_villa"/> | ||
<field name="partner_id" ref="base.res_partner_12"/> | ||
<field name="validity">14</field> | ||
<field name="create_date">2023-08-19</field> | ||
</record> | ||
|
||
<record id="offer_azure_2" model="estate.property.offer"> | ||
<field name="price">1500000</field> | ||
<field name="property_id" ref="property_big_villa"/> | ||
<field name="partner_id" ref="base.res_partner_12"/> | ||
<field name="validity">14</field> | ||
<field name="create_date">2023-08-24</field> | ||
</record> | ||
|
||
<record id="offer_deco_addict" model="estate.property.offer"> | ||
<field name="price">1500001</field> | ||
<field name="property_id" ref="property_big_villa"/> | ||
<field name="partner_id" ref="base.res_partner_12"/> | ||
<field name="validity">14</field> | ||
<field name="create_date">2023-08-29</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import estate_add_offer_wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from odoo import models, fields | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class EstateAddOfferWizard(models.TransientModel): | ||
_name = 'estate.add.offer.wizard' | ||
_description = 'Add Offer Wizard' | ||
|
||
price = fields.Float(string="Offer Price", required=True) | ||
offer_status = fields.Selection([ | ||
('accepted', 'Accepted'), | ||
('refused', 'Refused') | ||
], string="Offer Status") | ||
buyer_id = fields.Many2one('res.partner', string="Buyer", required=True) | ||
|
||
def action_add_offer(self): | ||
active_ids = self.env.context.get('active_ids') | ||
properties = self.env['estate.property'].browse(active_ids).filtered( | ||
lambda p: p.expected_price <= self.price | ||
) | ||
for p in properties: | ||
if p.state in ['new', 'offer_received']: | ||
offer = p.offer_ids.create({ | ||
'property_id': p.id, | ||
'price': self.price, | ||
'partner_id': self.buyer_id.id, | ||
'status': self.offer_status or 'new' # Ensure status is set | ||
}) | ||
# Update the property state if necessary | ||
if p.state == 'offer_received' and self.offer_status == 'accepted': | ||
offer.status = 'accepted' | ||
else: | ||
raise UserError('Property must be in new or offer received state') | ||
return {'type': 'ir.actions.act_window_close'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<odoo> | ||
<record id="estate_add_offer_wizard_form" model="ir.ui.view"> | ||
<field name="name">estate.add.offer.wizard.form</field> | ||
<field name="model">estate.add.offer.wizard</field> | ||
<field name="arch" type="xml"> | ||
<form string="Add Offer"> | ||
<group> | ||
<field name="price"/> | ||
<field name="offer_status"/> | ||
<field name="buyer_id"/> | ||
</group> | ||
<footer> | ||
<button string="Make an Offer" type="object" name="action_add_offer" class="btn-primary"/> | ||
<button string="Cancel" class="btn-secondary" special="cancel"/> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
<record id="action_estate_property_offer_wizard" model="ir.actions.act_window"> | ||
<field name="name">Estate Property Offer Wizard</field> | ||
<field name="res_model">estate.add.offer.wizard</field> | ||
<field name="view_mode">form</field> | ||
<field name="view_id" ref="estate.estate_add_offer_wizard_form"/> | ||
<field name="target">new</field> | ||
</record> | ||
</odoo> |