diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js
new file mode 100644
index 00000000000..884e16f960f
--- /dev/null
+++ b/awesome_owl/static/src/card/card.js
@@ -0,0 +1,13 @@
+import { Component, useState } from '@odoo/owl';
+
+export class Card extends Component {
+ static template = 'awesome_owl.card';
+ static props = {
+ title: { type: String },
+ slots: { type: Object, optional: true },
+ };
+
+ setup() {
+ this.state = useState({ isOpen: true });
+ }
+}
diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml
new file mode 100644
index 00000000000..42b56f7ba26
--- /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..625bd79ce07
--- /dev/null
+++ b/awesome_owl/static/src/counter/counter.js
@@ -0,0 +1,19 @@
+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..de1d9c261f2
--- /dev/null
+++ b/awesome_owl/static/src/counter/counter.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/main.js b/awesome_owl/static/src/main.js
index 1aaea902b55..b78166ed913 100644
--- a/awesome_owl/static/src/main.js
+++ b/awesome_owl/static/src/main.js
@@ -4,7 +4,7 @@ import { Playground } from "./playground";
const config = {
dev: true,
- name: "Owl Tutorial"
+ name: "Owl Tutorial"
};
// Mount the Playground component when the document.body is ready
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js
index 4ac769b0aa5..8941d5babe4 100644
--- a/awesome_owl/static/src/playground.js
+++ b/awesome_owl/static/src/playground.js
@@ -1,5 +1,20 @@
-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/todo_list";
export class Playground extends Component {
static template = "awesome_owl.playground";
+ static components = { Counter, Card, TodoList };
+ static props = {};
+
+ html = markup('Some content');
+
+ setup() {
+ this.state = useState({ sum: 0 });
+ }
+
+ incrementSum() {
+ this.state.sum++;
+ }
}
diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml
index 4fb905d59f9..5c83e965dd4 100644
--- a/awesome_owl/static/src/playground.xml
+++ b/awesome_owl/static/src/playground.xml
@@ -1,10 +1,23 @@
-
+
-
- hello world
-
+
+
+
+
+
+
+
+
+
+
+ Content
+
+
+
+
+
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..08eb74cbaf5
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_item.js
@@ -0,0 +1,16 @@
+import { Component } from '@odoo/owl';
+
+export class TodoItem extends Component {
+ static template = 'awesome_owl.todo_item';
+ static props = {
+ todo: {
+ type: {
+ id: { type: Number },
+ description: { type: String },
+ isCompleted: { type: Boolean },
+ },
+ },
+ toggleState: { type: Function },
+ removeTodo: { type: Function },
+ };
+}
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..ef314dbd1de
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_item.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+ .
+
+
+
+
+
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..1c63cf6b9dd
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_list.js
@@ -0,0 +1,35 @@
+import { Component, useState } from '@odoo/owl';
+import { TodoItem } from './todo_item';
+import { useAutoFocus } from '../utils';
+
+export class TodoList extends Component {
+ static template = 'awesome_owl.todo_list';
+ static components = { TodoItem };
+ static props = {};
+
+ setup() {
+ this.todos = useState([]);
+
+ useAutoFocus('input');
+ }
+
+ addTodo(ev) {
+ if (ev.keyCode === 13 && ev.target.value) {
+ const lastTodo = this.todos.slice(-1)[0];
+ this.todos.push({
+ id: lastTodo === undefined ? 0 : lastTodo.id + 1,
+ description: ev.target.value,
+ isCompleted: false,
+ });
+
+ ev.target.value = '';
+ }
+ }
+
+ removeTodo(elemId) {
+ const index = this.todos.findIndex((elem) => elem.id === elemId);
+ if (index >= 0) {
+ 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..9c90f78ee81
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_list.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..44533c50f1b
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,10 @@
+import { useRef, onMounted } from '@odoo/owl';
+
+function useAutoFocus(refName) {
+ const inputRef = useRef(refName);
+ onMounted(() => {
+ inputRef.el.focus();
+ });
+}
+
+export { useAutoFocus };
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..e756c677c8f
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,20 @@
+{
+ 'name': "Estate",
+ 'description': """
+ Track real estate properties
+ """,
+ 'version': '1.0',
+ 'author': "Odoo S.A.",
+ 'license': "LGPL-3",
+ 'depends': ['base'],
+ 'application': True,
+ '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/estate_menus.xml',
+ 'views/res_users.xml',
+ ],
+}
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 00000000000..fcbdb6f43d3
--- /dev/null
+++ b/estate/models/__init__.py
@@ -0,0 +1,7 @@
+from . import (
+ estate_property,
+ estate_property_type,
+ estate_property_tag,
+ estate_property_offer,
+ res_users,
+)
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 00000000000..b91b41485a0
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,126 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError, ValidationError
+from odoo.tools import float_compare
+
+
+class EstateProperty(models.Model):
+ _name = 'estate.property'
+ _description = 'Property'
+ _order = 'id desc'
+
+ name = fields.Char('Title', required=True)
+ description = fields.Text('Description')
+ postcode = fields.Char('Postcode')
+ date_availability = fields.Date(
+ 'Available From',
+ copy=False,
+ default=fields.Date.add(fields.Date.today(), months=+3),
+ )
+ expected_price = fields.Float('Expected Price', required=True)
+ selling_price = fields.Float('Selling Price', readonly=True, copy=False)
+ bedrooms = fields.Integer('Bedrooms', default=2)
+ living_area = fields.Integer('Living Area (sqm)')
+ facades = fields.Integer('Facades')
+ garage = fields.Boolean('Garage')
+ garden = fields.Boolean('Garden')
+ garden_area = fields.Integer('Garden Area (sqm)')
+ garden_orientation = fields.Selection(
+ string='Garden Orientation',
+ selection=[
+ ('north', 'North'),
+ ('south', 'South'),
+ ('east', 'East'),
+ ('west', 'West'),
+ ],
+ default='north',
+ )
+ active = fields.Boolean('Active', default=True)
+ state = fields.Selection(
+ string='State',
+ selection=[
+ ('new', 'New'),
+ ('offer_received', 'Offer Received'),
+ ('offer_accepted', 'Offer Accepted'),
+ ('sold', 'Sold'),
+ ('canceled', 'Canceled'),
+ ],
+ required=True,
+ copy=False,
+ default='new',
+ )
+ property_type_id = fields.Many2one('estate.property.type', string='Property Types')
+ property_tag_ids = fields.Many2many('estate.property.tag', string='Property Tags')
+ buyer_id = fields.Many2one('res.partner', string='Buyer', copy=False)
+ salesperson_id = fields.Many2one(
+ 'res.users', string='Salesperson', default=lambda self: self.env.user
+ )
+ offer_ids = fields.One2many(
+ 'estate.property.offer', 'property_id', string='Property Offers'
+ )
+ total_area = fields.Integer('Total Area (sqm)', compute='_compute_total_area')
+ best_price = fields.Float('Best Offer', compute='_compute_best_price')
+
+ _check_expected_price = models.Constraint(
+ 'CHECK(expected_price > 0)', 'The expected price must be strictly positive.'
+ )
+
+ @api.depends('garden_area', 'living_area')
+ def _compute_total_area(self):
+ for property in self:
+ property.total_area = property.garden_area + property.living_area
+
+ @api.depends('offer_ids.price')
+ def _compute_best_price(self):
+ for property in self:
+ property.best_price = max(property.offer_ids.mapped('price'), default=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
+
+ @api.constrains('selling_price', 'expected_price')
+ def _check_selling_price(self):
+ for property in self:
+ if property.state != 'offer_accepted':
+ continue
+
+ if (
+ property.state == 'offer_accepted'
+ and float_compare(property.selling_price, 0, 2) == -1
+ ):
+ raise ValidationError('The selling price must be positive.')
+
+ if (
+ float_compare(property.selling_price, property.expected_price * 0.9, 2)
+ == -1
+ ):
+ raise ValidationError(
+ 'Selling cannot be less than 90% of the expected price.'
+ )
+
+ @api.ondelete(at_uninstall=False)
+ def delete(self):
+ for property in self:
+ if property.state not in ('new', 'canceled'):
+ raise UserError(
+ 'Only properties in New or Canceled state can be deleted.'
+ )
+
+ def action_set_property_as_sold(self):
+ for property in self:
+ if property.state == 'canceled':
+ raise UserError('Canceled properties cannot be sold.')
+ property.state = 'sold'
+ return True
+
+ def action_set_property_as_canceled(self):
+ for property in self:
+ if property.state == 'sold':
+ raise UserError('Sold properties cannot be canceled.')
+ property.state = 'canceled'
+ return True
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..97750cf97bc
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,83 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+from odoo.tools import date_utils
+
+
+class EstatePropertyOffer(models.Model):
+ _name = "estate.property.offer"
+ _description = "Property Offer"
+ _order = 'price desc'
+
+ price = fields.Float('Price')
+ status = fields.Selection(
+ string='Status',
+ selection=[
+ ('accepted', 'Accepted'),
+ ('refused', 'Refused'),
+ ],
+ 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('Validity (days)', default=7)
+ date_deadline = fields.Date(
+ 'Deadline', compute='_compute_date_deadline', inverse='_inverse_date_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.'
+ )
+
+ @api.depends('validity')
+ def _compute_date_deadline(self):
+ for offer in self:
+ offer.date_deadline = date_utils.add(
+ (offer.create_date or fields.Date.today()), days=offer.validity
+ )
+
+ def _inverse_date_deadline(self):
+ for offer in self:
+ offer.validity = (
+ offer.date_deadline - (offer.create_date.date() or fields.Date.today())
+ ).days
+
+ @api.model
+ def create(self, vals_list):
+ for offer in vals_list:
+ property_id = offer.get('property_id')
+ if not property_id:
+ continue
+
+ linked_property = self.env['estate.property'].browse(property_id)
+
+ lowest_price = min(linked_property.offer_ids.mapped('price'), default=0.0)
+ if offer['price'] < lowest_price:
+ raise UserError(
+ 'You cannot create an offer with a lower amount than a existing one.'
+ )
+
+ if linked_property.state == 'new':
+ linked_property.state = 'offer_received'
+ return super().create(vals_list)
+
+ def action_accept(self):
+ for offer in self:
+ other_offers = offer.property_id.offer_ids - offer
+ if any(other_offers.filtered(lambda o: o.status == 'accepted')):
+ raise UserError('An offer has already been accepted.')
+
+ offer.status = 'accepted'
+ offer.property_id.state = 'offer_accepted'
+ offer.property_id.buyer_id = offer.partner_id
+ offer.property_id.selling_price = offer.price
+ return True
+
+ def action_refuse(self):
+ for offer in self:
+ offer.status = 'refused'
+ return True
diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py
new file mode 100644
index 00000000000..20f2281a3eb
--- /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 = "Property Tag"
+ _order = 'name'
+
+ name = fields.Char('Tag', required=True)
+ color = fields.Integer('Color')
+
+ _name_uniq = models.Constraint(
+ 'unique(name)', 'A tag with the same name already exists.'
+ )
diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py
new file mode 100644
index 00000000000..85f833dd3ed
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,26 @@
+from odoo import api, fields, models
+
+
+class EstatePropertyType(models.Model):
+ _name = "estate.property.type"
+ _description = "Property Type"
+ _order = 'sequence, name'
+
+ name = fields.Char('Type', required=True)
+ property_ids = fields.One2many(
+ 'estate.property', 'property_type_id', string='Property'
+ )
+ sequence = fields.Integer('Sequence', default=1)
+ offer_ids = fields.One2many(
+ 'estate.property.offer', 'property_type_id', string='Offers'
+ )
+ offer_count = fields.Integer('Offers Count', compute='_compute_offer_count')
+
+ _name_uniq = models.Constraint(
+ 'unique(name)', 'A type with the same name already exists.'
+ )
+
+ @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..89bc4cc5952
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,12 @@
+from odoo import fields, models
+
+
+class ResUsers(models.Model):
+ _inherit = 'res.users'
+
+ property_ids = fields.One2many(
+ 'estate.property',
+ 'salesperson_id',
+ string='Real Estate 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..78458c1cb61
--- /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
+estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
+estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1
+estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1
+estate.access_estate_property_offer,access_estate_property_offer,estate.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..6ff47288b05
--- /dev/null
+++ b/estate/views/estate_menus.xml
@@ -0,0 +1,14 @@
+
+
+
+
diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml
new file mode 100644
index 00000000000..acc0f0e5137
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,45 @@
+
+
+
+ estate.property.offer.form
+ estate.property.offer
+
+
+
+
+
+
+ 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..85e5ae3a07a
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,34 @@
+
+
+
+ estate.property.tag.form
+ estate.property.tag
+
+
+
+
+
+
+ estate.property.tag.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..7ec2d9c9882
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,50 @@
+
+
+
+ estate.property.type.form
+ estate.property.type
+
+
+
+
+
+
+ estate.property.type.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..b58bc1da97b
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,142 @@
+
+
+
+ estate.property.view.search
+ estate.property
+ 15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.form
+ estate.property
+
+
+
+
+
+
+ estate.property.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.kanban
+ estate.property
+
+
+
+
+
+
+
+
+
+ Expected Price:
+
+
+ Best Offer:
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
+ Property
+ estate.property
+ list,kanban,form
+ {'search_default_state': True}
+
+
diff --git a/estate/views/res_users.xml b/estate/views/res_users.xml
new file mode 100644
index 00000000000..65465b5b9ce
--- /dev/null
+++ b/estate/views/res_users.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..c73818c9356
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,10 @@
+{
+ 'name': "Estate Account",
+ 'description': """
+ Link the Estate app with the account
+ """,
+ 'version': '1.0',
+ 'author': "Odoo S.A.",
+ 'license': "LGPL-3",
+ 'depends': ['estate', 'account'],
+}
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..40b932bf201
--- /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_set_property_as_sold(self):
+ journal = self.env['account.journal'].search([('type', '=', 'sale')], limit=1)
+ self.env['account.move'].create(
+ {
+ 'partner_id': self.buyer_id.id,
+ 'move_type': 'out_invoice',
+ 'journal_id': journal.id,
+ '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,
+ }
+ ),
+ ],
+ }
+ )
+ return super().action_set_property_as_sold()