- hello world
+
Playground
+
+
+
+
+
+
+
+
+
+
+
Todo List
+
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..38caf5c9de2
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_item.js
@@ -0,0 +1,24 @@
+import { Component } from "@odoo/owl";
+
+export class TodoItem extends Component {
+ static template = "awesome_owl.todo_item";
+ static props = {
+ todo: {
+ shape: {
+ id: Number,
+ description: String,
+ isCompleted: Boolean,
+ },
+ },
+ toggleState: Function,
+ removeTodo: Function,
+ };
+
+ onToggle() {
+ 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..9a4ebb9d582
--- /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..724f1be31d5
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_list.js
@@ -0,0 +1,46 @@
+import { Component, useState } from "@odoo/owl";
+import { TodoItem } from "./todo_item";
+
+export class TodoList extends Component {
+ static template = "awesome_owl.todo_list";
+
+ setup() {
+ this.todos = useState([]);
+ this.counter = 0;
+ }
+
+ focusInput() {
+ this.myRef.el.focus();
+ }
+
+ addTodo(ev) {
+ if (ev.keyCode === 13 && ev.target.value != "") {
+ this.todos.push({
+ id: this.counter++,
+ description: ev.target.value,
+ isCompleted: false,
+ });
+ ev.target.value = "";
+ }
+ }
+
+ toggleTodoState = (todoId) => {
+ const todo = this.todos.find((t) => t.id === todoId);
+ if (todo) {
+ if (todo.isCompleted) {
+ todo.isCompleted = false;
+ } else {
+ todo.isCompleted = true;
+ }
+ }
+ }
+
+ removeTodo = (todoId) => {
+ const index = this.todos.findIndex((t) => t.id === todoId);
+ if (index > 0) {
+ this.todos.splice(index, 1);
+ }
+ }
+
+ static components = { TodoItem };
+}
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..239e89eaed6
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_list.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/__init__.py b/estate/__init__.py
new file mode 100644
index 00000000000..d6210b1285d
--- /dev/null
+++ b/estate/__init__.py
@@ -0,0 +1,3 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import models
diff --git a/estate/__manifest__.py b/estate/__manifest__.py
new file mode 100644
index 00000000000..ab827616d91
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,20 @@
+{
+ 'name': "Real Estate",
+ 'depends': ['base'],
+ 'author': "Odoo",
+ 'category': 'Category',
+ 'license': 'LGPL-3',
+ 'application': True,
+ 'description': """
+ A app for real estate
+ """,
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'views/estate_views.xml',
+ 'views/estate_list_views.xml',
+ 'views/estate_form_views.xml',
+ 'views/estate_search_views.xml',
+ 'views/estate_menus.xml',
+ 'views/estate_kanban_views.xml',
+ ],
+}
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 00000000000..3ced267895e
--- /dev/null
+++ b/estate/models/__init__.py
@@ -0,0 +1,9 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import (
+ estate_property,
+ estate_property_offer,
+ estate_property_tag,
+ estate_property_type,
+ res_users,
+)
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 00000000000..d4156e8ad7b
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,108 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models
+from odoo.exceptions import UserError, ValidationError
+from odoo.tools.float_utils import float_compare, float_is_zero
+
+
+class EstateProperty(models.Model):
+ _name = "estate.property"
+ _description = "Estate properties"
+ _order = "id desc"
+
+ name = fields.Char('Property Name', required=True)
+ description = fields.Text('Description')
+ postcode = fields.Char('Postcode')
+ date_availability = fields.Date('Available From', copy=False, default=lambda self: 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')],
+ help="Type is used to choose the orientation")
+ property_type_id = fields.Many2one('estate.property.type', string='Property Types')
+ seller_id = fields.Many2one('res.users', string='Salesman', 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')
+ active = fields.Boolean(default=True)
+ state = fields.Selection(
+ string='Status',
+ selection=[('new', 'New'), ('offer_received', 'Offer Received'), ('offer_accepted', 'Offer Accepted'), ('sold', 'Sold'), ('canceled', 'Canceled')],
+ required=True, copy=False, default='new')
+ total_area = fields.Integer('Total Area (sqm)', compute="_compute_total_area")
+ best_price = fields.Float('Best Offer', compute='_compute_best_price')
+
+ @api.depends('living_area', 'garden_area')
+ def _compute_total_area(self):
+ for line in self:
+ line.total_area = line.garden_area + line.living_area
+
+ @api.depends('offer_ids')
+ def _compute_best_price(self):
+ for line in self:
+ if line.offer_ids:
+ line.best_price = max(line.offer_ids.mapped('price'))
+ else:
+ line.best_price = 0.0
+
+ @api.onchange("garden")
+ def _onchange_partner_id(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):
+ for record in self:
+ if record.state != 'canceled':
+ record.state = 'sold'
+ else:
+ error_msg = "You cannot sell a canceled property."
+ raise UserError(error_msg)
+ return True
+
+ def action_cancel(self):
+ for record in self:
+ if record.state != 'sold':
+ record.state = 'canceled'
+ else:
+ error_msg = "You cannot cancel a sold property."
+ raise UserError(error_msg)
+ return True
+
+ _check_positive_expected_price = models.Constraint(
+ 'CHECK(expected_price > 0)',
+ 'The expected price of a property should be strictly positive.',
+ )
+
+ _check_positive_selling_price = models.Constraint(
+ 'CHECK(selling_price >= 0)',
+ 'The selling price of a property should be positive or zero.',
+ )
+
+ @api.constrains('selling_price', 'expected_price')
+ def _check_price_offer(self):
+ for record in self:
+ if float_is_zero(record.selling_price, precision_digits=2):
+ continue
+ expected_price = record.expected_price
+ selling_price = record.selling_price
+ if float_compare(selling_price, expected_price * 0.9, precision_digits=2) < 0:
+ error_msg = "The selling price should be at least 90% of the expected price."
+ raise ValidationError(error_msg)
+
+ @api.ondelete(at_uninstall=False)
+ def _unlink_check_state(self):
+ for record in self:
+ if record.state != 'new' and record.state != 'canceled':
+ error_msg = "Only properties in 'New' or 'Canceled' status can be deleted."
+ raise UserError(error_msg)
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..538c7fa016f
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,65 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from datetime import timedelta
+
+from odoo import api, fields, models
+from odoo.exceptions import ValidationError
+
+
+class EstatePropertyOffer(models.Model):
+ _name = "estate.property.offer"
+ _description = "Estate property offers"
+ _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)
+
+ @api.depends('create_date', 'validity')
+ def _compute_date_deadline(self):
+ for offer in self:
+ if offer.create_date:
+ offer.date_deadline = offer.create_date + timedelta(days=offer.validity)
+ else:
+ offer.date_deadline = fields.Date.today() + timedelta(days=offer.validity)
+
+ def _inverse_date_deadline(self):
+ for offer in self:
+ offer.validity = (offer.date_deadline - offer.create_date.date()).days
+
+ 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'
+
+ def action_refuse_offer(self):
+ for record in self:
+ record.status = 'refused'
+
+ _check_positive_offer_price = models.Constraint(
+ 'CHECK(price > 0)',
+ 'The price of an offer should be strictly positive.',
+ )
+
+ @api.model
+ def create(self, vals):
+ if len(vals) == 0:
+ return super().create(vals)
+ property_id = vals[0].get('property_id')
+ price = vals[0].get('price')
+ if property_id and price:
+ property_record = self.env['estate.property'].browse(property_id)
+ if property_record.best_price and price <= property_record.best_price:
+ error_msg = "The offer price should be higher than the best offer of the property."
+ raise ValidationError(error_msg)
+ property_record.state = 'offer_received'
+ 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..d17879341c2
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,17 @@
+# 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 = "Estate properties tags"
+ _order = "name"
+
+ name = fields.Char('Property Tags', required=True)
+ color = fields.Integer()
+
+ _check_unique_name = models.Constraint(
+ 'UNIQUE(name)',
+ 'The name of a property tag 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..14b0c9175d6
--- /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 = "Estate properties types"
+ _order = "sequence"
+
+ sequence = fields.Integer()
+ name = fields.Char('Property Types', required=True)
+ property_ids = fields.One2many('estate.property', 'property_type_id', string='Properties')
+ offer_ids = fields.One2many('estate.property.offer', 'property_type_id', string='Offers')
+ offer_count = fields.Integer('Offers Count', 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..85465e19d04
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,9 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models
+
+
+class ResUsers(models.Model):
+ _inherit = 'res.users'
+
+ property_ids = fields.One2many('estate.property', 'seller_id', string='Properties for Sale', 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..6816efc342c
--- /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_property_type,access_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1
+estate.access_property_tag,access_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1
+estate.access_property_offer,access_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1
diff --git a/estate/views/estate_form_views.xml b/estate/views/estate_form_views.xml
new file mode 100644
index 00000000000..f72123c9010
--- /dev/null
+++ b/estate/views/estate_form_views.xml
@@ -0,0 +1,141 @@
+
+
+
+ estate.form
+ estate.property
+
+
+
+
+
+
+ estate.type.form
+ estate.property.type
+
+
+
+
+
+
+ estate.tag.form
+ estate.property.tag
+
+
+
+
+
+
+ estate.offer.form
+ estate.property.offer
+
+
+
+
+
+
+ res.users.form.inherit.estate
+ res.users
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_kanban_views.xml b/estate/views/estate_kanban_views.xml
new file mode 100644
index 00000000000..a9d3018f40a
--- /dev/null
+++ b/estate/views/estate_kanban_views.xml
@@ -0,0 +1,27 @@
+
+
+
+ estate.property.kanban
+ estate.property
+
+
+
+
+
+
+
+
Expected Price:
+
+ Best Offer:
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_list_views.xml b/estate/views/estate_list_views.xml
new file mode 100644
index 00000000000..c57984b6bec
--- /dev/null
+++ b/estate/views/estate_list_views.xml
@@ -0,0 +1,55 @@
+
+
+
+ estate.property.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.type.list
+ estate.property.type
+
+
+
+
+
+
+
+
+
+ estate.property.tag.list
+ estate.property.tag
+
+
+
+
+
+
+
+
+ estate.property.offer.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml
new file mode 100644
index 00000000000..1a1ed06b449
--- /dev/null
+++ b/estate/views/estate_menus.xml
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/estate/views/estate_search_views.xml b/estate/views/estate_search_views.xml
new file mode 100644
index 00000000000..047cf81ad92
--- /dev/null
+++ b/estate/views/estate_search_views.xml
@@ -0,0 +1,34 @@
+
+
+
+ estate.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.type.search
+ estate.property.type
+
+
+
+
+
+
+
diff --git a/estate/views/estate_views.xml b/estate/views/estate_views.xml
new file mode 100644
index 00000000000..b3ffcc6a19a
--- /dev/null
+++ b/estate/views/estate_views.xml
@@ -0,0 +1,29 @@
+
+
+
+ Properties
+ estate.property
+ list,form,kanban
+ {"search_default_available": 1}
+
+
+
+ Property Types
+ estate.property.type
+ list,form
+
+
+
+ Property Tags
+ estate.property.tag
+ list,form
+
+
+
+ Property Type Offers
+ estate.property.offer
+ list,form
+ [('property_type_id', 'in', active_ids)]
+
+
+
diff --git a/estate_account/__init__.py b/estate_account/__init__.py
new file mode 100644
index 00000000000..d6210b1285d
--- /dev/null
+++ b/estate_account/__init__.py
@@ -0,0 +1,3 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import models
diff --git a/estate_account/__manifest__.py b/estate_account/__manifest__.py
new file mode 100644
index 00000000000..8cf1ce79f68
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,13 @@
+{
+ 'name': "Real Estate Invoicing",
+ 'depends': ['base', 'estate', 'account'],
+ 'author': "Odoo",
+ 'category': 'Category',
+ 'license': 'LGPL-3',
+ 'application': True,
+ 'description': """
+ A app for real estate invoices.
+ """,
+ 'data': [
+ ],
+}
diff --git a/estate_account/models/__init__.py b/estate_account/models/__init__.py
new file mode 100644
index 00000000000..4c7ec5adb72
--- /dev/null
+++ b/estate_account/models/__init__.py
@@ -0,0 +1,5 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+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..7b9e8c4e628
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,32 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import models
+
+
+class EstateProperty(models.Model):
+ _inherit = 'estate.property'
+
+ def action_sold(self):
+
+ self.env['account.move'].create({
+ 'partner_id': self.buyer_id.id,
+ 'move_type': 'out_invoice',
+ 'journal_id': self.env['account.journal'].search([('type', '=', 'sale')], limit=1).id,
+ 'line_ids': [
+ # 6% of the selling price
+ (0, 0, {
+ 'name': self.name,
+ 'quantity': 1,
+ 'price_unit': self.selling_price * 0.06,
+ }),
+ # 100.00 from administrative fees
+ (0, 0, {
+ 'name': 'Administrative Fees',
+ 'quantity': 1,
+ 'price_unit': 100.00,
+ }),
+
+ ],
+ })
+
+ return super().action_sold()