- hello world
+
+
+
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/todo_list/todo_item.js b/awesome_owl/static/src/todo_list/todo_item.js
new file mode 100644
index 00000000000..29d4e7ebbac
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_item.js
@@ -0,0 +1,21 @@
+import { Component } from "@odoo/owl";
+
+export class TodoItem extends Component {
+ static template = "awesome_owl.TodoItem";
+ static props = {
+ todo: {
+ type: Object,
+ shape: { id: Number, description: String, isCompleted: Boolean },
+ },
+ toggleState: Function,
+ removeTodo: Function,
+ };
+
+ onChange() {
+ this.props.toggleState(this.props.todo.id);
+ }
+
+ onRemove() {
+ this.props.removeTodo(this.props.todo.id);
+ }
+}
diff --git a/awesome_owl/static/src/todo_list/todo_item.xml b/awesome_owl/static/src/todo_list/todo_item.xml
new file mode 100644
index 00000000000..60c05fcf86d
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_item.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/todo_list/todo_list.js b/awesome_owl/static/src/todo_list/todo_list.js
new file mode 100644
index 00000000000..64c6c6d7f3c
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_list.js
@@ -0,0 +1,39 @@
+import { Component, useState } from "@odoo/owl";
+import { TodoItem } from "./todo_item";
+import { useAutoFocus } from "../utils";
+
+export class TodoList extends Component {
+ static template = "awesome_owl.TodoList";
+ static components = { TodoItem };
+
+ setup() {
+ this.nextId = 0;
+ this.todos = useState([]);
+ useAutoFocus("input");
+ }
+
+ addTodo(ev) {
+ if (ev.keyCode == 13 && ev.target.value != ""){
+ this.todos.push({
+ id: this.nextId++,
+ description: ev.target.value,
+ isCompleted: false
+ });
+ ev.target.value = "";
+ }
+ }
+
+ toggleTodo(todoId) {
+ const todo = this.todos.find((todo) => todo.id === todoId);
+ if (todo) {
+ todo.isCompleted = !todo.isCompleted;
+ }
+ }
+
+ removeTodo(todoId) {
+ const index = this.todos.findIndex((todo) => todo.id === todoId);
+ if (index >= 0) {
+ this.todos.splice(index, 1);
+ }
+ }
+}
diff --git a/awesome_owl/static/src/todo_list/todo_list.xml b/awesome_owl/static/src/todo_list/todo_list.xml
new file mode 100644
index 00000000000..3248c389e9c
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_list.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js
new file mode 100644
index 00000000000..e19a0f03f62
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,8 @@
+import { useRef, onMounted } from "@odoo/owl";
+
+export function useAutoFocus(refName) {
+ const ref = useRef(refName);
+ onMounted(() => {
+ ref.el.focus();
+ });
+}
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..b7d8db60d31
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,20 @@
+{
+ 'name': 'estate',
+ 'version': 1.0,
+ 'author': 'Odoo',
+ 'license': 'LGPL-3',
+ 'depends': [
+ 'base',
+ ],
+ 'installable': True,
+ 'application': True,
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'views/estate_property_offer_views.xml',
+ 'views/estate_property_views.xml',
+ 'views/estate_property_type_views.xml',
+ 'views/estate_property_tag_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..780a7e5c06c
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,120 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError, ValidationError
+from odoo.tools.float_utils import float_compare
+
+
+class EstateProperty(models.Model):
+ _name = 'estate.property'
+ _description = 'Estate property'
+ _order = 'id desc'
+
+ name = fields.Char(required=True, string="Title")
+ description = fields.Text()
+ postcode = fields.Char()
+ date_availability = fields.Datetime(
+ "Available From", copy=False,
+ default=lambda self: fields.Datetime.add(fields.Datetime.today(), months=3),
+ )
+ expected_price = fields.Float(required=True)
+ selling_price = fields.Float(readonly=True, copy=False)
+ best_price = fields.Float(compute="_compute_best_price")
+ 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(
+ string="Garden Orientation",
+ selection=[
+ ("north", "North"),
+ ("south", "South"),
+ ("east", "East"),
+ ("west", "West"),
+ ],
+ )
+ total_area = fields.Integer(compute="_compute_total_area", readonly=True)
+ active = fields.Boolean(default=True)
+ state = fields.Selection(
+ string="Status",
+ selection=[
+ ("new", "New"),
+ ("offer_received", "Offer Received"),
+ ("offer_accepted", "Offer Accepted"),
+ ("sold", "Sold"),
+ ("cancelled", "Cancelled"),
+ ],
+ default="new",
+ )
+ property_type_id = fields.Many2one("estate.property.type", string="Type")
+ buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False)
+ salesperson_id = fields.Many2one(
+ "res.users", string="Salesperson", default=lambda self: self.env.uid
+ )
+ tag_ids = fields.Many2many("estate.property.tag", string="Tags")
+ offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers")
+
+ _check_positive_expected_price = models.Constraint(
+ "CHECK(expected_price > 0)",
+ "The expected price of a property must be strictly positive.",
+ )
+
+ _check_positive_selling_price = models.Constraint(
+ "CHECK(selling_price >= 0)", "The selling price of a property must be positive."
+ )
+
+ @api.constrains("selling_price")
+ def _check_selling_price(self):
+ for property in self:
+ if (float_compare(property.selling_price, (0.9 * property.expected_price), 2) == -1):
+ raise ValidationError(self.env._("The selling price must be at least 90% of the expected price. You may decrease the expected price if you want to accept this offer."))
+
+ @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:
+ 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):
+ if self.garden:
+ self.garden_area = 10
+ self.garden_orientation = "north"
+ else:
+ self.garden_area = 0
+ self.garden_orientation = ""
+
+ def action_sold_property(self):
+ for property in self:
+ if property.state == "cancelled":
+ raise UserError(self.env._("Cancelled properties cannot be sold"))
+ property.state = "sold"
+ return True
+
+ def action_cancel_property(self):
+ for property in self:
+ if property.state == "sold":
+ raise UserError(self.env._("Sold properties cannot be cancelled"))
+ property.state = "cancelled"
+ return True
+
+ @api.ondelete(at_uninstall=False)
+ def _check_unlink(self):
+ for property in self:
+ if property.state != "new" and property.state != "cancelled":
+ raise UserError(self.env._("Only new and cancelled properties can be deleted!"))
+
+ @api.onchange("offer_ids")
+ def _onchange_offer_ids(self):
+ for property in self:
+ if len(property.offer_ids) == 0:
+ property.state = "new"
+ elif property.state != "offer_accepted":
+ property.state = "offer_received"
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..8669c4aefcc
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,75 @@
+from odoo import api, fields, models
+from odoo.exceptions import ValidationError
+
+
+class EstatePropertyOffer(models.Model):
+ _name = 'estate.property.offer'
+ _description = 'Estate Property Offer'
+ _order = 'price desc'
+
+ price = fields.Float()
+ status = fields.Selection(
+ string="Status",
+ selection=[("accepted", "Accepted"), ("refused", "Refused")],
+ copy=False,
+ )
+ validity = fields.Integer(default=7, string="Validity (days)")
+ date_deadline = fields.Date(
+ compute="_compute_deadline", inverse="_inverse_deadline", string="Deadline",
+ )
+
+ partner_id = fields.Many2one("res.partner", string="Partner")
+ property_id = fields.Many2one("estate.property", string="Property")
+ property_type_id = fields.Many2one(
+ related="property_id.property_type_id", store=True
+ )
+
+ _check_positive_price = models.Constraint(
+ "CHECK(price > 0)",
+ "The expected price of a offer must be positive.",
+ )
+
+ @api.depends("validity")
+ def _compute_deadline(self):
+ for offer in self:
+ if offer.create_date:
+ offer.date_deadline = fields.Date.add(
+ offer.create_date, days=offer.validity,
+ )
+ else:
+ offer.date_deadline = fields.Date.add(
+ fields.Date.today(), days=offer.validity,
+ )
+
+ def _inverse_deadline(self):
+ for offer in self:
+ offer.validity = (
+ offer.date_deadline - fields.Date.to_date(offer.create_date)
+ ).days
+
+ def action_accept_offer(self):
+ for offer in self:
+ if offer.property_id.state == "offer_accepted":
+ offer.status = "refused"
+ return True
+ offer.status = "accepted"
+ offer.property_id.selling_price = offer.price
+ offer.property_id.buyer_id = offer.partner_id
+ offer.property_id.state = "offer_accepted"
+ return True
+
+ def action_refuse_offer(self):
+ for offer in self:
+ if offer.status == "accepted":
+ offer.property_id.selling_price = 0
+ offer.property_id.buyer_id = ""
+ offer.status = "refused"
+ return True
+
+ @api.model
+ def create(self, vals):
+ for record in vals:
+ best_price = self.env["estate.property"].browse(record["property_id"]).best_price
+ if record["price"] < best_price:
+ raise ValidationError(self.env._("The offer must be greater than %s€", best_price))
+ 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..d9631697ab6
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,14 @@
+from odoo import fields, models
+
+
+class EstatePropertyTag(models.Model):
+ _name = 'estate.property.tag'
+ _description = 'Estate Property Type'
+ _order = 'name asc'
+
+ name = fields.Char(required=True)
+ color = fields.Integer()
+
+ _check_unique_name = models.Constraint(
+ "UNIQUE(name)", "A property tag name should be unique"
+ )
diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py
new file mode 100644
index 00000000000..d463145cdc9
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,25 @@
+from odoo import api, fields, models
+
+
+class EstatePropertyType(models.Model):
+ _name = 'estate.property.type'
+ _description = 'Estate Property Type'
+ _order = 'name asc'
+
+ name = fields.Char(required=True)
+ sequence = fields.Integer(
+ "Sequence", default=1, help="Use to order property types. Lower is better.",
+ )
+
+ property_ids = fields.One2many("estate.property", "property_type_id")
+ offer_ids = fields.One2many("estate.property.offer", "property_type_id")
+ offer_count = fields.Integer(compute="_compute_offer_count")
+
+ _check_unique_name = models.Constraint(
+ "UNIQUE(name)", "A property type name should be unique"
+ )
+
+ @api.depends("offer_ids")
+ def _compute_offer_count(self):
+ for type in self:
+ type.offer_count = len(type.offer_ids)
diff --git a/estate/models/res_users.py b/estate/models/res_users.py
new file mode 100644
index 00000000000..16301fc546f
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,11 @@
+from odoo import fields, models
+
+
+class User(models.Model):
+ _inherit = "res.users"
+
+ property_ids = fields.One2many(
+ "estate.property",
+ "salesperson_id",
+ 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..49bca99cac8
--- /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
+access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
+access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1
+access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1
+access_estate_property_offer,access_estate_property_offer,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..2407326acd7
--- /dev/null
+++ b/estate/views/estate_menus.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml
new file mode 100644
index 00000000000..2f58d88c7f9
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,31 @@
+
+
+
+ estate.property.offer.view.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.offer.action
+ estate.property.offer
+ list,form
+ [('property_type_id', '=', active_id)]
+
+
diff --git a/estate/views/estate_property_tag_views.xml b/estate/views/estate_property_tag_views.xml
new file mode 100644
index 00000000000..bb4c70b87c2
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,26 @@
+
+
+
+ estate.property.tag.view.form
+ estate.property.tag
+
+
+
+
+
+
+
+ estate.property.tag.action
+ 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..635e30f5623
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,62 @@
+
+
+
+ estate.property.type.view.form
+ estate.property.type
+
+
+
+
+
+
+
+ estate.property.type.view.list
+ estate.property.type
+
+
+
+
+
+
+
+
+
+ estate.property.type.action
+ 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..a29cf154fc9
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,156 @@
+
+
+
+ estate.property.action
+ estate.property
+ list,form,kanban
+ {'search_default_available': True}
+
+
+
+ estate.property.view.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.view.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.view.form
+ estate.property
+
+
+
+
+
+
+
+ estate.property.view.kanban
+ estate.property
+
+
+
+
+
+
+
+
+
+
+ Expected Price:
+
+ Best Offer:
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/res_users_views.xml b/estate/views/res_users_views.xml
new file mode 100644
index 00000000000..d649a6cc5ce
--- /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..3d6e9c860df
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,13 @@
+{
+ 'name': 'estate_account',
+ 'version': 1.0,
+ 'author': 'Odoo',
+ 'license': 'LGPL-3',
+ 'depends': [
+ 'account',
+ 'estate',
+ ],
+ 'installable': True,
+ '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..7bed38a6408
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,27 @@
+from odoo import Command, models
+
+
+class EstateProperty(models.Model):
+ _inherit = "estate.property"
+
+ def action_sold_property(self):
+ for record in self:
+ self.env['account.move'].create(
+ {
+ 'partner_id': int(record.buyer_id),
+ 'move_type': 'out_invoice',
+ 'invoice_line_ids': [
+ Command.create({
+ 'name': f"{record.name} (6% down payment)",
+ 'quantity': 1,
+ 'price_unit': 0.06 * record.selling_price
+ }),
+ Command.create({
+ 'name': 'Admin fees',
+ 'quantity': 1,
+ 'price_unit': 100.00
+ })
+ ],
+ }
+ )
+ return super().action_sold_property()