diff --git a/estate/__init__.py b/estate/__init__.py
new file mode 100644
index 00000000000..0650744f6bc
--- /dev/null
+++ b/estate/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/estate/__manifest__.py b/estate/__manifest__.py
new file mode 100644
index 00000000000..b6a9603b680
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,21 @@
+{
+ 'name': 'Real Estate',
+ 'version': '1.0',
+ 'depends': ['base'],
+ 'author': 'Shivam Saksham(shsak)',
+ 'category': 'Sales',
+ 'description': """
+ An Real Estate App to buy, sell, and rent properties.
+ """,
+ 'application': True,
+ 'license': 'LGPL-3',
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'views/estate_property_views.xml',
+ 'views/estate_property_tag_views.xml',
+ 'views/estate_property_offer_views.xml',
+ 'views/estate_property_type_views.xml',
+ 'views/res_users_views.xml',
+ 'views/estate_menus.xml',
+ ],
+}
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 00000000000..9a2189b6382
--- /dev/null
+++ b/estate/models/__init__.py
@@ -0,0 +1,5 @@
+from . import estate_property
+from . import estate_property_type
+from . import estate_property_tag
+from . import estate_property_offer
+from . import res_users
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 00000000000..295b5089051
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,118 @@
+from odoo import models, fields, api, exceptions, _
+from odoo.tools.float_utils import float_compare
+
+
+class EstateProperty(models.Model):
+ _name = "estate_property"
+ _description = "Estate Property details"
+ _order = "id desc"
+
+ name = fields.Char(required=True)
+ description = fields.Text()
+ postcode = fields.Char()
+ date_availability = fields.Date(
+ default=lambda self: fields.Date.add(fields.Date.today(), months=3), copy=False
+ )
+ expected_price = fields.Float(required=True)
+ selling_price = fields.Float(readonly=True, copy=False)
+ bedrooms = fields.Integer(default=2)
+ living_area = fields.Integer()
+ facades = fields.Integer()
+ garage = fields.Boolean()
+ garden = fields.Boolean()
+ garden_area = fields.Integer()
+ garden_orientation = fields.Selection(
+ string="Garden Orientation",
+ selection=[
+ ("north", "North"),
+ ("south", "South"),
+ ("east", "East"),
+ ("west", "West"),
+ ],
+ )
+ state = fields.Selection(
+ string="Status",
+ selection=[
+ ("new", "New"),
+ ("offer_received", "Offer Received"),
+ ("offer_accepted", "Offer Accepted"),
+ ("sold", "Sold"),
+ ("cancelled", "Cancelled"),
+ ],
+ default="new",
+ required=True,
+ copy=False,
+ )
+ active = fields.Boolean(default=True)
+ property_type_id = fields.Many2one("estate.property.type", string="Type")
+ buyer = fields.Many2one("res.partner", copy=False)
+ salesperson = fields.Many2one(
+ "res.users", string="Salesman", default=lambda self: self.env.user
+ )
+ tag_ids = fields.Many2many("estate.property.tag", string="Tag")
+ offer_ids = fields.One2many("estate.property.offer", "property_id")
+ total_area = fields.Integer(compute="_compute_total_area")
+ best_price = fields.Float(compute="_compute_best_price")
+
+ _check_expected_price = models.Constraint(
+ "CHECK(expected_price > 0)", "The Expected price cannot be 0 or less then 0"
+ )
+
+ _check_selling_price = models.Constraint(
+ "CHECK(selling_price >= 0)", "The Selling price cannot be less then 0"
+ )
+
+ @api.constrains("selling_price", "buyer", "expected_price")
+ def _check_selling_price_90p(self):
+ for record in self:
+ if record.selling_price == 0:
+ return False
+ if (
+ float_compare(
+ (record.selling_price / record.expected_price) * 100,
+ 90,
+ precision_digits=2,
+ )
+ < 0
+ ):
+ raise exceptions.ValidationError(
+ _("Selling Price should be 90% or more of expected price.")
+ )
+
+ @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") or [0])
+
+ @api.onchange("garden")
+ def _onchange_garden(self):
+ if self.garden:
+ self.garden_orientation = "north"
+ self.garden_area = 10
+ else:
+ self.garden_orientation = None
+ self.garden_area = 0
+
+ def action_cancel_property(self):
+ if self.filtered(lambda x: x.state == "sold"):
+ raise exceptions.UserError(_("A sold property cannot be cancelled"))
+
+ self.state = "cancelled"
+
+ def action_property_sold(self):
+ if self.filtered(lambda x: x.state == "cancelled"):
+ raise exceptions.UserError(_("A cancelled property cannot be sold"))
+
+ self.state = "sold"
+
+ @api.ondelete(at_uninstall=False)
+ def _unlink_if_new_or_sold(self):
+ if self.filtered(lambda x: x.state not in ("new", "cancelled")):
+ raise exceptions.UserError(
+ _("Cannot delete property which is new or cancelled")
+ )
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..c6d11e2e030
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,62 @@
+from odoo import models, fields, api, exceptions, _
+
+
+class EstatePropertyOffer(models.Model):
+ _name = 'estate.property.offer'
+ _description = 'Offer to buy the property'
+ _order = 'price desc'
+
+ price = fields.Float()
+ status = fields.Selection(
+ string='Status',
+ selection=[('accepted', 'Accepted'), ('refused', 'Refused')],
+ copy=False,
+ )
+ partner_id = fields.Many2one('res.partner', required=True)
+ property_id = fields.Many2one('estate_property', required=True)
+ validity = fields.Integer(default=7)
+ date_deadline = fields.Date(compute='_compute_offer_date_deadline', inverse='_inverse_offer_date_deadline')
+ property_type_id = fields.Many2one(related='property_id.property_type_id')
+
+ _check_offer_price = models.Constraint(
+ 'CHECK(price > 0)',
+ 'Offer Price cannot be 0 or below 0'
+ )
+
+ @api.depends('validity')
+ def _compute_offer_date_deadline(self):
+ for record in self:
+ if record.create_date:
+ record.date_deadline = fields.Date.add(record.create_date.date(), days=record.validity)
+ else:
+ record.date_deadline = fields.Date.add(fields.Date.today(), days=record.validity)
+
+ def _inverse_offer_date_deadline(self):
+ for record in self:
+ record.validity = (record.date_deadline - record.create_date.date()).days
+
+ def action_offer_accepted(self):
+ for record in self:
+ if record.property_id.buyer:
+ raise exceptions.UserError(_('An another offer is already accepted'))
+ record.property_id.selling_price = record.price
+ record.property_id.buyer = record.partner_id
+ record.property_id.state = 'offer_accepted'
+ record.status = 'accepted'
+ return True
+
+ def action_offer_refused(self):
+ for record in self:
+ record.status = 'refused'
+ return True
+
+ @api.model
+ def create(self, vals_list):
+ if len(vals_list) > 0:
+ prop = self.env['estate_property'].browse(vals_list[0]['property_id'])
+ if prop.best_price > vals_list[0]['price']:
+ raise exceptions.UserError(_('An offer with high price already exists.'))
+
+ prop.state = 'offer_received'
+
+ return super().create(vals_list)
diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py
new file mode 100644
index 00000000000..7b2b6d16c40
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,15 @@
+from odoo import models, fields
+
+
+class EstatePropertyTag(models.Model):
+ _name = 'estate.property.tag'
+ _description = 'Tag for the property'
+ _order = 'name'
+
+ name = fields.Char(required=True)
+ color = fields.Integer()
+
+ _check_unique_name = models.Constraint(
+ 'unique(name)',
+ 'A tag with the same name already exists.'
+ )
diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py
new file mode 100644
index 00000000000..b98b36e345d
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,26 @@
+from odoo import models, fields, api
+
+
+class EstatePropertyType(models.Model):
+ _name = 'estate.property.type'
+ _description = 'Defines the type of Real Estate Property'
+ _order = 'name'
+
+ name = fields.Char(required=True)
+ property_ids = fields.One2many('estate_property', 'property_type_id', string='Properties')
+ sequence = fields.Integer(
+ default=1,
+ help='used to order the type based on the number of time it is used'
+ )
+ offer_ids = fields.One2many('estate.property.offer', 'property_type_id', string='Offers')
+ offer_count = fields.Integer(compute='_compute_offers_count')
+
+ _check_unique_name = models.Constraint(
+ 'unique(name)',
+ 'A tag with the same name already exists.'
+ )
+
+ @api.depends('offer_ids')
+ def _compute_offers_count(self):
+ for record in self:
+ record.offer_count = len(record.offer_ids)
diff --git a/estate/models/res_users.py b/estate/models/res_users.py
new file mode 100644
index 00000000000..31e362e2cd5
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,11 @@
+from odoo import fields, models
+
+
+class ResUsers(models.Model):
+ _inherit = 'res.users'
+
+ property_ids = fields.One2many(
+ 'estate_property',
+ 'salesperson',
+ domain=['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]
+ )
diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv
new file mode 100644
index 00000000000..78458c1cb61
--- /dev/null
+++ b/estate/security/ir.model.access.csv
@@ -0,0 +1,5 @@
+id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
+estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
+estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1
+estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1
+estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1
diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml
new file mode 100644
index 00000000000..f0841d8e7d1
--- /dev/null
+++ b/estate/views/estate_menus.xml
@@ -0,0 +1,14 @@
+
+
+
diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml
new file mode 100644
index 00000000000..c38f6aad256
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,43 @@
+
+
+ estate_property_offer_list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Property Offer List
+ estate.property.offer
+
+
+
+
+
+
+ Estate Property Offers
+ estate.property.offer
+ [('property_type_id', '=', active_id)]
+ list,form
+
+
diff --git a/estate/views/estate_property_tag_views.xml b/estate/views/estate_property_tag_views.xml
new file mode 100644
index 00000000000..522441a4311
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,17 @@
+
+
+ Tags
+ estate.property.tag
+
+
+
+
+
+
+
+
+ Property Tags
+ estate.property.tag
+ list,form
+
+
diff --git a/estate/views/estate_property_type_views.xml b/estate/views/estate_property_type_views.xml
new file mode 100644
index 00000000000..0bc46effd8d
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,56 @@
+
+
+ estate_property_type_form
+ estate.property.type
+
+
+
+
+
+
+ estate_property_type_list
+ estate.property.type
+
+
+
+
+
+
+
+
+
+ Property Types
+ estate.property.type
+ list,form
+
+
diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml
new file mode 100644
index 00000000000..17c4863af60
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,115 @@
+
+
+ estate_property_form
+ estate_property
+
+
+
+
+
+
+ Properties List
+ estate_property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Properties Search
+ estate_property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Properties
+ estate_property
+ {'search_default_available': True}
+ list,form,kanban
+
+
\ No newline at end of file
diff --git a/estate/views/res_users_views.xml b/estate/views/res_users_views.xml
new file mode 100644
index 00000000000..e3b24840a4e
--- /dev/null
+++ b/estate/views/res_users_views.xml
@@ -0,0 +1,14 @@
+
+
+ res.users.view.form.inherit.estate
+ res.users
+
+
+
+
+
+
+
+
+
+
diff --git a/estate_account/__init__.py b/estate_account/__init__.py
new file mode 100644
index 00000000000..0650744f6bc
--- /dev/null
+++ b/estate_account/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/estate_account/__manifest__.py b/estate_account/__manifest__.py
new file mode 100644
index 00000000000..7448d7ce0ce
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,12 @@
+{
+ "name": "Estate Accounting",
+ "version": "1.0",
+ "depends": ["estate", "account"],
+ "author": "Shivam Saksham(shsak)",
+ "category": "Sales",
+ "description": """
+ A Real Estate Invoicing Module
+ """,
+ "license": "LGPL-3",
+ "data": [],
+}
diff --git a/estate_account/models/__init__.py b/estate_account/models/__init__.py
new file mode 100644
index 00000000000..5e1963c9d2f
--- /dev/null
+++ b/estate_account/models/__init__.py
@@ -0,0 +1 @@
+from . import estate_property
diff --git a/estate_account/models/estate_property.py b/estate_account/models/estate_property.py
new file mode 100644
index 00000000000..fe5d23303f2
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,30 @@
+from odoo import models, Command
+
+
+class EstateProperty(models.Model):
+ _inherit = "estate_property"
+
+ def action_property_sold(self):
+ self.env["account.move"].create(
+ {
+ "move_type": "out_invoice",
+ "partner_id": self.buyer.id,
+ "invoice_line_ids": [
+ Command.create(
+ {
+ "name": self.name,
+ "quantity": 1,
+ "price_unit": self.selling_price * 0.6,
+ }
+ ),
+ Command.create(
+ {
+ "name": "Administrative Fees",
+ "quantity": 1,
+ "price_unit": 100,
+ }
+ ),
+ ],
+ }
+ )
+ return super().action_property_sold()