diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js
new file mode 100644
index 00000000000..e3840ba468b
--- /dev/null
+++ b/awesome_owl/static/src/card/card.js
@@ -0,0 +1,23 @@
+import { Component, useState } from "@odoo/owl";
+
+export class Card extends Component {
+ static template = "awesome_owl.Card";
+ static props = {
+ title: {type: String},
+ slots: {
+ type: Object,
+ shape: {
+ default: true,
+ },
+ },
+ };
+
+ setup() {
+ this.state = useState({open: true});
+ }
+
+ toggleOpen() {
+ this.state.open = ! this.state.open
+ }
+}
+
diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml
new file mode 100644
index 00000000000..ad54834cce7
--- /dev/null
+++ b/awesome_owl/static/src/card/card.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js
new file mode 100644
index 00000000000..614b9ab0ca0
--- /dev/null
+++ b/awesome_owl/static/src/counter/counter.js
@@ -0,0 +1,15 @@
+import { Component, useState } from "@odoo/owl";
+
+export class Counter extends Component {
+ static template = "awesome_owl.Counter";
+ static props = {onChange: {type: Function, optional: true}};
+
+ state = useState({ value: 0 });
+
+ increment() {
+ this.state.value++;
+ 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..603b0bf96a7
--- /dev/null
+++ b/awesome_owl/static/src/counter/counter.xml
@@ -0,0 +1,10 @@
+
+
+
+ Counter:
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js
index 4ac769b0aa5..1d61b7adf0c 100644
--- a/awesome_owl/static/src/playground.js
+++ b/awesome_owl/static/src/playground.js
@@ -1,5 +1,21 @@
-import { Component } from "@odoo/owl";
+import { Component, markup, useState } from "@odoo/owl";
+import { Counter } from "./counter/counter";
+import { Card } from "./card/card";
+import { TodoList } from "./todo_list/todo_list";
export class Playground extends Component {
- static template = "awesome_owl.playground";
+ static template = "awesome_owl.Playground";
+ static components = { Counter, Card, TodoList };
+ static props = [];
+
+ state = useState({ sum: 2, value: 1 });
+ content = markup('
some content
');
+
+ increment() {
+ this.state.value++;
+ }
+
+ incrementSum() {
+ this.state.sum++;
+ }
}
diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml
index 4fb905d59f9..5b7270a3430 100644
--- a/awesome_owl/static/src/playground.xml
+++ b/awesome_owl/static/src/playground.xml
@@ -1,10 +1,14 @@
-
+
+
+
+
+
+
+
+
+
+
-
-
- 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..fe1feda3bc7
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_item.js
@@ -0,0 +1,25 @@
+import { Component, useState } from "@odoo/owl";
+
+export class TodoItem extends Component {
+ static template = "awesome_owl.TodoItem";
+ static props = {
+ todo: {
+ type: Object,
+ shape: {
+ id: { type: Number },
+ description: { type: String },
+ isCompleted: { type: Boolean },
+ },
+ },
+ toggleState: {type: Function},
+ removeTodo: {type: Function},
+ };
+
+ onChange() {
+ this.props.toggleState(this.props.todo.id);
+ }
+
+ onDelete() {
+ 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..03d97beac30
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_item.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+ .
+
+
+
+
+
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..5f1e1b62a12
--- /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 { useAutoFocusInput } from "../utils"
+
+export class TodoList extends Component {
+ static template = "awesome_owl.TodoList";
+ static components = { TodoItem };
+ static props = [];
+
+
+ setup() {
+ this.todo_id = useState({ id: 0 });
+ this.todos = useState([]);
+ useAutoFocusInput("input");
+ }
+
+ addTodo(ev) {
+ if (ev.keyCode !== 13 || ev.target.value.length === 0) {
+ return
+ }
+ this.todos.push({ id: this.todo_id.id++, description: ev.target.value, isCompleted: false });
+ ev.target.value = "";
+ }
+
+ toggleTodo(todoId) {
+ const todo = this.todos.find(e => e.id === todoId);
+ if (todo) {
+ todo.isCompleted = !todo.isCompleted;
+ }
+ }
+ removeTodo(todoId) {
+ const todo_index = this.todos.findIndex((elem) => elem.id === todoId);
+ if (todo_index >= 0) {
+ this.todos.splice(todo_index, 1);
+ } else {
+ console.log("non")
+ }
+ }
+}
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..4819ff8f10d
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/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..94f2181ed40
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,10 @@
+import { useRef, onMounted } from "@odoo/owl";
+
+export function useAutoFocusInput(refName) {
+ const inputRef = useRef(refName);
+ onMounted(() => {
+ if (inputRef.el) {
+ inputRef.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..ef2e8b8ba19
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,25 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+
+{
+ 'name': 'estate',
+ 'category': 'Tutorials',
+ 'depends': [
+ 'base',
+ ],
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'views/estate_property_offer_views.xml',
+ 'views/estate_property_tag_views.xml',
+ 'views/estate_property_type_views.xml',
+ 'views/estate_property_views.xml',
+ 'views/res_users_views.xml',
+ 'views/estate_menus.xml',
+ ],
+ 'application': True,
+ 'installable': True,
+ 'auto_install': 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..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..59ebfecac26
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,94 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+from odoo.tools.float_utils import float_compare, float_is_zero
+
+
+class EstateProperty(models.Model):
+ _name = 'estate.property'
+ _description = "estate property"
+
+ name = fields.Char(required=True, string="Title")
+ description = fields.Text()
+ postcode = fields.Char()
+ date_availability = fields.Date(default=lambda self: fields.Date.add(fields.Date.today(), months=3), copy=False)
+ 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()
+ garden_orientation = fields.Selection([('north', "North"), ('south', "South"), ('east', "East"), ('west', "West")])
+ total_area = fields.Integer(compute='_compute_total_area')
+ property_type_id = fields.Many2one(comodel_name='estate.property.type', string="House Type")
+ buyer_id = fields.Many2one(comodel_name='res.partner', string="Buyer", copy=False)
+ seller_id = fields.Many2one(comodel_name='res.users', string="Seller", default=lambda self: self.env.user)
+ tag_ids = fields.Many2many(comodel_name='estate.property.tag', string="Tags")
+ offer_ids = fields.One2many(comodel_name='estate.property.offer', inverse_name='property_id', string="")
+ best_offer = fields.Float(compute='_compute_best_offer')
+ active = fields.Boolean(string="Active", default=True)
+ state = fields.Selection(
+ string="Status",
+ selection=[
+ ('new', "New"),
+ ('offer_received', "Offer received"),
+ ('offer_accepted', "Offer accepted"),
+ ('sold', "Sold"),
+ ('cancelled', "Cancelled"),
+ ],
+ required=True,
+ default='new',
+ copy=False,
+ )
+
+ _check_expected_price = models.Constraint('CHECK(expected_price > 0)', "The expected price must be stricly positive")
+
+ _check_selling_price = models.Constraint('CHECK(selling_price > 0)', "The selling price must be stricly positive")
+
+ @api.depends('living_area', 'garden_area')
+ def _compute_total_area(self):
+ for record_property in self:
+ record_property.total_area = record_property.living_area + record_property.garden_area
+
+ @api.depends('offer_ids.price')
+ def _compute_best_offer(self):
+ for record_property in self:
+ record_property.best_offer = max(record_property.offer_ids.mapped('price'), 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 = ''
+
+ @api.constrains('selling_price', 'expected_price')
+ def _check_selling_expected_price(self):
+ for record_property in self:
+ if not float_is_zero(record_property.selling_price, precision_digits=2) and (
+ float_compare(record_property.expected_price * 0.9, record_property.selling_price, precision_digits=2) > 0):
+ raise UserError(self.env._("The selling price must be a least 90% of the expected price!"))
+
+ def action_cancel(self):
+ for record_property in self:
+ if record_property.state == 'sold':
+ raise UserError(record_property.env._("Sold properties cannot be cancelled"))
+ record_property.state = 'cancelled'
+ return True
+
+ def action_sold(self):
+ for record_property in self:
+ if record_property.state == 'cancelled':
+ raise UserError(record_property.env_("Canceled properties cannot be sold"))
+ record_property.state = 'sold'
+ return True
+
+ @api.ondelete(at_uninstall=False)
+ def _ondelete(self):
+ if any((property_id.state not in ('new', 'cancelled')) for property_id in self):
+ raise UserError(self.env._("You can only delete property in the state New or Cancelled"))
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..60c888c3fcd
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,58 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+from odoo.tools.float_utils import float_compare
+
+
+class EstatePropertyOffer(models.Model):
+ _name = 'estate.property.offer'
+ _description = "Property Offer"
+ _order = "price desc"
+
+ price = fields.Float(string="Price")
+ status = fields.Selection([('accepted', "Accepted"), ('refused', "Refused")], copy=False)
+ partner_id = fields.Many2one('res.partner', required=True)
+ property_id = fields.Many2one('estate.property', required=True, ondelete='cascade')
+ validity = fields.Integer(default=7)
+ date_deadline = fields.Date(compute='_compute_date_deadline', inverse='_inverse_date_deadline')
+ property_type_id = fields.Many2one(related='property_id.property_type_id')
+
+ _check_offer_price = models.Constraint('CHECK(price > 0)', "The offer price must be stricly positive")
+
+ @api.depends('create_date', 'validity')
+ def _compute_date_deadline(self):
+ for record in self:
+ starting_date = record.create_date.date() if record.create_date else fields.Date.today()
+ record.date_deadline = fields.Date.add(starting_date, days=record.validity)
+
+ @api.depends('create_date', '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):
+ for record in self:
+ if record.property_id.offer_ids.filtered(lambda offer: offer.status == 'accepted'):
+ raise UserError(record.env_("Another offer has already been accepted."))
+ record.status = 'accepted'
+ record.property_id.buyer_id = record.partner_id
+ record.property_id.selling_price = record.price
+ record.property_id.state = 'offer_accepted'
+ return True
+
+ def action_refuse_offer(self):
+ for record in self:
+ record.status = 'refused'
+ return True
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ for vals in vals_list:
+ estate_property = self.env['estate.property'].browse(vals['property_id'])
+ if float_compare(vals['price'], estate_property.best_offer, precision_digits=2) < 0:
+ raise UserError(self.env._("The price must be higher than %s", estate_property.best_offer))
+
+ estate_property.state = 'offer_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..b2d55d36b64
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,16 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models
+
+
+class EstatePropertyTag(models.Model):
+ _name = 'estate.property.tag'
+ _description = "Property Tag"
+ _order = "name"
+
+ name = fields.Char(required=True, string="Property Tag")
+ color = fields.Integer()
+
+ _unique_tag = models.Constraint(
+ "UNIQUE(name)", "The 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 00000000000..f343761a942
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,20 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models
+
+
+class EstatePropertyType(models.Model):
+ _name = 'estate.property.type'
+ _description = "Property Type"
+ _order = "sequence, name"
+
+ name = fields.Char(required=True, string="Property Type")
+ 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')
+
+ @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..df1fbaf3d10
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,15 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models
+
+
+class ResUsers(models.Model):
+ _inherit = ['res.users']
+ _name = 'res.users'
+
+ property_ids = fields.One2many(
+ 'estate.property',
+ 'seller_id',
+ string="Available Properties",
+ 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..68c221e0dec
--- /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_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
diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml
new file mode 100644
index 00000000000..f7e76061e35
--- /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..b7e102cd0a6
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,23 @@
+
+
+
+ estate.property.offer.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+ Property 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..cd9d5399a4a
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,18 @@
+
+
+
+ Property Tag
+ estate.property.tag
+ list,form
+
+
+ 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..963e55b7005
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,48 @@
+
+
+
+ Property Types
+ estate.property.type
+ list,form
+
+
+ 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..3cb1634c6bd
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,143 @@
+
+
+
+ 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 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..ad4b957b115
--- /dev/null
+++ b/estate/views/res_users_views.xml
@@ -0,0 +1,16 @@
+
+
+
+ res.users.view.form.inherit.property
+ 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..d60b5bc1182
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,18 @@
+
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+
+{
+ 'name': 'estate_account',
+ 'category': 'Tutorials',
+ 'depends': [
+ 'base',
+ '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..c0e34348e91
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,33 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import Command, models
+
+
+class EstateProperty(models.Model):
+ _inherit = ['estate.property']
+ _name = 'estate.property'
+
+ def action_sold(self):
+ self.env['account.move'].create(
+ {
+ 'partner_id': self.buyer_id.id,
+ 'move_type': 'out_invoice',
+ 'invoice_line_ids': [
+ Command.create(
+ {
+ 'name': self.env._("6% of the selling price"),
+ 'quantity': 1,
+ 'price_unit': self.selling_price * 0.06,
+ }
+ ),
+ Command.create(
+ {
+ 'name': self.env._("100 fees"),
+ 'quantity': 1,
+ 'price_unit': 100,
+ }
+ ),
+ ],
+ }
+ )
+ return super().action_sold()