diff --git a/estate/__init__.py b/estate/__init__.py
new file mode 100644
index 0000000000..0650744f6b
--- /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 0000000000..8cb9aed116
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,21 @@
+{
+ "name": "Real_Estate",
+ "depends": ["base"],
+ "Description": "Estate Module by aneg",
+ "category": "Real Estate",
+ "license": "LGPL-3",
+ "summary": "Real_Estate module for different purpose",
+ "author": "aneg_odoo",
+ "version": "0.1",
+ "application": True,
+ "installable": True,
+ "data": [
+ "security/ir.model.access.csv",
+ "views/estate_property_offer.xml",
+ "views/estate_property_views.xml",
+ "views/estate_property_type.xml",
+ "views/estate_property_tag.xml",
+ "views/estate_menus.xml",
+ "views/res_users_view.xml",
+ ],
+}
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 0000000000..9a2189b638
--- /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 0000000000..88baf3063f
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,112 @@
+from odoo import api, models, fields
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
+from odoo.exceptions import UserError, ValidationError
+
+
+class estateproperty(models.Model):
+ _name = "estate.property" #: name of the Model
+ _description = "estate_model"
+ _order = "id desc"
+
+ name = fields.Char("Title", default="Unknown")
+ myestate_model = fields.Text("Description")
+ postcode = fields.Char("Postcode")
+ date_availability = fields.Date(
+ "Available From", copy=False, default=datetime.now() + relativedelta(months=3)
+ )
+ expected_price = fields.Float("Expected Price", default=0)
+ selling_price = fields.Float("Selling Price", copy=False)
+ bedrooms = fields.Integer("Bedrooms", default=3)
+ living_area = fields.Integer("Living Area (sqm)", default=2)
+ facades = fields.Integer("Facades", default=2)
+ garage = fields.Boolean("Garage")
+ garden = fields.Boolean("Garden")
+ garden_area = fields.Integer("Garden Area (sqm)", default=0)
+ garden_orientation = fields.Selection(
+ [("north", "north"), ("south", "south"), ("east", "east"), ("west", "west")]
+ )
+ active = fields.Boolean("Active", default=True)
+ status = fields.Selection(
+ [
+ ("new", "New"),
+ ("offer received", "Offer Received"),
+ ("offer accepted", "Offer Accepted"),
+ ("sold", "Sold"),
+ ("cancelled", "Cancelled"),
+ ],
+ default="new",
+ copy=False,
+ )
+ last_seen = fields.Datetime("Last Seen", default=fields.Datetime.now)
+ property_type = fields.Many2one("estate.property.type", string="Property Type")
+ sale_id = fields.Many2one(
+ "res.users", string="Salesman", default=lambda self: self.env.user
+ )
+ Buyer_id = fields.Many2one("res.users", string="Buyer", copy=False)
+ property_tag = fields.Many2many("estate.property.tag", string="Property Tag")
+ offer_id = fields.One2many("estate.property.offer", "property_id", string="Offers")
+ total = fields.Float(compute="_compute_total", string="Total Area (sqm)")
+ best_price = fields.Float(compute="_compute_price", string="Best offer")
+
+ _sql_constraints = [
+ (
+ "check_sellingprice_expectedprice_not_negative",
+ "CHECK(selling_price >= 0.0 and expected_price >= 0.0)",
+ "The selling price and expected_price should be greater than 0.",
+ ),
+ ]
+
+ @api.depends("living_area", "garden_area")
+ def _compute_total(self):
+ for ele in self:
+ ele.total = ele.living_area + ele.garden_area
+
+ @api.depends("offer_id.price")
+ def _compute_price(self):
+ for ele in self:
+ ele.best_price = max(ele.mapped("offer_id.price"), default=0)
+
+ @api.onchange("garden")
+ def _onchange_garden(self):
+ if self.garden:
+ self.garden_area = 100
+ self.garden_orientation = "north"
+ else:
+ self.garden_area = 0
+ self.garden_orientation = None
+
+ def sold_button(self):
+ if self.status == "cancelled":
+ raise UserError("Cancelled Properties cannot be sold")
+ else:
+ self.status = "sold"
+
+ def cancel_button(self):
+ if self.status == "sold":
+ raise UserError("sold Properties cannot be cancelled")
+ else:
+ self.status = "cancelled"
+
+ @api.constrains("selling_price", "expected_price")
+ def validate_selling_price(self):
+ for record in self:
+ if (
+ record.selling_price < (0.9 * record.expected_price)
+ and record.selling_price != 0.0
+ ):
+ raise ValidationError(
+ "the selling price cannot be lower than 90% of the expected price."
+ )
+
+ @api.ondelete(at_uninstall=False)
+ def _prevent_property_deletion(self):
+ for record in self:
+ if record.status not in ("new", "Cancelled"):
+ raise UserError("Only new and cancelled properties can be deleted")
+
+ def check_limit(self, vals):
+ self.status = "offer received"
+
+ if vals.get("price") <= self.best_price:
+ raise ValidationError("the offer must be higher than best price")
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 0000000000..e524547a79
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,53 @@
+from odoo import api, models, fields
+from datetime import date, timedelta
+
+
+class EstatePropertyOffer(models.Model):
+ _name = "estate.property.offer"
+ _description = "Estate Property Offer"
+ _order = "price desc"
+
+ price = fields.Float("Price")
+ status = fields.Selection(
+ [("Accepted", "Accepted"), ("Refused", "Refused")], readonly=True
+ )
+ partner_id = fields.Many2one("res.partner")
+ property_id = fields.Many2one("estate.property")
+ property_type_id = fields.Many2one(related="property_id.property_type", store=True)
+ validity = fields.Integer(string="Validity(days)", default=7)
+ date_deadline = fields.Date(
+ string="Deadline", compute="_compute_deadline", inverse="_inverse_deadline"
+ )
+ _sql_constraints = [
+ (
+ "check_offerprice_not_negative",
+ "CHECK(price >= 0.0)",
+ "The offer price should be greater than 0",
+ ),
+ ]
+
+ @api.depends("validity")
+ def _compute_deadline(self):
+ for ele in self:
+ if not ele.create_date:
+ ele.create_date = date.today()
+ ele.date_deadline = ele.create_date + timedelta(days=ele.validity)
+
+ def _inverse_deadline(self):
+ for ele in self:
+ ele.validity = abs((ele.date_deadline - ele.create_date.date()).days)
+
+ def action_confirm(self):
+ for record in self:
+ record.status = "Accepted"
+ record.property_id.selling_price = record.price
+
+ def action_cancel(self):
+ for record in self:
+ record.status = "Refused"
+ record.property_id.selling_price = 0
+
+ @api.model
+ def create(self, vals):
+ self.env["estate.property"].browse(vals["property_id"]).check_limit(vals)
+ return super().create(vals)
diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py
new file mode 100644
index 0000000000..42618836d5
--- /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.tag"
+ _description = "EstatePropertyTag"
+ _order = "name"
+
+ name = fields.Char(string="tag", required=True)
+ _sql_constraints = [
+ ("uniq_propertytag", "unique(name)", "A property tag name must be unique"),
+ ]
+ color = fields.Integer("color index")
diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py
new file mode 100644
index 0000000000..f6359fb431
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,26 @@
+from odoo import models, fields, api
+
+
+class EstateProperty(models.Model):
+ _name = "estate.property.type"
+ _description = "EstatePropertyType"
+ _order = "name"
+
+ name = fields.Char("Property Types", required=True)
+ _sql_constraints = [
+ ("uniq_propertytype", "unique(name)", "A property type name must be unique"),
+ ]
+ property_ids = fields.One2many("estate.property", "property_type")
+ offer_ids = fields.One2many(
+ comodel_name="estate.property.offer", inverse_name="property_type_id"
+ )
+ offer_count = fields.Integer(compute="_num_of_offers", string="Offer Count")
+ sequence = fields.Integer(
+ "Sequence", default=1, help="To manually reorder property types"
+ )
+
+ api.depends("offer_id")
+
+ def _num_of_offers(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 0000000000..dbd52c2e9d
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,11 @@
+from odoo import models, fields
+from datetime import datetime
+
+
+class Resusers(models.Model):
+ _inherit = "res.users"
+ property_ids = fields.One2many(
+ "estate.property",
+ "sale_id",
+ domain=lambda self: [("date_availability", "<=", datetime.now())],
+ )
diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv
new file mode 100644
index 0000000000..0c0b62b7fe
--- /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 0000000000..14fdfc31f5
--- /dev/null
+++ b/estate/views/estate_menus.xml
@@ -0,0 +1,12 @@
+
+
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_offer.xml b/estate/views/estate_property_offer.xml
new file mode 100644
index 0000000000..9381ac5eb3
--- /dev/null
+++ b/estate/views/estate_property_offer.xml
@@ -0,0 +1,30 @@
+
+
+ properties offer
+ estate.property.offer
+ tree,form
+ [('property_type_id', '=', active_id)]
+
+
+ estate.property.offer.tree.view
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_tag.xml b/estate/views/estate_property_tag.xml
new file mode 100644
index 0000000000..bc9377cbbe
--- /dev/null
+++ b/estate/views/estate_property_tag.xml
@@ -0,0 +1,16 @@
+
+
+ Property Tags
+ estate.property.tag
+ tree,form
+
+
+ estate.property.tag.tree.view
+ estate.property.tag
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_type.xml b/estate/views/estate_property_type.xml
new file mode 100644
index 0000000000..d21b6d669b
--- /dev/null
+++ b/estate/views/estate_property_type.xml
@@ -0,0 +1,54 @@
+
+
+ Property Types
+ estate.property.type
+ tree,form
+
+
+
+ state.property.type.tree.view
+ estate.property.type
+
+
+
+
+
+
+
+
+ estate.property.type.form.view
+ estate.property.type
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml
new file mode 100644
index 0000000000..176a719a6f
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,157 @@
+
+
+ Properties
+ estate.property
+ tree,form,kanban
+ {'search_default_status': True}
+
+
+ estate.property.tree.view
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.model.form.view
+ estate.property
+
+
+
+
+
+
+ estate.property.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.kanbanview
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Expected Price:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate/views/res_users_view.xml b/estate/views/res_users_view.xml
new file mode 100644
index 0000000000..5e216a1f1c
--- /dev/null
+++ b/estate/views/res_users_view.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+ res.users.view.form
+ res.users
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate_account/__init__.py b/estate_account/__init__.py
new file mode 100644
index 0000000000..0650744f6b
--- /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 0000000000..6b9481c1c0
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,12 @@
+{
+ "name": "Estate_Account",
+ "depends": ["estate", "account"],
+ "Description": "estate_account",
+ "category": "",
+ "license": "LGPL-3",
+ "summary": "estate account module would include the invoice creation logic of the estate property.",
+ "author": "aneg_odoo",
+ "version": "0.1",
+ "application": True,
+ "installable": True,
+}
diff --git a/estate_account/models/__init__.py b/estate_account/models/__init__.py
new file mode 100644
index 0000000000..5e1963c9d2
--- /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 0000000000..128ab24f8d
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,33 @@
+from odoo import models, Command
+
+
+class estateaccount(models.Model):
+ _inherit = "estate.property"
+
+ def sold_button(self):
+ for record in self:
+ self.env["account.move"].create(
+ {
+ "name": "test",
+ "move_type": "out_invoice",
+ "partner_id": record.offer_id.partner_id.id,
+ "line_ids": [
+ Command.create(
+ {
+ "name": record.name,
+ # "product_id": record.Buyer_id.id,
+ "quantity": 1.0,
+ "price_unit": 0.06 * (record.selling_price),
+ }
+ ),
+ Command.create(
+ {
+ "name": "administrative fee",
+ "quantity": 1.0,
+ "price_unit": 100.0,
+ }
+ ),
+ ],
+ }
+ )
+ return super().sold_button()