+
hello world
+
+
+
+
+
+ Some content
+
+
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/todo/todoitem.js b/awesome_owl/static/src/todo/todoitem.js
new file mode 100644
index 00000000000..e2f1d7023bb
--- /dev/null
+++ b/awesome_owl/static/src/todo/todoitem.js
@@ -0,0 +1,27 @@
+import { Component } from "@odoo/owl";
+
+
+export class TodoItem extends Component {
+ static template = "awesome_owl.todoitem";
+ static props = {
+ id: Number,
+ description: String,
+ isCompleted: Boolean,
+ onToggle: {
+ Function,
+ optional: true,
+ },
+ onClick: {
+ Function,
+ optional: true,
+ },
+ };
+
+ toggleState() {
+ this.props.onToggle(this.props.id);
+ }
+
+ removeTodo() {
+ this.props.onClick(this.props.id);
+ }
+}
diff --git a/awesome_owl/static/src/todo/todoitem.xml b/awesome_owl/static/src/todo/todoitem.xml
new file mode 100644
index 00000000000..867f89fff73
--- /dev/null
+++ b/awesome_owl/static/src/todo/todoitem.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ .
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/todo/todolist.js b/awesome_owl/static/src/todo/todolist.js
new file mode 100644
index 00000000000..05775dc4179
--- /dev/null
+++ b/awesome_owl/static/src/todo/todolist.js
@@ -0,0 +1,39 @@
+import { Component, useState, useRef } from "@odoo/owl";
+import { TodoItem } from "./todoitem"
+import { useAutofocus } from "@awesome_owl/utils"
+
+
+export class TodoList extends Component {
+ static template = "awesome_owl.todolist";
+ static components = { TodoItem };
+
+ setup() {
+ this.todos = useState([]);
+ this.nextId = 0;
+ this.description_inputRef = useRef("todo_input");
+ useAutofocus(this.description_inputRef);
+ }
+
+ addTodo(ev) {
+ const description = this.description_inputRef.el.value.trim();
+ if (ev.keyCode === 13 && description) {
+ this.todos.push({ id: this.nextId, description: description, isCompleted: false });
+ this.nextId++;
+ this.description_inputRef.el.value = "";
+ }
+ }
+
+ toggleTodo(id) {
+ const todo = this.todos.find(t => t.id === id);
+ if (todo) {
+ todo.isCompleted = !todo.isCompleted;
+ }
+ }
+
+ removeTodo(id) {
+ const index = this.todos.findIndex(t => t.id === id);
+ if (index >= 0) {
+ this.todos.splice(index, 1);
+ }
+ }
+}
diff --git a/awesome_owl/static/src/todo/todolist.xml b/awesome_owl/static/src/todo/todolist.xml
new file mode 100644
index 00000000000..185f85b00d3
--- /dev/null
+++ b/awesome_owl/static/src/todo/todolist.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js
new file mode 100644
index 00000000000..5c0a897c728
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,13 @@
+import { useEffect } from "@odoo/owl";
+
+
+export function useAutofocus(ref) {
+ useEffect(
+ () => {
+ if (ref.el) {
+ ref.el.focus();
+ }
+ },
+ () => [ref.el]
+ );
+}
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..647a95ef2f3
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,23 @@
+{
+ "name": "Real Estate",
+ "version": "1.0",
+ "summary": "Manage properties and buyers.",
+ "license": "OEEL-1",
+ "depends": [
+ "base",
+ ],
+ "author": "wimar-odoo",
+ "description": """
+ Manage efficiently real estate properties for sale and match them with potential buyers.
+ """,
+ "application": True,
+ "data": [
+ "security/ir.model.access.csv",
+ "views/estate_property_views.xml",
+ "views/estate_property_type_views.xml",
+ "views/estate_property_tag_views.xml",
+ "views/estate_property_offer_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..c796d6c062f
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,92 @@
+from odoo import fields, models, api, _
+from odoo.exceptions import UserError, ValidationError
+from odoo.tools import float_is_zero, float_compare
+
+
+class EstateProperty(models.Model):
+ _name = "estate.property"
+ _description = "Estate Property"
+ _order = "id DESC"
+
+ name = fields.Char(string="Title", required=True)
+ description = fields.Text()
+ postcode = fields.Char()
+ date_availability = fields.Date(string="Available From", copy=False, default=fields.Date.add(fields.Date.today(), months=3))
+ expected_price = fields.Float(required=True)
+ selling_price = fields.Float(readonly=True, copy=False)
+ bedrooms = fields.Integer(default=2)
+ living_area = fields.Integer(string="Living Area (sqm)")
+ facades = fields.Integer()
+ garage = fields.Boolean()
+ garden = fields.Boolean()
+ garden_area = fields.Integer(string="Garden Area (sqm)")
+ garden_orientation = fields.Selection(
+ selection=[("north", "North"), ("south", "South"), ("east", "East"), ("west", "West")],
+ help="The orientation of the Garden",
+ )
+ active = fields.Boolean(default=True)
+ state = fields.Selection(
+ selection=[("new", "New"), ("received", "Offer Received"), ("accepted", "Offer Accepted"), ("sold", "Sold"), ("cancelled", "Cancelled")],
+ required=True,
+ copy=False,
+ default="new",
+ help="The current state of the property",
+ )
+ property_type_id = fields.Many2one("estate.property.type")
+ salesperson_id = fields.Many2one("res.users", string="Salesman", default=lambda self: self.env.user)
+ buyer_id = fields.Many2one("res.partner", copy=False)
+ tag_ids = fields.Many2many("estate.property.tag")
+ offer_ids = fields.One2many("estate.property.offer", "property_id")
+ total_area = fields.Integer(compute="_compute_total_area")
+ best_price = fields.Float(string="Best offer", compute="_compute_best_price")
+
+ _positive_expected_price = models.Constraint(
+ "CHECK(expected_price > 0)",
+ "The expected price must be strictly positive.",
+ )
+
+ @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")
+ 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.0
+
+ @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_property_sold(self):
+ if self.filtered(lambda x: x.state == "cancelled"):
+ raise UserError(_("Cancelled properties cannot be sold."))
+ self.state = "sold"
+ return True
+
+ def action_property_cancel(self):
+ if self.filtered(lambda x: x.state == "sold"):
+ raise UserError(_("Sold properties cannot be cancelled."))
+ self.state = "cancelled"
+ return True
+
+ @api.constrains("selling_price", "expected_price")
+ @api.onchange("selling_price", "expected_price")
+ def _check_ninety_percent(self):
+ for record in self:
+ if not float_is_zero(record.selling_price, 2) and float_compare(record.expected_price * 0.9, record.selling_price, 2) == 1:
+ raise ValidationError(_("The selling price must be at least 90% of the expected price! You must reduce the expected price if you want to accept this offer."))
+
+ @api.ondelete(at_uninstall=False)
+ def _unlink_except_new_and_cancelled(self):
+ if self.filtered(lambda x: x.state not in ("new", "cancelled")):
+ raise UserError(_("Properties need to be new or cancelled to be unlinked."))
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..88d5c980421
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,58 @@
+from odoo import models, fields, api, _
+from odoo.exceptions import UserError
+
+
+class EstatePropertyOffer(models.Model):
+ _name = "estate.property.offer"
+ _description = "Estate Property Offer"
+ _order = "price DESC"
+
+ price = fields.Float()
+ status = fields.Selection(
+ selection=[("accepted", "Accepted"), ("refused", "Refused")],
+ copy=False,
+ )
+ partner_id = fields.Many2one("res.partner", string="Buyer", required=True)
+ property_id = fields.Many2one("estate.property", required=True)
+ validity = fields.Integer(string="Validity (days)", default=7)
+ date_deadline = fields.Date(string="Deadline", compute="_compute_date_deadline", inverse="_inverse_date_deadline")
+ property_type_id = fields.Many2one("estate.property.type", related="property_id.property_type_id", store=True)
+
+ @api.depends("create_date", "validity")
+ def _compute_date_deadline(self):
+ for record in self:
+ record.date_deadline = fields.Date.add(record.create_date or fields.Date.today(), days=record.validity)
+
+ def _inverse_date_deadline(self):
+ for record in self:
+ record.validity = (record.date_deadline - record.create_date.date()).days
+
+ def action_accept_offer(self):
+ if self.filtered(lambda x: x.property_id.state in ("accepted", "sold", "cancelled")):
+ raise UserError(_("This offer can't be accepted because the property is currently %s.", self.property_id.state))
+
+ self.status = "accepted"
+ self.property_id.state = "accepted"
+ self.property_id.selling_price = self.price
+ self.property_id.buyer_id = self.partner_id
+
+ return True
+
+ def action_refuse_offer(self):
+ self.status = "refused"
+ return True
+
+ _positive_offer_price = models.Constraint(
+ "CHECK(price > 0)",
+ "The offer price must be strictly positive.",
+ )
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ properties = self.env["estate.property"].browse([vals["property_id"] for vals in vals_list])
+ for vals in vals_list:
+ filtered_properties = properties.filtered(lambda p: p.id == vals["property_id"])
+ if vals["price"] <= filtered_properties.best_price:
+ raise UserError(_("The offer price must be strictly greater than the current best offer."))
+ filtered_properties.state = "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..066b582f05f
--- /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 = "Estate Property Tag"
+ _order = "name"
+
+ name = fields.Char(required=True)
+ color = fields.Integer()
+
+ _unique_property_tag_name = models.Constraint(
+ "UNIQUE(name)",
+ "The 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 00000000000..1a53a4d26c1
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,23 @@
+from odoo import models, fields, api
+
+
+class EstatePropertyType(models.Model):
+ _name = "estate.property.type"
+ _description = "Estate Property Type"
+ _order = "name, sequence"
+
+ name = fields.Char(required=True)
+ property_ids = fields.One2many("estate.property", "property_type_id")
+ sequence = fields.Integer(default=1)
+ offer_ids = fields.One2many("estate.property.offer", "property_type_id")
+ offer_count = fields.Integer(compute="_compute_offer_count")
+
+ _unique_property_type_name = models.Constraint(
+ "UNIQUE(name)",
+ "The tag name must be unique.",
+ )
+
+ @api.depends("offer_ids")
+ def _compute_offer_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..ddefee38646
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,7 @@
+from odoo import models, fields
+
+
+class ResUsers(models.Model):
+ _inherit = "res.users"
+
+ property_ids = fields.One2many("estate.property", "salesperson_id")
diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv
new file mode 100644
index 00000000000..826a96a7eb7
--- /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
+access_estate_property_user,access_estate_property_user,model_estate_property,base.group_user,1,1,1,1
+access_estate_property_type_user,access_estate_property_type_user,model_estate_property_type,base.group_user,1,1,1,1
+access_estate_property_tag_user,access_estate_property_tag_user,model_estate_property_tag,base.group_user,1,1,1,1
+access_estate_property_offer_user,access_estate_property_offer_user,model_estate_property_offer,base.group_user,1,1,1,1
+access_res_users_user,access_res_users_user,model_res_users,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..6a6329257c5
--- /dev/null
+++ b/estate/views/estate_menus.xml
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml
new file mode 100644
index 00000000000..a467f73818a
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,36 @@
+
+
+
+ estate.property.offer.form
+ estate.property.offer
+
+
+
+
+
+
+ estate.property.offer.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_property_tag_views.xml b/estate/views/estate_property_tag_views.xml
new file mode 100644
index 00000000000..b7790ea57e5
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,32 @@
+
+
+
+ Property Tags
+ estate.property.tag
+ list,form
+
+
+
+ estate.property.tag.form
+ estate.property.tag
+
+
+
+
+
+
+ estate.property.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..20252594407
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,63 @@
+
+
+
+ Property Types
+ estate.property.type
+ list,form
+
+
+
+ Properties Offers
+ estate.property.offer
+ list
+ [("property_type_id", "=", active_id)]
+
+
+
+ estate.property.type.list
+ estate.property.type
+
+
+
+
+
+
+
+
+
+ estate.property.type.form
+ estate.property.type
+
+
+
+
+
diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml
new file mode 100644
index 00000000000..5e342c8e683
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,129 @@
+
+
+
+ Properties
+ estate.property
+ list,form,kanban
+ {"search_default_state": True}
+
+
+
+ estate.property.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.form
+ estate.property
+
+
+
+
+
+
+ estate.property.kanban
+ estate.property
+
+
+
+
+
+
+
+
+
+ Expected Price:
+
+ Best Offer:
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
+
+ estate.property.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/res_users_views.xml b/estate/views/res_users_views.xml
new file mode 100644
index 00000000000..da370163e0a
--- /dev/null
+++ b/estate/views/res_users_views.xml
@@ -0,0 +1,15 @@
+
+
+
+ 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..2f79489a775
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,16 @@
+{
+ "name": "Estate Account",
+ "version": "19.0.1.0.0",
+ "summary": "Manage properties invoices",
+ "description": "Manage properties invoices",
+ "author": "wimar-odoo",
+ "license": "OEEL-1",
+ "depends": [
+ "estate",
+ "account",
+ ],
+ "application": True,
+ "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..732f739d968
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,32 @@
+from odoo import models, Command
+
+
+class EstateProperty(models.Model):
+ _inherit = "estate.property"
+
+ def action_property_sold(self):
+ values = {
+ "partner_id": self.salesperson_id.id,
+ "move_type": "out_invoice",
+ "journal_id": self.env["account.journal"].search([('type', '=', 'sale')], limit=1).id,
+ "invoice_line_ids": [
+ Command.create({
+ "name": self.name,
+ "quantity": 1,
+ "price_unit": self.selling_price,
+ }),
+ Command.create({
+ "name": "6% commission",
+ "quantity": 1,
+ "price_unit": self.selling_price * 0.06,
+ }),
+ Command.create({
+ "name": "Administrative fees",
+ "quantity": 1,
+ "price_unit": 100.00,
+ })
+ ],
+ }
+
+ self.env["account.move"].create(values)
+ return super().action_property_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..a6992df6d34
--- /dev/null
+++ b/estate_account/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_estate_property_user,access_estate_property_user,model_estate_property,base.group_user,1,1,1,1