- hello world
+
+
+
+
diff --git a/awesome_owl/static/src/todolist/todo.js b/awesome_owl/static/src/todolist/todo.js
new file mode 100644
index 0000000000..f6173dfd0d
--- /dev/null
+++ b/awesome_owl/static/src/todolist/todo.js
@@ -0,0 +1,24 @@
+import { Component, onMounted, useRef } from "@odoo/owl";
+
+export class Todo extends Component {
+ static template = "awesome_owl.todo";
+ static props = {
+ todo: {
+ id: Number,
+ description: String,
+ isCompleted: Boolean,
+ },
+ toggleState: Function,
+ };
+ setup() {
+ this.stateRef = useRef("todo_item_ref");
+ onMounted(() => {
+ if (this.props.todo.isCompleted) {
+ this.stateRef.el.checked = true;
+ }
+ });
+ }
+ toggleState() {
+ this.props.toggleState(this.props.todo.id);
+ }
+}
diff --git a/awesome_owl/static/src/todolist/todo.xml b/awesome_owl/static/src/todolist/todo.xml
new file mode 100644
index 0000000000..f0328d1ae1
--- /dev/null
+++ b/awesome_owl/static/src/todolist/todo.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/todolist/todolist.js b/awesome_owl/static/src/todolist/todolist.js
new file mode 100644
index 0000000000..dba0b5e940
--- /dev/null
+++ b/awesome_owl/static/src/todolist/todolist.js
@@ -0,0 +1,44 @@
+import { Component, useState, useRef, onMounted } from "@odoo/owl";
+import { Todo } from "./todo";
+
+export class TodoList extends Component {
+ static template = "awesome_owl.todolist";
+ static props = {};
+ static components = { Todo };
+
+ setup() {
+ this.state = useState({
+ todos: [
+ { id: 0, description: "buy milk", isCompleted: false },
+ { id: 1, description: "drink water", isCompleted: false },
+ { id: 2, description: "play soccer", isCompleted: true },
+ ],
+ });
+ this.todoInputRef = useRef("todo_input");
+ onMounted(() => {
+ this.todoInputRef.el.focus();
+ });
+ }
+
+ addTodo(event) {
+ if (event.keyCode == 13 && event.target.value != "") {
+ this.state.todos.push({
+ id: this.state.todos.length,
+ description: event.target.value,
+ isCompleted: false,
+ });
+ event.target.value = "";
+ console.log(this.state.todos);
+ }
+ }
+
+ toggleState(id) {
+ const index = this.state.todos.findIndex((todo) => todo.id == id);
+ if (index != -1) {
+ this.state.todos[index] = {
+ ...this.state.todos[index],
+ isCompleted: !this.state.todos[index].isCompleted,
+ };
+ }
+ }
+}
diff --git a/awesome_owl/static/src/todolist/todolist.xml b/awesome_owl/static/src/todolist/todolist.xml
new file mode 100644
index 0000000000..923a1359c9
--- /dev/null
+++ b/awesome_owl/static/src/todolist/todolist.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
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..47ab9fb5ea
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,19 @@
+{
+ "name": "Real Estate",
+ "author": "Odoo",
+ "website": "https://www.odoo.com/page/realestate",
+ "version": "0.1",
+ "application": True,
+ "installable": True,
+ "depends": ["base"],
+ "data": [
+ "security/ir.model.access.csv",
+ "views/estate_property_type_views.xml",
+ "views/estate_property_tag_views.xml",
+ "views/estate_property_offer_views.xml",
+ "views/estate_property_views.xml",
+ "views/estate_menus.xml",
+ "views/estate_res_user_views.xml",
+ ],
+ "license": "LGPL-3",
+}
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 0000000000..ff7189569b
--- /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 estate_res_user
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 0000000000..6799e0ea11
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,128 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+from odoo.tools.float_utils import float_is_zero, float_compare
+
+
+class EstateProperty(models.Model):
+ _name = "estate.property"
+ _description = "Estate Property"
+ _order = "id desc"
+
+ name = fields.Char(required=True)
+ description = fields.Text()
+ postcode = fields.Char()
+ date_availability = fields.Date(
+ copy=False,
+ default=lambda x: fields.Datetime.add(fields.Datetime.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()
+ facades = fields.Integer()
+ garage = fields.Boolean()
+ garden = fields.Boolean()
+ garden_area = fields.Integer()
+ garden_orientation = fields.Selection(
+ string="Garden Orientation",
+ selection=[
+ ("north", "North"),
+ ("south", "South"),
+ ("east", "East"),
+ ("west", "West"),
+ ],
+ )
+ active = fields.Boolean(default=True)
+ state = fields.Selection(
+ string="State",
+ selection=[
+ ("new", "New"),
+ ("offer_received", "Offer Received"),
+ ("offer_accepted", "Offer Accepted"),
+ ("sold", "Sold"),
+ ("canceled", "Canceled"),
+ ],
+ default="new",
+ copy=False,
+ )
+ property_type_id = fields.Many2one("estate.property.type", string="Property Type")
+ buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False)
+ salesperson_id = fields.Many2one(
+ "res.users", string="Salesperson", default=lambda self: self.env.user
+ )
+ tags_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_area")
+ best_price = fields.Float(compute="_compute_best_price")
+
+ _sql_constraints = [
+ (
+ "check_positive_expected_price",
+ "CHECK(expected_price>0)",
+ "The expected price should be positive.",
+ ),
+ (
+ "check_positive_selling_price",
+ "CHECK(selling_price>0)",
+ "The selling price should be positive.",
+ ),
+ ]
+
+ @api.depends("garden_area", "living_area")
+ def _compute_total_area(self):
+ for record in self:
+ record.total_area = record.garden_area + record.living_area
+
+ @api.depends("offer_ids.price")
+ def _compute_best_price(self):
+ for record in self:
+ prices = record.offer_ids.mapped("price")
+ record.best_price = max(prices, default=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 = False
+
+ def action_sold(self):
+ print("I am in property")
+ self.ensure_one()
+ if self.state != "canceled":
+ self.state = "sold"
+ else:
+ raise UserError("Canceled properties can't be sold")
+ return True
+
+ def action_cancel(self):
+ for record in self:
+ if record.state != "sold":
+ record.state = "canceled"
+ else:
+ raise UserError("Sold properties can't be sold")
+ return True
+
+ @api.constrains("selling_price", "expected_price")
+ def _check_selling(self):
+ for record in self:
+ if (
+ not float_is_zero(record.selling_price, precision_digits=3)
+ and float_compare(
+ record.selling_price,
+ record.expected_price * 0.9,
+ precision_digits=3,
+ )
+ < 0
+ ):
+ raise UserError(
+ "The selling price cannot be lower than 90% of the expected price"
+ )
+
+ @api.ondelete(at_uninstall=False)
+ def _unlink_if_not_new_or_cancelled(self):
+ for record in self:
+ if record.state not in ("new", "canceled"):
+ raise UserError("Only new or canceled properties can be deleted")
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 0000000000..c6bcf2fb7f
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,73 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+
+
+class EstatePropertyOffer(models.Model):
+ _name = "estate.property.offer"
+ _description = "Property Offer"
+ _order = "price asc"
+
+ price = fields.Float()
+ status = fields.Selection(
+ string="Type",
+ selection=[("accepted", "Accepted"), ("refused", "Refused")],
+ copy=False,
+ )
+ partner_id = fields.Many2one("res.partner", required=True)
+ property_id = fields.Many2one("estate.property", required=True)
+ validity = fields.Integer(default=7)
+ date_deadline = fields.Date(
+ compute="_compute_date_deadline", inverse="_inverse_date_deadline"
+ )
+ property_type_id = fields.Many2one(
+ "estate.property.type",
+ store=True,
+ string="Property Type",
+ related="property_id.property_type_id",
+ )
+
+ _sql_constraints = [
+ (
+ "check_positive_price",
+ "CHECK(price>0)",
+ "The offer price should be positive.",
+ ),
+ ]
+
+ @api.depends("validity", "create_date")
+ def _compute_date_deadline(self):
+ for record in self:
+ if not record.create_date:
+ today = fields.Datetime.today()
+ record.date_deadline = fields.Datetime.add(today, days=record.validity)
+ else:
+ record.date_deadline = fields.Datetime.add(
+ record.create_date, 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(self):
+ self.ensure_one()
+ self.status = "accepted"
+ self.property_id.selling_price = self.price
+ self.property_id.buyer_id = self.partner_id
+ self.property_id.state = "offer_accepted"
+ return True
+
+ def action_refuse(self):
+ self.ensure_one()
+ self.status = "refused"
+ return True
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ for vals in vals_list:
+ property = self.env["estate.property"].browse(vals["property_id"])
+ property.state = "offer_received"
+ for offer in property.offer_ids:
+ if offer.price > vals["price"]:
+ raise UserError("The offer must be higher than the existing offer")
+ 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 0000000000..f1fc9bd7cb
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,13 @@
+from odoo import fields, models
+
+
+class EstatePropertyTag(models.Model):
+ _name = "estate.property.tag"
+ _description = "Property Tags"
+ _order = "name"
+
+ name = fields.Char()
+ color = fields.Integer()
+ _sql_constraints = [
+ ("unique_name", "UNIQUE(name)", "The property tag must be unique.")
+ ]
diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py
new file mode 100644
index 0000000000..4c9e31e02e
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,25 @@
+from odoo import fields, models, api
+
+
+class EstatePropertyType(models.Model):
+ _name = "estate.property.type"
+ _description = "Estate Property Type"
+ _order = "sequence, name"
+
+ name = fields.Char(required=True)
+ property_ids = fields.One2many(
+ "estate.property", "property_type_id", string="Property"
+ )
+ sequence = fields.Integer("Sequence")
+ offer_ids = fields.One2many(
+ "estate.property.offer", inverse_name="property_type_id"
+ )
+ offer_count = fields.Integer(compute="_compute_offer_count")
+ _sql_constraints = [
+ ("unique_name", "UNIQUE(name)", "The property type 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/estate_res_user.py b/estate/models/estate_res_user.py
new file mode 100644
index 0000000000..107f595708
--- /dev/null
+++ b/estate/models/estate_res_user.py
@@ -0,0 +1,8 @@
+from odoo import fields, models
+
+
+class User(models.Model):
+ _inherit = "res.users"
+
+ property_ids = fields.One2many("estate.property", inverse_name="salesperson_id")
+ domain = ["|", ("state", "=", "new"), ("state", "=", "offer_received")]
diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv
new file mode 100644
index 0000000000..49bca99cac
--- /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 0000000000..08b66bfac9
--- /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 0000000000..34044fbe10
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,42 @@
+
+
+
+ Property Offers
+ estate.property.offer
+ list,form
+ [('property_type_id', '=', active_id)]
+
+
+
+ estate.property.offer.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.offer.form
+ 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 0000000000..e95ce3db2a
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,32 @@
+
+
+
+ Tags
+ estate.property.tag
+ list,form
+
+
+
+ estate.property.tag.list
+ estate.property.tag
+
+
+
+
+
+
+
+
+ estate.property.form
+ 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 0000000000..2e9bb7ca6c
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,51 @@
+
+
+
+ Property Types
+ estate.property.type
+ list,form
+
+
+
+ estate.property.type.list
+ estate.property.type
+
+
+
+
+
+
+
+
+
+ estate.property.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 0000000000..5c36710374
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,128 @@
+
+
+
+ Properties
+ estate.property
+ list,form,kanban
+ {'search_default_available':True}
+
+
+
+ estate.property.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.form
+ estate.property
+
+
+
+
+
+
+ estate.property.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.kanban
+ estate.property
+
+
+
+
+
+
+
+ Expected Price:
+
+
+
+ Best Price:
+
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_res_user_views.xml b/estate/views/estate_res_user_views.xml
new file mode 100644
index 0000000000..8b2cc83490
--- /dev/null
+++ b/estate/views/estate_res_user_views.xml
@@ -0,0 +1,15 @@
+
+
+
+ estate.res.user.form.inherit
+ res.users
+
+
+
+
+
+
+
+
+
+
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..50d5938a47
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,13 @@
+{
+ "name": "Real Estate Accounting",
+ "author": "Odoo",
+ "website": "https://www.odoo.com/page/realestate",
+ "version": "0.1",
+ "application": True,
+ "installable": True,
+ "depends": ["estate", "account"],
+ "data": [
+ "security/ir.model.access.csv",
+ ],
+ "license": "LGPL-3",
+}
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..ff91cf7e02
--- /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_sold(self):
+ print("I am here")
+ self.ensure_one()
+ self.env["account.move"].create(
+ {
+ "partner_id": self.buyer_id,
+ "move_type": "out_invoice",
+ "invoice_line_ids": [
+ Command.create(
+ {
+ "name": self.name,
+ "quantity": 1,
+ "price_unit": 0.06 * self.selling_price,
+ }
+ ),
+ Command.create(
+ {
+ "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 0000000000..85de405deb
--- /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
+estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1