diff --git a/awesome_clicker/__manifest__.py b/awesome_clicker/__manifest__.py
index e57ef4d5bb0..7d9d4d79572 100644
--- a/awesome_clicker/__manifest__.py
+++ b/awesome_clicker/__manifest__.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+# some not so great changes to make a first commit
{
'name': "Awesome Clicker",
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..8c312f28372
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,19 @@
+{
+ "name": "Real Estate",
+ "category": "Real Estate",
+ "application": True,
+ "installable": True,
+ "depends":[
+ "base",
+ "web"
+ ],
+ "data": [
+ "security/ir.model.access.csv",
+ "views/estate_menus.xml",
+ "views/estate_property_views.xml",
+ "views/estate_property_offer_views.xml",
+ "views/estate_property_type_views.xml",
+ "views/estate_property_tag_views.xml",
+ "views/res_users_views.xml",
+ ]
+}
\ No newline at end of file
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 00000000000..a9459ed5906
--- /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
\ No newline at end of file
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 00000000000..100941851ca
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,110 @@
+from odoo import api, fields, models, exceptions, tools
+
+
+class Property(models.Model):
+ _name = "estate.property"
+ _description = "Real Estate property"
+ _order = "sequence, id desc"
+
+ sequence = fields.Integer("Sequence", default=1)
+ name = fields.Char("Title", required=True)
+ description = fields.Text("Description")
+ postcode = fields.Char("Postcode")
+ date_availability = fields.Date(
+ "Available Date", copy=False, default=fields.Date.add(fields.Date.today(), months=3))
+ expected_price = fields.Float("Expected price", required=True)
+ selling_price = fields.Float("Selling price", readonly=True, copy=False)
+ bedrooms = fields.Integer("Bedrooms", default=2)
+ living_area = fields.Integer("Living area (sqm)")
+ facades = fields.Integer("Facades")
+ garage = fields.Boolean("Garage")
+ garden = fields.Boolean("Garden")
+ garden_area = fields.Integer("Garden area (sqm)")
+ garden_orientation = fields.Selection([
+ ("north", "North"),
+ ("south", "South"),
+ ("east", "East"),
+ ("west", "West")
+ ], string="Garden Orientation")
+ active = fields.Boolean("Active", default=True)
+ state = fields.Selection([
+ ("new", "New"),
+ ("offer_received", "Offer Received"),
+ ("offer_accepted", "Offer Accepted"),
+ ("sold", "Sold"),
+ ("canceled", "Canceled")
+ ], string="Status", required=True, copy=False, default="new")
+
+ _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 positive.")
+ ]
+
+ property_type_id = fields.Many2one(
+ "estate.property.type", string="Property Type")
+ salesman_id = fields.Many2one(
+ "res.users", string="Salesman", default=lambda self: self.env.user)
+ buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False)
+ tag_ids = fields.Many2many("estate.property.tag", string="Tags")
+ offer_ids = fields.One2many(
+ "estate.property.offer", "property_id", string="Offers")
+
+ total_area = fields.Float("Total area (sqm)", compute="_compute_area")
+ best_price = fields.Float("Best price", compute="_compute_best_price")
+
+ @api.depends("living_area", "garden_area")
+ def _compute_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([0] + record.offer_ids.mapped('price'))
+
+ @api.onchange("garden")
+ def _onchange_garden(self):
+ if self.garden:
+ self.garden_area = 10
+ self.garden_orientation = "north"
+ else:
+ self.garden_area = 0
+ self.garden_orientation = ""
+
+ def action_set_sold(self):
+ for record in self:
+ if record.state != "canceled":
+ record.state = "sold"
+ else:
+ raise exceptions.UserError(
+ "Canceled properties cannot be sold.")
+
+ def action_set_canceled(self):
+ for record in self:
+ if record.state != "sold":
+ record.state = "canceled"
+ else:
+ raise exceptions.UserError(
+ "Sold properties cannot be canceled.")
+
+ def hello_seru(self):
+ print("I'm a conflict in your branch")
+ def handle_conflict(self):
+ print("Hello! I handled a conflict.")
+
+ @api.constrains("expected_price", "selling_price")
+ def _check_price(self):
+ for record in self:
+ if record.selling_price and record.expected_price and not tools.float_utils.float_is_zero(record.selling_price, precision_digits=2):
+ if record.selling_price < 0.9 * record.expected_price:
+ raise exceptions.ValidationError(
+ "The selling price cannot be lower than 90% of the expected price.")
+
+ @api.ondelete(at_uninstall=False)
+ def _not_delete_if_not_new_or_canceled(self):
+ for record in self:
+ if record.state not in ["new", "canceled"]:
+ raise exceptions.UserError(
+ "You cannot delete a property that is not new.")
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..20e11131efe
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,65 @@
+from odoo import api, models, fields, exceptions
+
+
+class PropertyOffer(models.Model):
+ _name = "estate.property.offer"
+ _description = "Estate Property Offer"
+ _order = "price desc"
+
+ price = fields.Float("Price")
+ status = fields.Selection([
+ ("accepted", "Accepted"),
+ ("refused", "Refused")],
+ string="Status", copy=False)
+ partner_id = fields.Many2one("res.partner", string="Partner", required=True)
+ property_id = fields.Many2one("estate.property", string="Property", required=True)
+ validity = fields.Integer("Validity (days)", default=7)
+ date_deadline = fields.Date("Deadline", compute="_compute_date_deadline", inverse="_inverse_date_deadline")
+ property_type_id = fields.Many2one("estate.property.type", string="Property Type", related="property_id.property_type_id")
+
+ _sql_constraints = [
+ ("check_price", "CHECK(price > 0)", "Offer price must be positive.")
+ ]
+
+ @api.depends("validity")
+ def _compute_date_deadline(self):
+ for record in self:
+ record.date_deadline = fields.Date.add(
+ record.create_day if hasattr(record, "create_day") else fields.Date.today(),
+ days=record.validity)
+
+ def _inverse_date_deadline(self):
+ for record in self:
+ create_date = record.create_day if hasattr(record, "create_day") else fields.Date.today()
+ record.validity = (record.date_deadline - create_date).days
+
+ def action_accept_offer(self):
+ for record in self:
+ if record.property_id.state not in ["offer_accepted", "sold"]:
+ # if tools.float_utils.float_compare(record.price, 0.9 * record.property_id.expected_price, precision_rounding=2) == -1:
+ # i don't know why the above didn't work (i tried for expected price 100 and offer price 89 and it still accepted the offer
+ # so i wrote the below instead, which is not a good practice)
+ if record.price < 0.9 * record.property_id.expected_price:
+ raise exceptions.ValidationError("The selling price cannot be lower than 90% of the expected price.")
+ else:
+ record.status = "accepted"
+ record.property_id.state = "offer_accepted"
+ record.property_id.buyer_id = record.partner_id
+ record.property_id.selling_price = record.price
+ else:
+ raise exceptions.UserError("Only one offer can be accepted.")
+
+ def action_refuse_offer(self):
+ for record in self:
+ record.status = "refused"
+
+ @api.model_create_multi
+ def create(self, vals):
+ for val in vals:
+ property = self.env["estate.property"].browse(val["property_id"])
+ if val["price"] < property.best_price:
+ raise exceptions.UserError(f"Price must be at least ${property.best_price}.")
+
+ property.state = "offer_received"
+
+ 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 00000000000..eb19319c171
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,12 @@
+from odoo import models, fields
+
+class PropertyTag(models.Model):
+ _name = "estate.property.tag"
+ _description = "Real Estate Property Tag"
+ _order = "name"
+
+ name = fields.Char(required=True)
+ color = fields.Integer("Color")
+ _sql_constraints = [
+ ("name_unique", "UNIQUE(name)", "The property tag name must be unique.")
+ ]
\ No newline at end of file
diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py
new file mode 100644
index 00000000000..180f8c67042
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,36 @@
+from odoo import api, fields, models
+
+class PropertyType(models.Model):
+ _name = "estate.property.type"
+ _description = "Real estate property type"
+ _order = "sequence, name"
+
+ name = fields.Char(required = True)
+ sequence = fields.Integer("Sequence", default=1)
+ sql_constraints = [
+ ('name_unique', 'UNIQUE(name)', 'The property type name must be unique.')
+ ]
+
+ property_ids = fields.One2many("estate.property", "property_type_id", string = "Properties")
+ offer_ids = fields.One2many("estate.property.offer", "property_type_id", string="Offers")
+ offer_count = fields.Integer(compute="_compute_offers", string="Offers count")
+
+ @api.depends("offer_ids")
+ def _compute_offers(self):
+ for record in self:
+ record.offer_count = len(record.offer_ids)
+
+class PropertyTypeLine(models.Model):
+ _name = "estate.property.type.line"
+ _description = "Real estate property type line"
+
+ model_id = fields.Many2one("estate.property.type")
+ name = fields.Char("Title")
+ expected_price = fields.Float("Expected Price")
+ state = fields.Selection([
+ ("new", "New"),
+ ("offer_received", "Offer Received"),
+ ("offer_accepted", "Offer Accepted"),
+ ("sold", "Sold"),
+ ("canceled", "Canceled")
+ ], string="Status", required=True, copy=False, default="new")
diff --git a/estate/models/res_users.py b/estate/models/res_users.py
new file mode 100644
index 00000000000..9a0a24fa1bd
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,11 @@
+from odoo import fields, models
+
+class ResUsersProperties(models.Model):
+ _inherit = "res.users"
+
+ property_ids = fields.One2many(
+ "estate.property",
+ "salesman_id",
+ string="Properties",
+ domain=[('state', 'in', ['new', 'offer_received'])]
+ )
diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv
new file mode 100644
index 00000000000..ee747c69c4f
--- /dev/null
+++ b/estate/security/ir.model.access.csv
@@ -0,0 +1,6 @@
+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
+access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1
+access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1
+access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1
+estate.access_estate_property_type_line,access_estate_property_type_line,estate.model_estate_property_type_line,base.group_user,1,1,1,1
\ No newline at end of file
diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml
new file mode 100644
index 00000000000..ea4b655a9a7
--- /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..2e74bc44434
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,46 @@
+
+
+
+ estate.property.offer.form
+ estate.property.offer
+
+
+
+
+
+ estate.property.offer.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Offers
+ estate.property.offer
+ list,form
+ [('property_type_id', '=', context.get('active_id'))]
+
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_tag_views.xml b/estate/views/estate_property_tag_views.xml
new file mode 100644
index 00000000000..ca09b132f57
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,19 @@
+
+
+
+ Property Tags
+ estate.property.tag
+ list,form
+
+
+
+ estate.property.tag.list
+ estate.property.tag
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate/views/estate_property_type_views.xml b/estate/views/estate_property_type_views.xml
new file mode 100644
index 00000000000..4406b0f0060
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,57 @@
+
+
+
+ Property Types
+ estate.property.type
+ list,form
+
+
+
+
+ estate.property.type.view.tree
+ estate.property.type
+
+
+
+
+
+
+
+
+
+ estate.property.type.form
+ 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 00000000000..d431f901237
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,147 @@
+
+
+
+
+ estate.property.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.form
+ estate.property
+
+
+
+
+
+
+
+ estate.property.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.kanban
+ estate.property
+
+
+
+
+
+
+
+
+
+
+ Expected Price:
+
+
+
+ Best Offer:
+
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
+
+
+ Properties
+ estate.property
+ list,form,kanban
+ {'search_default_available': True}
+
+
\ 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..f0f2b534055
--- /dev/null
+++ b/estate/views/res_users_views.xml
@@ -0,0 +1,15 @@
+
+
+
+ res.users.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 00000000000..9a7e03eded3
--- /dev/null
+++ b/estate_account/__init__.py
@@ -0,0 +1 @@
+from . import models
\ No newline at end of file
diff --git a/estate_account/__manifest__.py b/estate_account/__manifest__.py
new file mode 100644
index 00000000000..6c4720c7dd0
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,11 @@
+{
+ "name": "Estate Account",
+ "category": "Real Estate",
+ "description": "Real Estate Accounting",
+ "application": True,
+ "installable": True,
+ "depends":[
+ "estate",
+ "accountant",
+ ],
+}
\ No newline at end of file
diff --git a/estate_account/models/__init__.py b/estate_account/models/__init__.py
new file mode 100644
index 00000000000..f4c8fd6db6d
--- /dev/null
+++ b/estate_account/models/__init__.py
@@ -0,0 +1 @@
+from . import estate_property
\ No newline at end of file
diff --git a/estate_account/models/estate_property.py b/estate_account/models/estate_property.py
new file mode 100644
index 00000000000..32ba27416f3
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,26 @@
+from odoo import models, Command
+
+class Property(models.Model):
+ _inherit = "estate.property"
+
+ def action_set_sold(self):
+ journal = self.env["account.journal"].search([("type", "=", "sale")], limit=1)
+ self.env["account.move"].create({
+ "move_type": "out_invoice",
+ "journal_id": journal.id,
+ "partner_id": self.buyer_id.id,
+ "name": self.name,
+ "line_ids": [
+ Command.create({
+ "name": "6% of the price",
+ "quantity": 1,
+ "price_unit": 0.06 * self.selling_price
+ }),
+ Command.create({
+ "name": "Administrative fees",
+ "quantity": 1,
+ "price_unit": 100.00
+ })
+ ]
+ })
+ return super().action_set_sold()