It is commonly used for internal user interfaces or secure APIs.
+ """
+
+ # Route with no authentication or session required
+ @route("/none_type", auth="none", methods=["GET"], csrf=False)
+ def api_data(self):
+ return """
+ Stateless API route with no authentication or session.
+
- Auth type: 'none' (no user/session context).
+
- CSRF disabled for this route.
+
- Suitable for integration scenarios requiring lightweight stateless operations.
+ """
+
+ # Route accessible only to administrators
+ @route("/admin_page", auth="admin")
+ def admin_page(self):
+ """
+ Route accessible only to administrators.
+ - Auth type: 'admin'.
+ - Suitable for pages or actions restricted to users with admin rights.
+ """
+ return """
+
Admin Page
+
This page is restricted to administrators only.
+
It is used for critical or sensitive backend operations.
+ """
+
+ # Route for portal users with website context
+ @route("/portal_users", auth="portal", website=True)
+ def my_orders(self):
+ """
+ Route for portal users with website context.
+ - Auth type: 'portal' (only users with portal access can view).
+ - Includes website context for frontend integration.
+ - Common use case: showing customer-specific data like orders or invoices.
+ """
+ return """
+
Portal Users Page
+
This page is only accessible to portal users (e.g., customers or suppliers).
+
It is integrated with the website module for a frontend display.
+ """
diff --git a/estate/controllers/postreq.py b/estate/controllers/postreq.py
new file mode 100644
index 0000000000..dc5a52dc1e
--- /dev/null
+++ b/estate/controllers/postreq.py
@@ -0,0 +1,60 @@
+from odoo import http
+from odoo.http import request, route
+import json
+
+
+class WebsiteContactForm(http.Controller):
+
+ @http.route("/website/contact_form", auth="public", website=True)
+ def contact_form(self):
+ # Render the contact form template
+ return request.render("estate.contact_form_template")
+
+ @route(
+ "/website/contact_form_submit",
+ auth="user",
+ methods=["POST"],
+ type="http",
+ website=True,
+ )
+ def submit_contact_form(self, **post):
+ name = post.get("name")
+ email = post.get("email")
+
+ request.env["res.partner"].sudo().create({"name": name, "email": email})
+
+ return request.render("estate.thank_you")
+
+ @http.route(
+ "/ext_website/contact_form/submit",
+ auth="public",
+ methods=["POST"],
+ type="json",
+ website=True,
+ csrf=False,
+ cors="*",
+ )
+ def submit_contact_form_ext(self, **post):
+ # print("post:", post)
+ if not post:
+ try:
+ ## request.httprequest.data is raw data format (binary data)
+ post = json.loads(request.httprequest.data.decode("utf-8"))
+ except Exception as e:
+ _logger.error(f"Fallback JSON Parsing Error: {e}")
+ return {"error": "Invalid request format"}
+
+ name = post.get("name")
+ email = post.get("email")
+
+ # Debugging - check the received data
+ print(f"Received data: {name}, {email}")
+
+ if name and email:
+ # Create a new partner record with the provided data
+ partner = (
+ request.env["res.partner"].sudo().create({"name": name, "email": email})
+ )
+ return "Partner created successfully!"
+ else:
+ return "Error: Please provide both name and email."
diff --git a/estate/demo/demo_res_company.xml b/estate/demo/demo_res_company.xml
new file mode 100644
index 0000000000..f747b98e96
--- /dev/null
+++ b/estate/demo/demo_res_company.xml
@@ -0,0 +1,12 @@
+
+
+ Estate Company
+ 123 Estate Lane
+ Estate City
+
+
+ 90210
+ +1 234 567 8900
+ info@estatecompany2.com
+
+
diff --git a/estate/demo/demo_res_users.xml b/estate/demo/demo_res_users.xml
new file mode 100644
index 0000000000..c3bcd63885
--- /dev/null
+++ b/estate/demo/demo_res_users.xml
@@ -0,0 +1,39 @@
+
+
+
+ Manager 1 Estate
+ m1
+ p
+
+
+
+
+
+
+ Manager 2 Estate
+ m2
+ p
+
+
+
+
+
+
+
+ Agent 1 Estate
+ a1
+ p
+
+
+
+
+
+
+ Agent 2 Estate
+ a2
+ p
+
+
+
+
+
diff --git a/estate/demo/estate.property.tags.csv b/estate/demo/estate.property.tags.csv
new file mode 100644
index 0000000000..9d618c4bb3
--- /dev/null
+++ b/estate/demo/estate.property.tags.csv
@@ -0,0 +1,11 @@
+"id","name","color"
+"tag_modern","Modern","1"
+"tag_luxury","Luxury","2"
+"tag_vintage","Vintage","3"
+"tag_cozy","Cozy","4"
+"tag_spacious","Spacious","5"
+"tag_economical","Economical","6"
+"tag_green","Green","7"
+"tag_waterfront","Waterfront","8"
+"tag_mountain_view","Mountain View","9"
+"tag_city_center","City Center","10"
diff --git a/estate/demo/estate.property.types.csv b/estate/demo/estate.property.types.csv
new file mode 100644
index 0000000000..f9041386ea
--- /dev/null
+++ b/estate/demo/estate.property.types.csv
@@ -0,0 +1,7 @@
+"id","name","sequence"
+"estate_property_type_residential","Residential","1"
+"estate_property_type_commercial","Commercial","2"
+"estate_property_type_land","Land","3"
+"estate_property_type_industrial","Industrial","4"
+"estate_property_type_villa","Villa","5"
+"estate_property_type_apartment","Apartment","6"
diff --git a/estate/demo/estate_property_demo.xml b/estate/demo/estate_property_demo.xml
new file mode 100644
index 0000000000..0059428014
--- /dev/null
+++ b/estate/demo/estate_property_demo.xml
@@ -0,0 +1,240 @@
+
+
+
+ Big Villa
+ offer_received
+ A nice and big villa
+ 12345
+ 2020-02-02
+ 1600000.00
+ 0.00
+ 6
+ 100
+ 4
+ True
+ True
+ 100000
+
+
+ south
+
+
+
+
+
+ Trailer home
+ cancelled
+ Home in a trailer park
+ 54321
+ 1970-01-01
+ 100000.00
+ 91000.00
+ 1
+ 10
+ 4
+ False
+ False
+ 0
+
+
+
+
+
+
+
+
+ My home
+ offer_received
+ Home in a my park
+ 123456
+
+ 110000.00
+ 0.00
+ 15
+ 10000
+ 4
+
+
+ False
+ False
+ 0
+
+
+
+
+
+
+
+
+ Modern Villa
+ offer_received
+ A sleek, modern villa with spacious living rooms.
+ 67890
+ 2024-01-01
+ 2500000.00
+ 0.00
+ 5
+ 350
+ 3
+
+
+ True
+ True
+ 500
+ north
+
+
+
+
+
+
+ Commercial Office
+ new
+ A large commercial office space in the city center.
+ 11223
+ 2024-06-01
+ 1500000.00
+ 0.00
+ 0
+ 1000
+
+
+ 2
+ False
+ False
+ 0
+
+
+
+
+
+
+
+ Residential Apartment
+ offer_accepted
+ A modern residential apartment in a high-rise building.
+ 34567
+ 2024-03-15
+ 500000.00
+ 510000.00
+ 2
+ 80
+ 1
+ True
+
+
+
+ False
+ 0
+
+
+
+
+
+
+
+
+ Land for Sale
+ sold
+ A plot of land ready for development.
+ 45678
+ 2024-07-01
+ 300000.00
+ 2655000.00
+ 0
+ 0
+ 4
+
+
+
+ False
+ False
+ 0
+
+
+
+
+
+
+
+ Industrial Warehouse
+ offer_received
+ An industrial warehouse with large storage capacity.
+ 98765
+ 2024-04-10
+ 1000000.00
+ 10550000.00
+ 0
+ 2000
+ 2
+
+
+
+ False
+ False
+ 0
+
+
+
+
+
+
+
+ Luxury Mountain View Villa
+ sold
+ A luxurious villa with a spectacular mountain view.
+ 54321
+ 2024-08-01
+ 5000000.00
+ 48050000.00
+ 7
+ 800
+ 5
+ True
+ false
+
+
+
+ 2000
+ west
+
+
+
+
+
+
diff --git a/estate/demo/estate_property_offers_demo.xml b/estate/demo/estate_property_offers_demo.xml
new file mode 100644
index 0000000000..565138d0e2
--- /dev/null
+++ b/estate/demo/estate_property_offers_demo.xml
@@ -0,0 +1,120 @@
+
+
+
+ 1805000
+ refused
+
+
+ 7
+
+
+ 1905000
+
+
+ 7
+
+
+ 2005000
+
+
+ 7
+
+
+ 2105000
+
+
+
+
+
+ 2110000
+
+
+
+
+
+ 25000000
+
+
+ 30
+
+
+ 25500000
+
+
+ 15
+
+
+ 26000000
+
+
+ 7
+
+
+ 5205000
+
+
+ 15
+
+
+ 5305000
+ refused
+
+
+ 10
+
+
+ 5405000
+
+
+ 5
+
+
+ 2655000
+ accepted
+
+
+ 40
+
+
+ 2710000
+ refused
+
+
+ 20
+
+
+ 2805000
+ refused
+
+
+ 10
+
+
+ 10550000
+
+
+ 30
+
+
+ 11050000
+
+
+ 15
+
+
+ 48050000
+ accepted
+
+
+ 45
+
+
+ 49050000
+ refused
+
+
+ 30
+
+
+
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 0000000000..4b27e9cf4e
--- /dev/null
+++ b/estate/models/__init__.py
@@ -0,0 +1,5 @@
+from . import estate_property_offer
+from . import estate_property
+from . import estate_property_type
+from . import estate_property_tag
+from . import res_users
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 0000000000..01a16c598a
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,169 @@
+from odoo import models, fields, api
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
+from odoo.exceptions import UserError, ValidationError, AccessError
+from odoo.tools import float_compare
+from odoo.tools import is_html_empty
+
+
+class EstateProperty(models.Model):
+ _name = "estate.property"
+ _description = "Real Estate Property"
+ _inherit = ["mail.thread", "mail.activity.mixin"]
+ _check_company_auto = True
+
+ name = fields.Char(
+ required=True,
+ string="Name",
+ tracking=True,
+ )
+ image = fields.Image(string="Image", max_width=1920, max_height=1920)
+ postcode = fields.Char(string="Pincode")
+ date_availability = fields.Date(
+ string="Available from",
+ default=lambda self: (datetime.now() + relativedelta(months=3)).date(),
+ copy=False,
+ )
+ expected_price = fields.Float(
+ required=True,
+ string="Expected Price",
+ tracking=True,
+ )
+ selling_price = fields.Float(readonly=True, copy=False)
+
+ description = fields.Char()
+ bedrooms = fields.Integer(default=2)
+ living_area = fields.Integer(string="Living Area (sqm)", index=True)
+ facades = fields.Integer()
+ garage = fields.Boolean()
+ garden = fields.Boolean()
+ active = fields.Boolean(default=True)
+ garden_area = fields.Integer(string="Garden Area (sqm)")
+ garden_orientation = fields.Selection(
+ [
+ ("north", "North"),
+ ("south", "South"),
+ ("east", "East"),
+ ("west", "West"),
+ ],
+ )
+ state = fields.Selection(
+ [
+ ("new", "New"),
+ ("offer_received", "Offer Received"),
+ ("offer_accepted", "Offer Accepted"),
+ ("sold", "Sold"),
+ ("cancelled", "Cancelled"),
+ ],
+ required=True,
+ default="new",
+ tracking=True,
+ )
+ total_area = fields.Float(
+ compute="_compute_total_area",
+ string="Total Area (sqm)",
+ tracking=True,
+ )
+ property_type_id = fields.Many2one("estate.property.types", required=True)
+ user_id = fields.Many2one(
+ "res.users",
+ string="Salesperson",
+ index=True,
+ default=lambda self: self.env.user,
+ check_company=True,
+ )
+ partner_id = fields.Many2one("res.partner", string="Buyer", copy=False)
+ tag_ids = fields.Many2many("estate.property.tags", string="Tags")
+ offer_ids = fields.One2many(
+ "estate.property.offers",
+ "property_id",
+ string="Offers",
+ )
+ best_price = fields.Float(compute="_compute_best_price")
+
+ company_id = fields.Many2one(
+ "res.company",
+ string="Company",
+ required=True,
+ default=lambda self: self.env.company,
+ )
+
+ @api.depends("living_area", "garden_area")
+ def _compute_total_area(self):
+ for record in self:
+ record.total_area = record.living_area + record.garden_area
+
+ @api.depends("offer_ids.price")
+ def _compute_best_price(self):
+ for record in self:
+ record.best_price = max(record.offer_ids.mapped("price"), default=0)
+
+ @api.onchange("garden")
+ def _onchange_garden(self):
+ for record in self:
+ record.garden_area = 10 if record.garden else 0
+ record.garden_orientation = "north" if record.garden else None
+
+ def onclick_sold(self):
+ for record in self:
+ if record.state not in ["cancelled"]:
+ record.state = "sold"
+ else:
+ raise UserError("A cancelled property cannot be sold.")
+
+ def onclick_cancel(self):
+ for record in self:
+ if record.state not in ["sold"]:
+ record.state = "cancelled"
+ else:
+ raise UserError("A sold property cannot be cancelled.")
+
+ _sql_constraints = [
+ (
+ "check_expected_price_cust",
+ "CHECK(expected_price > 0)",
+ "Expected price cannot be less than 0.",
+ ),
+ ]
+
+ @api.constrains("selling_price")
+ def _check_selling_price(self):
+ for record in self:
+ if record.state not in ["new", "offer_received"]:
+ if (
+ float_compare(
+ record.selling_price,
+ record.expected_price * 90 / 100,
+ precision_digits=2,
+ )
+ == -1
+ ):
+ raise ValidationError(
+ "Selling price is too low! It must be at least 90% of the expected price."
+ )
+
+ @api.ondelete(at_uninstall=False)
+ def _prevent_deletion_of_record_while_state_is_not_new_or_cancelled(self):
+ if any(record.state not in ["new", "cancelled"] for record in self):
+ raise AccessError(
+ "You can only delete a property if it is in the 'new' or 'cancelled' state."
+ )
+
+ @api.model
+ def get_empty_list_help(self, help_message):
+ if not is_html_empty(help_message):
+ return help_message
+
+ help_title, sub_title = "", ""
+ help_title = (
+ "No records available. Please check your filters or create new records."
+ )
+
+ # Add the background image in the HTML with inline CSS
+ return super().get_empty_list_help(
+ f"""
+
{help_title}
+
{sub_title}
+
+ """
+ )
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 0000000000..56399ded2b
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,94 @@
+from odoo import models, fields, api
+from datetime import datetime, timedelta
+from odoo.exceptions import ValidationError
+
+
+class EstatePropertyOffer(models.Model):
+ _name = "estate.property.offers"
+ _description = "Real Estate Property Offer"
+ _order = "price desc"
+
+ _sql_constraints = [
+ ("check_price", "CHECK(price > 0)", "Price cannot be less than or equal to 0."),
+ ]
+
+ price = fields.Float(required=True)
+ status = fields.Selection(
+ [
+ ("accepted", "Accepted"),
+ ("refused", "Refused"),
+ ],
+ copy=False,
+ )
+ partner_id = fields.Many2one("res.partner", string="Partner")
+ property_id = fields.Many2one("estate.property", required=True, index=True)
+ date_deadline = fields.Date(
+ default=(datetime.now() + timedelta(days=7)).date(),
+ compute="_compute_date_by_validity",
+ inverse="_compute_validity_by_date",
+ store=True,
+ )
+ validity = fields.Integer(
+ default=7,
+ inverse="_compute_date_by_validity",
+ compute="_compute_validity_by_date",
+ store=True,
+ )
+ property_state = fields.Selection(
+ related="property_id.state", string="Property State"
+ )
+ property_type_id = fields.Many2one(
+ related="property_id.property_type_id", store=True, depends=["property_id"]
+ )
+
+ @api.depends("date_deadline")
+ def _compute_validity_by_date(self):
+ for record in self:
+ if record.create_date and record.date_deadline:
+ record.validity = (
+ record.date_deadline - record.create_date.date()
+ ).days
+ else:
+ record.validity = (record.date_deadline - datetime.today().date()).days
+
+ @api.depends("validity")
+ def _compute_date_by_validity(self):
+ for record in self:
+ if record.create_date and record.validity:
+ record.date_deadline = (
+ record.create_date + timedelta(days=record.validity)
+ ).date()
+ else:
+ record.date_deadline = (
+ datetime.today() + timedelta(days=record.validity)
+ ).date()
+
+ def action_confirm(self):
+ for record in self:
+ record.status = "accepted"
+ record.property_id.state = "offer_accepted"
+ record.property_id.selling_price = record.price
+ record.property_id.partner_id = record.partner_id
+
+ def action_cancel(self):
+ for record in self:
+ record.status = "refused"
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ if not isinstance(vals_list, list):
+ raise ValidationError("Unexpected input to create method.")
+
+ for vals in vals_list:
+ property_id = vals.get("property_id")
+ if property_id:
+ property = self.env["estate.property"].browse(property_id)
+ if property.state == "new":
+ property.state = "offer_received"
+ max_price = max(property.offer_ids.mapped("price"), default=0)
+ if vals["price"] <= max_price:
+ raise ValidationError(
+ f"The offer price must be greater than the current maximum offer price of {max_price}."
+ )
+
+ return super(EstatePropertyOffer, self).create(vals_list)
diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py
new file mode 100644
index 0000000000..51f6b8da98
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,13 @@
+from odoo import models, fields
+
+
+class EstatePropertyTag(models.Model):
+ _name = "estate.property.tags"
+ _description = "Real Estate Property Tags"
+
+ name = fields.Char(required=True, string="Tag Name")
+ color = fields.Integer(string="Color")
+
+ _sql_constraints = [
+ ("check_tag_name", "UNIQUE(name)", "Tag name must be unique."),
+ ]
diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py
new file mode 100644
index 0000000000..ba6ae08a41
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,28 @@
+from odoo import models, fields, api
+
+
+class EstatePropertyType(models.Model):
+ _name = "estate.property.types"
+ _description = "Real Estate Property Type"
+ _order = "sequence, name, id"
+
+ name = fields.Char(required=True, string="Property Type")
+
+ _sql_constraints = [
+ ("check_property_type", "UNIQUE(name)", "Property type must be unique."),
+ ]
+
+ offer_ids = fields.One2many("estate.property.offers", "property_type_id")
+
+ property_ids = fields.One2many("estate.property", "property_type_id")
+
+ sequence = fields.Integer(
+ "Sequence", default=1, help="Used to order property types. Lower values are higher priority."
+ )
+
+ offer_counts = fields.Integer(compute="_compute_offers_by_property_types")
+
+ @api.depends("offer_ids")
+ def _compute_offers_by_property_types(self):
+ for record in self:
+ record.offer_counts = len(record.offer_ids)
diff --git a/estate/models/res_users.py b/estate/models/res_users.py
new file mode 100644
index 0000000000..e004cd7d01
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,6 @@
+from odoo import fields, models
+
+class ResUsers(models.Model):
+ _inherit = "res.users"
+
+ property_ids = fields.One2many("estate.property", "user_id")
diff --git a/estate/report/company_details_templates.xml b/estate/report/company_details_templates.xml
new file mode 100644
index 0000000000..dcf2b839f6
--- /dev/null
+++ b/estate/report/company_details_templates.xml
@@ -0,0 +1,30 @@
+
+
+
+