diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js
new file mode 100644
index 00000000000..a83b3baba2a
--- /dev/null
+++ b/awesome_owl/static/src/card/card.js
@@ -0,0 +1,22 @@
+import { Component, useState } from "@odoo/owl";
+
+export class Card extends Component {
+ static template = "awesome_owl.card";
+ static props = {
+ title: String,
+ slots: {
+ type: Object,
+ shape: {
+ default: true
+ },
+ }
+ }
+
+ setup() {
+ this.state = useState({ isOpen: true });
+ }
+
+ toggleContent() {
+ this.state.isOpen = !this.state.isOpen;
+ }
+}
diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml
new file mode 100644
index 00000000000..58aab036fad
--- /dev/null
+++ b/awesome_owl/static/src/card/card.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js
new file mode 100644
index 00000000000..e72295a5822
--- /dev/null
+++ b/awesome_owl/static/src/counter/counter.js
@@ -0,0 +1,20 @@
+import { Component, useState } from "@odoo/owl";
+
+export class Counter extends Component {
+ static template = "awesome_owl.counter";
+ static props = {
+ onChange: { type: Function, optional: true },
+ }
+
+ setup() {
+ this.state = useState({ counter: 0 });
+ }
+
+ increment() {
+ this.state.counter++;
+ if(this.props.onChange) {
+ this.props.onChange();
+ }
+ }
+
+}
diff --git a/awesome_owl/static/src/counter/counter.xml b/awesome_owl/static/src/counter/counter.xml
new file mode 100644
index 00000000000..a9bda35cc0d
--- /dev/null
+++ b/awesome_owl/static/src/counter/counter.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+ Counter:
+
+
+
+
+
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js
index 4ac769b0aa5..011179f2d6d 100644
--- a/awesome_owl/static/src/playground.js
+++ b/awesome_owl/static/src/playground.js
@@ -1,5 +1,19 @@
-import { Component } from "@odoo/owl";
+import { Component, markup, useState} from "@odoo/owl";
+import { Card } from "./card/card.js";
+import { Counter } from "./counter/counter.js";
+import { TodoList } from "./todo/todo_list.js";
export class Playground extends Component {
static template = "awesome_owl.playground";
+ static components = { Card, Counter, TodoList };
+
+ setup() {
+ this.state = useState({ sum: 0 });
+ this.content1 = "
some text 1
";
+ this.content2 = markup("some text 2
");
+ }
+
+ incrementSum() {
+ this.state.sum++;
+ }
}
diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml
index 4fb905d59f9..bac30ab533c 100644
--- a/awesome_owl/static/src/playground.xml
+++ b/awesome_owl/static/src/playground.xml
@@ -5,6 +5,30 @@
hello world
+
+
+
+ The sum is:
+
+
+
+ Content of card 1
+
+
+ Content of card 2
+
+
+
+
+
+
+
+ Content of card 3
+
+
+
+
+
diff --git a/awesome_owl/static/src/todo/todo_item.js b/awesome_owl/static/src/todo/todo_item.js
new file mode 100644
index 00000000000..5c3d9d36da5
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_item.js
@@ -0,0 +1,25 @@
+import { Component } from "@odoo/owl";
+
+export class TodoItem extends Component {
+ static template = "awesome_owl.todo_item";
+ 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/todo_item.xml b/awesome_owl/static/src/todo/todo_item.xml
new file mode 100644
index 00000000000..237abca5b1e
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_item.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/todo/todo_list.js b/awesome_owl/static/src/todo/todo_list.js
new file mode 100644
index 00000000000..8c5589bdd20
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_list.js
@@ -0,0 +1,44 @@
+import { Component, useState, useRef, onMounted } from "@odoo/owl";
+import { TodoItem } from "./todo_item";
+import { useAutofocus } from "../utils.js";
+
+export class TodoList extends Component {
+ static template = "awesome_owl.todo_list";
+ static components = { TodoItem };
+
+ setup() {
+ this.todos = useState([]);
+ this.nextId = 1;
+ useAutofocus("input");
+ }
+
+ addTodo(ev) {
+ if (ev.keyCode === 13) {
+ const input = ev.target;
+ const description = input.value.trim();
+
+ if (description) {
+ this.todos.push({
+ id: this.nextId++,
+ description: description,
+ isCompleted: false
+ });
+ input.value = "";
+ }
+ }
+ }
+
+ toggleState(todoId) {
+ const todo = this.todos.find(t => t.id === todoId);
+ if (todo) {
+ todo.isCompleted = !todo.isCompleted;
+ }
+ }
+
+ removeTodo(todoId) {
+ const index = this.todos.findIndex(t => t.id === todoId);
+ if (index !== -1) {
+ this.todos.splice(index, 1);
+ }
+ }
+}
diff --git a/awesome_owl/static/src/todo/todo_list.xml b/awesome_owl/static/src/todo/todo_list.xml
new file mode 100644
index 00000000000..8b434975eec
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_list.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js
new file mode 100644
index 00000000000..8cd786da6da
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,8 @@
+import { useRef, onMounted } from "@odoo/owl";
+
+export function useAutofocus(name) {
+ let ref = useRef(name);
+ onMounted(() => {
+ ref.el && 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..61dff35c57f
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,17 @@
+{
+ 'name': "Real Estate",
+ 'version': '1.0',
+ 'depends': ['base'],
+ 'data': [
+ 'security/ir.model.access.csv',
+ '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',
+ 'views/estate_menus.xml',
+ ],
+ 'application': True,
+ '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..fea9f441d6d
--- /dev/null
+++ b/estate/models/__init__.py
@@ -0,0 +1,5 @@
+from . import estate_property
+from . import estate_property_offer
+from . import estate_property_tag
+from . import estate_property_type
+from . import res_users
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 00000000000..b8de0f01617
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,165 @@
+from dateutil.relativedelta import relativedelta
+
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+from odoo.tools.float_utils import float_compare
+
+GARDEN_ORIENTATIONS = [
+ ('north', 'North'),
+ ('south', 'South'),
+ ('east', 'East'),
+ ('west', 'West'),
+]
+
+PROPERTY_STATUS = [
+ ('new', 'New'),
+ ('offer received', 'Offer Received'),
+ ('offer accepted', 'Offer Accepted'),
+ ('sold', 'Sold'),
+ ('cancelled', 'Cancelled'),
+]
+
+
+class EstateProperty(models.Model):
+ _name = "estate.property"
+ _description = "An estate property model"
+ _order = "id desc"
+
+ # === FIELDS ===#
+
+ name = fields.Char(
+ required=True)
+ description = fields.Text()
+ postcode = fields.Char()
+ date_availability = fields.Date(
+ copy=False,
+ default=lambda self: self._default_date_availability())
+ expected_price = fields.Float(
+ required=True)
+ selling_price = fields.Float(
+ copy=False,
+ readonly=True)
+ 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(
+ selection=GARDEN_ORIENTATIONS,
+ )
+ active = fields.Boolean(
+ default=True)
+ state = fields.Selection(
+ copy=False,
+ default='new',
+ required=True,
+ selection=PROPERTY_STATUS,
+ )
+ property_type_id = fields.Many2one(
+ "estate.property.type",
+ string='Property Type')
+ salesperson_id = fields.Many2one(
+ "res.users",
+ string="Salesperson",
+ 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")
+ total_area = fields.Float(
+ compute='_compute_total_area',
+ string='Total Area')
+ best_price = fields.Float(
+ compute='_compute_best_price',
+ string='Best Offer')
+
+ _check_expected_price = models.Constraint(
+ 'CHECK(expected_price > 0)',
+ 'The expected price must be strictly positive!',
+ )
+
+ _check_selling_price = models.Constraint(
+ 'CHECK(selling_price >= 0)',
+ 'The selling price must be positive!',
+ )
+
+ # === COMPUTE METHODS ===#
+
+ # Default method to set date_availability to three months from today
+ def _default_date_availability(self):
+ return fields.Datetime.today() + relativedelta(months=3)
+
+ @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.mapped('offer_ids.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 = False
+
+ # === ACTION METHODS ===#
+
+ def action_set_sold(self):
+ for record in self:
+ if record.state == 'cancelled':
+ error_message = "Cancelled properties cannot be sold."
+ raise UserError(error_message)
+ record.state = 'sold'
+ return True
+
+ def action_set_canceled(self):
+ for record in self:
+ if record.state == 'sold':
+ error_message = "Sold properties cannot be cancelled."
+ raise UserError(error_message)
+ record.state = 'cancelled'
+ return True
+
+ # === CONSTRAINT METHODS ===#
+
+ @api.constrains('selling_price', 'expected_price')
+ def _check_selling_price(self):
+ for record in self:
+ if record.selling_price and record.expected_price:
+ if float_compare(record.selling_price,
+ record.expected_price * 0.9,
+ precision_rounding=0.01) < 0:
+ error_message = (
+ "The selling price must be at least 90% "
+ "of the expected price."
+ )
+ raise UserError(error_message)
+
+ # === CRUD OVERRIDES ===#
+
+ @api.ondelete(at_uninstall=False)
+ def _unlink_property(self):
+ for record in self:
+ if record.state not in ['new', 'cancelled']:
+ error_message = (
+ "Only properties in 'New' or 'Cancelled' state "
+ "can be deleted."
+ )
+ raise UserError(error_message)
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..c0e31b2f2df
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,101 @@
+from dateutil.relativedelta import relativedelta
+
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+
+
+OFFER_STATUS = [
+ ('accepted', 'Accepted'),
+ ('refused', 'Refused'),
+]
+
+
+class PropertyOffer(models.Model):
+ _name = "estate.property.offer"
+ _description = "An estate property offer model"
+ _order = "price desc"
+
+ # === FIELDS ===#
+
+ price = fields.Float()
+ status = fields.Selection(
+ selection=OFFER_STATUS,
+ copy=False)
+ partner_id = fields.Many2one(
+ "res.partner",
+ string='Partner',
+ required=True)
+ property_id = fields.Many2one(
+ "estate.property",
+ string='Property',
+ required=True,
+ ondelete='cascade')
+ validity = fields.Integer(
+ default=7,
+ string='Validity (days)')
+ date_deadline = fields.Date(
+ compute='_compute_date_deadline',
+ inverse='_inverse_date_deadline',
+ string='Deadline')
+ property_type_id = fields.Many2one(
+ related="property_id.property_type_id",
+ store=True,
+ )
+
+ _check_price = models.Constraint(
+ 'CHECK(price > 0)',
+ 'The price must be strictly positive!',
+ )
+
+ # === COMPUTE METHODS ===#
+
+ @api.depends('validity', 'create_date')
+ def _compute_date_deadline(self):
+ for record in self:
+ if record.create_date:
+ record.date_deadline = record.create_date.date() + \
+ relativedelta(days=record.validity)
+ else:
+ record.date_deadline = fields.Datetime.today() + \
+ relativedelta(days=record.validity)
+
+ def _inverse_date_deadline(self):
+ for record in self:
+ if record.create_date and record.date_deadline:
+ delta = record.date_deadline - record.create_date.date()
+ record.validity = delta.days
+
+ # === ACTION METHODS ===#
+
+ def action_accept_offer(self):
+ for record in self:
+ record.status = 'accepted'
+ record.property_id.selling_price = record.price
+ record.property_id.buyer_id = record.partner_id
+ record.property_id.state = 'offer accepted'
+ return True
+
+ def action_reject_offer(self):
+ for record in self:
+ record.status = 'refused'
+ return True
+
+ # === CONSTRAINT METHODS ===#
+
+ @api.constrains('price')
+ def _check_price(self):
+ for record in self:
+ existing_offers = record.property_id.offer_ids.filtered(lambda o: o != record)
+ if existing_offers:
+ min_price = min(existing_offers.mapped('price'))
+ if record.price < min_price:
+ error_message = "The offer price can't be lower than existing offers!"
+ raise UserError(error_message)
+
+ # === CRUD OVERRIDES ===#
+
+ @api.model
+ def create(self, vals):
+ offer = super().create(vals)
+ offer.property_id.state = 'offer received'
+ return offer
diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py
new file mode 100644
index 00000000000..b0ddf7bb72b
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,18 @@
+from odoo import fields, models
+
+
+class PropertyTag(models.Model):
+ _name = "estate.property.tag"
+ _description = "An estate property tag model"
+ _order = "name asc"
+
+ # === FIELDS ===#
+
+ name = fields.Char(
+ required=True)
+ color = fields.Integer()
+
+ _check_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..ed9e0a9997e
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,38 @@
+from odoo import api, fields, models
+
+
+class PropertyType(models.Model):
+ _name = "estate.property.type"
+ _description = "An estate property type model"
+ _order = "name asc"
+
+ # === FIELDS ===#
+
+ name = fields.Char(
+ required=True)
+ property_ids = fields.One2many(
+ "estate.property",
+ "property_type_id")
+ sequence = fields.Integer(
+ 'Sequence',
+ default=1)
+ offer_ids = fields.One2many(
+ "estate.property.offer",
+ "property_type_id",
+ )
+ offer_count = fields.Integer(
+ compute='_compute_offer_count',
+ string="Offers",
+ )
+
+ _check_name = models.Constraint(
+ 'unique(name)',
+ 'The property type name must be unique!',
+ )
+
+ # === COMPUTE METHODS ===#
+
+ @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..32d6423e3d1
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,10 @@
+from odoo import fields, models
+
+
+class ResUsers(models.Model):
+ _inherit = "res.users"
+
+ property_ids = fields.One2many(
+ "estate.property",
+ "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 00000000000..404f43c06fe
--- /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,estate.property,model_estate_property,base.group_user,1,1,1,1
+access_estate_property_type,estate.property.type,model_estate_property_type,base.group_user,1,1,1,1
+access_estate_property_tag,estate.property.tag,model_estate_property_tag,base.group_user,1,1,1,1
+access_estate_property_offer,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..81d59c8d97c
--- /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..a0a65f218ae
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,43 @@
+
+
+
+
+ estate.property.offer.view.form
+ estate.property.offer
+
+
+
+
+
+
+ estate.property.offer.view.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Offers
+ 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..8fd1a1c3058
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ estate.property.tag.view.list
+ estate.property.tag
+
+
+
+
+
+
+
+
+ Property Tags
+ 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..3764e361a01
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,58 @@
+
+
+
+
+ estate.property.type.view.form
+ estate.property.type
+
+
+
+
+
+
+ estate.property.type.view.list
+ estate.property.type
+
+
+
+
+
+
+
+
+
+ Property Types
+ 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..7e206889b3d
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,135 @@
+
+
+
+
+ estate.property.view.kanban
+ estate.property
+
+
+
+
+
+
+
+
Expected Price:
+
+ Best Price:
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.view.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.view.form
+ estate.property
+
+
+
+
+
+
+ estate.property.view.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Properties
+ estate.property
+ list,form,kanban
+ {'search_default_available_properties': True}
+
+
diff --git a/estate/views/res_users_views.xml b/estate/views/res_users_views.xml
new file mode 100644
index 00000000000..4b58b67c734
--- /dev/null
+++ b/estate/views/res_users_views.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ res.users.view.form
+ 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..6b709923480
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,8 @@
+{
+ 'name': "Estate Account",
+ 'version': '1.0',
+ 'depends': ['estate', 'account'],
+ 'application': 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..a5f6c4a73ec
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,24 @@
+from odoo import Command, models
+
+
+class EstateProperty(models.Model):
+ _inherit = "estate.property"
+
+ # === ACTION METHODS === #
+
+ def action_set_sold(self):
+ self.env['account.move'].create({
+ 'partner_id': self.buyer_id.id,
+ 'move_type': 'out_invoice',
+ 'invoice_line_ids': [
+ Command.create({
+ 'name': self.name,
+ 'quantity': 1,
+ 'price_unit': self.selling_price * 0.06}),
+ Command.create({
+ 'name': 'Adminstration Fee',
+ 'quantity': 1,
+ 'price_unit': 100}),
+ ],
+ })
+ return super().action_set_sold()