- hello world
+
+
+ hello world
+
+
+
+
+
+
+
+ The sum is:
+
+
+
+
+
+
+
-
+
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..d5570b13b92
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,28 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+{
+ 'name': 'Real Estate',
+ 'version': '19.0.0.1.0',
+ 'category': 'Real Estate/Properties',
+ 'sequence': 15,
+ 'summary': 'Track leads and close opportunities',
+ 'website': 'https://www.odoo.com/app/estate',
+ 'depends': [
+ 'base',
+ ],
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'views/estate_property_type_views.xml',
+ 'views/estate_property_tags_views.xml',
+ 'views/estate_property_users_views.xml',
+ 'views/estate_property_offers_views.xml',
+ 'views/estate_property_views.xml',
+ 'views/estate_property_menu.xml',
+ ],
+ 'demo': [],
+ 'installable': True,
+ 'application': True,
+ 'assets': {},
+ 'author': 'Odoo S.A.',
+ 'license': 'LGPL-3',
+}
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 00000000000..d16f45eccd6
--- /dev/null
+++ b/estate/models/__init__.py
@@ -0,0 +1,5 @@
+from . import estate_property
+from . import estate_propery_type
+from . import estate_propery_tag
+from . import estate_propery_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..508f9ca895b
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,112 @@
+from odoo import fields, models, api
+from odoo.exceptions import UserError, ValidationError
+from odoo.tools.float_utils import float_compare, float_is_zero
+
+
+class EstateProperty(models.Model):
+ _name = "estate.property"
+ _description = "Real Estate Property"
+ _order = "id desc"
+
+ name = fields.Char(required=True)
+ description = fields.Text()
+ postcode = fields.Char()
+ date_avaibility = fields.Date(string="Date Avaibility")
+ expected_price = fields.Float()
+ selling_price = fields.Float()
+ bedrooms = fields.Integer()
+ living_area = fields.Integer()
+ facades = fields.Integer()
+ garage = fields.Boolean()
+ garden = fields.Boolean()
+ garden_area = fields.Integer()
+ garden_orientation = fields.Selection(
+ selection=[
+ ("north", "North"),
+ ("south", "South"),
+ ("east", "East"),
+ ("west", "West")
+ ],
+ )
+ active = fields.Boolean(default=True)
+ state = fields.Selection(
+ selection=[
+ ("new", "New"),
+ ("offer received", "Offer Received"),
+ ("offer accepted", "Offer Accepted"),
+ ("sold", "Sold"),
+ ("cancelled", "Cancelled")
+ ],
+ default="new"
+ )
+
+ partner_id = fields.Many2one("res.partner", string="Partner")
+ user_id = fields.Many2one("res.users", string="Users")
+ property_type_id = fields.Many2one("estate.property.type",
+ string="PropType")
+ property_tag_ids = fields.Many2many("estate.property.tag", string="Tags")
+ offer_ids = fields.One2many(
+ "estate.property.offer", "property_id", string="offers")
+ total_area = fields.Float(compute="_compute_total")
+ best_price = fields.Float(compute="_compute_best_price")
+
+ # define constrain
+ _check_expected_price = models.Constraint(
+ 'CHECK(expected_price > 0)',
+ 'The expected price must be strictly positive',
+ )
+
+ @api.depends("living_area", "garden_area")
+ def _compute_total(self):
+ for record in self:
+ record.total_area = record.living_area + record.garden_area
+
+ @api.depends("offer_ids.price", "expected_price")
+ def _compute_best_price(self):
+ for record in self:
+ if record.offer_ids:
+ record.best_price = max(record.offer_ids.mapped("price"))
+ else:
+ record.best_price = 0
+
+ @api.onchange("garden")
+ def _onchange_garden(self):
+ for record in self:
+ if record.garden:
+ record.garden_area = 10
+ record.garden_orientation = "north"
+ else:
+ record.garden_area = 0
+ record.garden_orientation = ""
+
+ @api.constrains("expected_price", "selling_price")
+ def _check_price_offer(self):
+ for record in self:
+ if record.selling_price > 0:
+ if float_is_zero(record.selling_price, precision_rounding=2):
+ continue
+ min_price = 0.9 * record.expected_price
+ # if offer percentage lower then 90%
+ if float_compare(record.selling_price, min_price, precision_digits=2) == -1:
+ raise ValidationError(
+ "The selling price cannot be lower than 90% of the expected price\n"
+ "You must reduce the expected price if you want to accept this offer"
+ )
+
+ def action_sold(self):
+ for record in self:
+ if record.state == "cancelled":
+ raise UserError("Cancelled properties cannot be sold")
+ record.state = "sold"
+
+ def action_cancel(self):
+ for record in self:
+ if record.state == "sold":
+ raise UserError("Sold properties cannot be cancelled")
+ record.state = "cancelled"
+
+ @api.ondelete(at_uninstall=False)
+ def _unlink_if_new_or_canceled(self):
+ for record in self:
+ if record.state not in ['new', 'cancelled']:
+ raise UserError("You can only delete new or canceled properties.")
diff --git a/estate/models/estate_propery_offer.py b/estate/models/estate_propery_offer.py
new file mode 100644
index 00000000000..a3ab31c87b3
--- /dev/null
+++ b/estate/models/estate_propery_offer.py
@@ -0,0 +1,90 @@
+from odoo import fields, models, api
+from odoo.exceptions import UserError, ValidationError
+from datetime import datetime, timedelta
+
+
+class EstatePropertyOffer(models.Model):
+ _name = "estate.property.offer"
+ _description = "Real Estate Property Offer"
+ _order = "price desc"
+
+ price = fields.Float()
+ status = fields.Selection(
+ selection=[
+ ("accepted", "Accepted"),
+ ("refused", "Refused")
+ ],
+ )
+ partner_id = fields.Many2one(
+ "res.partner", string="Partner", required=True)
+ property_id = fields.Many2one(
+ "estate.property", required=True)
+ property_type_id = fields.Many2one("estate.property.type")
+ deadline = fields.Date(
+ string="Deadline",
+ default=datetime.today(),
+ compute="_compute_validity_days",
+ inverse="_inverse_deadline",
+ store=True
+ )
+ validity_days = fields.Integer(default=7)
+
+ _check_expected_price = models.Constraint(
+ 'CHECK(price > 0)',
+ 'The price must be strictly positive',
+ )
+
+ @api.depends("validity_days")
+ def _compute_validity_days(self):
+ for record in self:
+ if record.deadline and record.validity_days > 0:
+ record.deadline = record.deadline + timedelta(
+ days=record.validity_days)
+ else:
+ record.deadline = fields.Date.today()
+
+ @api.depends("deadline")
+ def _inverse_deadline(self):
+ for record in self:
+ if record.deadline:
+ diff = record.deadline - fields.Date.today()
+ record.validity_days = diff.days
+
+ def accept_offer(self):
+ for record in self:
+ if record.status == "accepted":
+ raise ValidationError("the offer already accepted")
+
+ if record.property_id.garden_orientation == "south" and record.property_id.expected_price > record.price:
+ raise ValidationError("The south-facing garden can only be accepted if above expected price")
+
+ if record.property_id.selling_price == 0:
+ record.status = "accepted"
+ record.property_id.selling_price = record.price
+ record.property_id.partner_id = record.partner_id
+ record.property_id.state = "offer accepted"
+
+ def action_refuse_offer(self):
+ for record in self:
+ if record.status == "accepted":
+ raise ValidationError(
+ "You're not eligible to refused an accepted offer"
+ )
+ record.status = "refused"
+
+ @api.model
+ def create(self, val_list):
+ for vals in val_list:
+ property_id = vals.get('property_id')
+
+ existing_offers = self.search([
+ ('property_id', '=', property_id)],
+ order='price desc', limit=1)
+
+ if existing_offers and vals.get('price', 0) < existing_offers.price:
+ raise UserError(f"You cannot create an offer lower than {existing_offers.price}.")
+
+ property_record = self.env['estate.property'].browse(property_id)
+ property_record.state = 'offer received'
+
+ return super().create(val_list)
diff --git a/estate/models/estate_propery_tag.py b/estate/models/estate_propery_tag.py
new file mode 100644
index 00000000000..e78e66125aa
--- /dev/null
+++ b/estate/models/estate_propery_tag.py
@@ -0,0 +1,15 @@
+from odoo import fields, models
+
+
+class EstatePropertyTag(models.Model):
+ _name = "estate.property.tag"
+ _description = "Real Estate Property Tag"
+ _order = "name asc"
+
+ name = fields.Char(required=True)
+
+ color = fields.Integer()
+
+ _check_unique_property_tags = models.Constraint(
+ 'unique(name)'
+ )
diff --git a/estate/models/estate_propery_type.py b/estate/models/estate_propery_type.py
new file mode 100644
index 00000000000..a2ec0c12e6e
--- /dev/null
+++ b/estate/models/estate_propery_type.py
@@ -0,0 +1,31 @@
+from odoo import fields, models, api
+
+
+class EstatePropertyType(models.Model):
+ _name = "estate.property.type"
+ _description = "Real Estate Property Type"
+ _order = "name asc"
+
+ sequence = fields.Integer('Sequence', default=1, help="Used to order stages. Lower is better.")
+ name = fields.Char(required=True)
+
+ property_ids = fields.One2many("estate.property", "property_type_id")
+ offer_ids = fields.One2many("estate.property.offer", "property_id")
+ expected_price = fields.Float()
+ state = fields.Char()
+ offer_count = fields.Char(compute="_compute_offer")
+
+ @api.depends("offer_ids")
+ def _compute_offer(self):
+ for record in self:
+ record.offer_count = len(record.offer_ids)
+
+ def action_offer(self):
+ return {
+ "type": "ir.actions.act_window",
+ "name": "Propery Offers",
+ "res_model": "estate.property.offer",
+ "domain": [("property_id", "=", self.id)],
+ "view_mode": "list,form",
+ "context": {"default_property_id": self.id},
+ }
diff --git a/estate/models/res_users.py b/estate/models/res_users.py
new file mode 100644
index 00000000000..a387e729ad4
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,6 @@
+from odoo import fields, models
+
+
+class Users(models.Model):
+ _inherit = "res.users"
+ property_ids = fields.One2many("estate.property", 'user_id')
diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv
new file mode 100644
index 00000000000..0c0b62b7fee
--- /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/static/description/icon.png b/estate/static/description/icon.png
new file mode 100644
index 00000000000..a02a465d8cc
Binary files /dev/null and b/estate/static/description/icon.png differ
diff --git a/estate/static/description/icon.svg b/estate/static/description/icon.svg
new file mode 100644
index 00000000000..12e8ec084cc
--- /dev/null
+++ b/estate/static/description/icon.svg
@@ -0,0 +1 @@
+
diff --git a/estate/static/description/icon_hi.png b/estate/static/description/icon_hi.png
new file mode 100644
index 00000000000..7a3f54851c9
Binary files /dev/null and b/estate/static/description/icon_hi.png differ
diff --git a/estate/tests/__init__.py b/estate/tests/__init__.py
new file mode 100644
index 00000000000..576617cccff
--- /dev/null
+++ b/estate/tests/__init__.py
@@ -0,0 +1 @@
+from . import test_estate_property
diff --git a/estate/tests/test_estate_property.py b/estate/tests/test_estate_property.py
new file mode 100644
index 00000000000..6f6b1d6724b
--- /dev/null
+++ b/estate/tests/test_estate_property.py
@@ -0,0 +1,45 @@
+from odoo.exceptions import ValidationError
+from odoo.tests import TransactionCase, tagged
+from odoo import Command
+
+
+@tagged('post_install', '-at_install')
+class TestEstateProperty(TransactionCase):
+
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
+ cls.estate = cls.env['estate.property'].create({
+ 'name': 'Super test estate',
+ 'expected_price': 100000.0,
+ 'state': 'new',
+ })
+ cls.test_partner = cls.env['res.partner'].create({
+ 'name': 'Maman ours',
+ })
+
+ def test_estate_best_price(self):
+ '''
+ Ensure best price is correctly updated when an offer is received.
+ '''
+ self.assertEqual(self.estate.best_price, 0.0)
+ self.estate.offer_ids = [Command.create({
+ 'price': 125000.0,
+ 'partner_id': self.test_partner.id,
+ })]
+ self.assertEqual(self.estate.best_price, 125000.0)
+
+ def test_accept_offer_south_facing_garden(self):
+ '''
+ Ensure offers for estates with south-facing gardens can only be accepted if above expected
+ price.
+ '''
+ self.estate.expected_price = 500000
+ self.estate.garden = True
+ self.estate.garden_orientation = 'south'
+ self.estate.offer_ids = [Command.create({
+ 'price': 475000.0,
+ 'partner_id': self.test_partner.id,
+ })]
+ with self.assertRaises(ValidationError):
+ self.estate.offer_ids.accept_offer()
diff --git a/estate/views/estate_property_menu.xml b/estate/views/estate_property_menu.xml
new file mode 100644
index 00000000000..ebb2cd358c3
--- /dev/null
+++ b/estate/views/estate_property_menu.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_property_offers_views.xml b/estate/views/estate_property_offers_views.xml
new file mode 100644
index 00000000000..eae2502042a
--- /dev/null
+++ b/estate/views/estate_property_offers_views.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ estate.property_offer.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_property_tags_views.xml b/estate/views/estate_property_tags_views.xml
new file mode 100644
index 00000000000..ba722c52701
--- /dev/null
+++ b/estate/views/estate_property_tags_views.xml
@@ -0,0 +1,30 @@
+
+
+
+
+ Property Tags
+ estate.property.tag
+ list,form
+
+
+ If you need help, ask yourself
+
+
+ You need to be strong, go working out
+
+
+ don't skip working out
+
+
+
+
+ estate.properties_tag.list
+ estate.property.tag
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_property_type_views.xml b/estate/views/estate_property_type_views.xml
new file mode 100644
index 00000000000..4b308da9583
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,62 @@
+
+
+
+
+ Property Types
+ estate.property.type
+ list,form
+
+
+ If you need help, ask yourself
+
+
+ You need to be strong, go working out
+
+
+ don't skip working out
+
+
+
+
+
+
+
+
+ estate.property_type.form
+ estate.property.type
+
+
+
+
+
+
diff --git a/estate/views/estate_property_users_views.xml b/estate/views/estate_property_users_views.xml
new file mode 100644
index 00000000000..5cc378bd95a
--- /dev/null
+++ b/estate/views/estate_property_users_views.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ inherited.res.users.view.form.estate
+ res.users
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml
new file mode 100644
index 00000000000..c5e52b27903
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,166 @@
+
+
+
+
+ Property
+ estate.property
+ list,kanban,form
+ {'search_default_active': 1}
+
+
+ If you need help, ask yourself
+
+
+ You need to be strong, go working out
+
+
+ don't skip working out
+
+
+
+
+ estate.properties.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.form
+ estate.property
+
+
+
+
+
+
+
+ estate.property.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.view.kanban
+ estate.property
+
+
+
+
+
+
+
+
+
+ Expected Price:
+
+
+ Best Offer:
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
+
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..cdcbe098392
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,13 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+{
+ 'name': 'Real Estate Accounting',
+ 'depends': [
+ 'estate',
+ 'account',
+ ],
+ 'application': True,
+ 'installable': True,
+ 'author': 'Odoo S.A.',
+ 'license': 'LGPL-3',
+}
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..fb012e9967f
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,28 @@
+from odoo import models, Command
+
+
+class EstateProperty(models.Model):
+ _inherit = "estate.property"
+
+ def action_sold(self):
+ for record in self:
+ self.env['account.move'].create({
+ 'partner_id': record.user_id.id,
+ 'move_type': 'out_invoice',
+
+ 'invoice_line_ids': [
+ Command.create(
+ {
+ 'name': record.name,
+ 'quantity': 1,
+ 'price_unit': record.selling_price * 0.06,
+ },
+ {
+ 'name': 'Administrative Fees',
+ 'quantity': 1,
+ 'price_unit': 100.00,
+ }
+ ),
+ ]})
+
+ return super().action_sold()
diff --git a/estate_account/security/ir.model.access.csv b/estate_account/security/ir.model.access.csv
new file mode 100644
index 00000000000..e69de29bb2d