+
hello world
+
+
+
+
+
+ Card content 1
+
+
+
+
+
+
+
+
-
-
+
\ No newline at end of file
diff --git a/awesome_owl/static/src/todolist/todo_item.js b/awesome_owl/static/src/todolist/todo_item.js
new file mode 100644
index 00000000000..a8f3fc6a611
--- /dev/null
+++ b/awesome_owl/static/src/todolist/todo_item.js
@@ -0,0 +1,23 @@
+import { Component } from '@odoo/owl';
+
+export class TodoItem extends Component {
+ static template = 'awesome_owl.TodoItem';
+ static props = {
+ todo: {
+ type: {
+ id: Number,
+ description: String,
+ isCompleted: Boolean,
+ },
+ optional: false,
+ },
+ toggleTodo: {
+ type: Function,
+ optional: false,
+ },
+ removeTodo: {
+ type: Function,
+ optional: false,
+ },
+ };
+}
\ No newline at end of file
diff --git a/awesome_owl/static/src/todolist/todo_item.xml b/awesome_owl/static/src/todolist/todo_item.xml
new file mode 100644
index 00000000000..566952279b9
--- /dev/null
+++ b/awesome_owl/static/src/todolist/todo_item.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/awesome_owl/static/src/todolist/todo_list.js b/awesome_owl/static/src/todolist/todo_list.js
new file mode 100644
index 00000000000..1949bd8dee9
--- /dev/null
+++ b/awesome_owl/static/src/todolist/todo_list.js
@@ -0,0 +1,51 @@
+import { Component, useState } from '@odoo/owl';
+import { TodoItem } from './todo_item';
+import { useAutoFocus } from '../utils';
+
+export class TodoList extends Component {
+ static template = 'awesome_owl.TodoList';
+ static components = { TodoItem };
+ static props = {
+ todos: {
+ type: Array,
+ optional: true,
+ },
+ };
+
+ setup() {
+ this.todos = useState([]);
+ this.addTask = this.addTask.bind(this);
+ this.nextTodoId = this.todos.length + 1;
+ useAutoFocus('add_task_input');
+ this.toggleTodo = this.toggleTodo.bind(this);
+ this.removeTodo = this.removeTodo.bind(this);
+ }
+
+ addTask(ev) {
+ ev.preventDefault();
+ if (ev.key !== 'Enter') {
+ return;
+ }
+ const input = ev.target;
+ const description = input.value.trim();
+ if (!description) {
+ return;
+ }
+ this.todos.push({
+ id: this.nextTodoId++,
+ description,
+ isCompleted: false,
+ });
+ input.value = '';
+ }
+
+ toggleTodo(todoId) {
+ const toBeToggled = this.todos.find(todo => todo.id === todoId);
+ toBeToggled.isCompleted = !toBeToggled.isCompleted;
+ }
+
+ removeTodo(todoId) {
+ const toBeRemovedIndex = this.todos.findIndex(todo => todo.id === todoId);
+ this.todos.splice(toBeRemovedIndex, 1);
+ }
+}
diff --git a/awesome_owl/static/src/todolist/todo_list.xml b/awesome_owl/static/src/todolist/todo_list.xml
new file mode 100644
index 00000000000..d0ba75abe28
--- /dev/null
+++ b/awesome_owl/static/src/todolist/todo_list.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js
new file mode 100644
index 00000000000..d88b6f1a6cd
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,8 @@
+import { onMounted, useRef } from '@odoo/owl';
+
+export const useAutoFocus = (inputFieldRefName) => {
+ const addTaskInputRef = useRef(inputFieldRefName);
+ onMounted(() => {
+ addTaskInputRef.el.focus();
+ });
+}
\ No newline at end of file
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..e23e965ffd2
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,21 @@
+{
+ 'name': 'Real Estate',
+ 'version': '1.0',
+ 'description': 'anything',
+ 'summary': 'anything again',
+ '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_res_users_views.xml',
+ 'views/estate_menus.xml',
+ ],
+ 'depends': [
+ 'base',
+ ],
+ 'application': True,
+ 'installable': True,
+ 'license': 'AGPL-3'
+}
diff --git a/estate/constants.py b/estate/constants.py
new file mode 100644
index 00000000000..abc18e1560a
--- /dev/null
+++ b/estate/constants.py
@@ -0,0 +1,5 @@
+# selling prices for the properties should be at least 90% of the expected price
+PROPERTY_SELLING_PRICE_THRESHOLD = 0.9
+
+# epsilon to define the rounding precision when comparing floats
+PROPERTY_PRICE_PRECISION_EPSILON = 1e-6
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 00000000000..7b3fc844702
--- /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 estate_property_user
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 00000000000..7c47b2af0dd
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,112 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+from odoo.tools.float_utils import float_compare, float_is_zero
+
+from ..constants import PROPERTY_PRICE_PRECISION_EPSILON, PROPERTY_SELLING_PRICE_THRESHOLD
+
+
+class EstateProperty(models.Model):
+ _name = 'estate.property'
+ _description = 'model for the properties in our app'
+ _order = 'id desc'
+
+ name = fields.Char(required = True)
+ description = fields.Text()
+ postcode = fields.Char()
+ date_availability = fields.Date(
+ copy = False,
+ default = fields.Date.add(fields.Date.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'),
+ ],
+ help = 'garden orientation is used to choose the orientation of the garden attached to the property'
+ )
+ active = fields.Boolean(default = True)
+ state = fields.Selection(
+ string = "State",
+ selection = [
+ ('new', 'New'),
+ ('offer_received', 'Offer Received'),
+ ('offer_accepted', 'Offer Accepted'),
+ ('sold', 'Sold'),
+ ('cancelled', 'Cancelled'),
+ ],
+ default = 'new',
+ required = True,
+ 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)
+ property_tag_ids = fields.Many2many("estate.property.tag", string = "Property Tags")
+ offer_ids = fields.One2many("estate.property.offer", "property_id", string = "Offers")
+ total_area = fields.Float(compute = "_compute_total_area")
+ best_offer = fields.Float(compute = "_compute_best_offer")
+
+ @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_offer(self):
+ for record in self:
+ record.best_offer = max(record.offer_ids.mapped('price'), default = 0.0)
+
+ @api.onchange('garden')
+ def _onchange_garden(self):
+ if not self.garden:
+ self.garden_area = 0
+ self.garden_orientation = ''
+ else:
+ self.garden_orientation = 'north'
+ self.garden_area = 10
+
+ def action_cancel_property(self):
+ if self.filtered(lambda record: record.state == 'sold'):
+ raise UserError('Sold properties cannot be cancelled')
+ self.state = 'cancelled'
+ return True
+
+ def action_sell_property(self):
+ if self.filtered(lambda record: record.state == 'cancelled'):
+ raise UserError('Cancelled properties cannot be sold')
+ if not self.filtered(lambda record: record.state == 'offer_accepted'):
+ raise UserError('You must accept an offer before you can sell the property')
+ self.state = 'sold'
+ return True
+
+ @api.constrains('selling_price')
+ def _check_selling_price(self):
+ for record in self:
+ if float_is_zero(record.selling_price, precision_rounding = PROPERTY_PRICE_PRECISION_EPSILON):
+ continue
+ if float_compare(
+ record.selling_price, record.expected_price * PROPERTY_SELLING_PRICE_THRESHOLD,
+ precision_rounding = PROPERTY_PRICE_PRECISION_EPSILON
+ ) < 0:
+ raise UserError('The selling price must be at least 90% of the the expected price')
+
+ @api.ondelete(at_uninstall = False)
+ def _ondelete_property(self):
+ if self.filtered(lambda record: record.state not in ('new', 'cancelled')):
+ raise UserError('Only new or canceled properties can be deleted')
+
+ _sql_constraints = [
+ ('positive_expected_price', 'CHECK(expected_price > 0)', 'Expected price must be positive'),
+ ('positive_selling_price', 'CHECK(selling_price >= 0)', 'Selling price must be positive'),
+ ]
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..4f90a7f0d50
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,67 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+from odoo.tools.float_utils import float_compare, float_is_zero
+
+from ..constants import PROPERTY_PRICE_PRECISION_EPSILON
+
+
+class EstatePropertyOffer(models.Model):
+ _name = 'estate.property.offer'
+ _description = 'the offer of the property being sold'
+ _order = 'price desc'
+
+ price = fields.Float()
+ status = fields.Selection(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)
+ 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', store = True)
+
+ @api.depends('validity')
+ def _compute_date_deadline(self):
+ for record in self:
+ if record.create_date:
+ record.date_deadline = fields.Date.add(record.create_date, days = record.validity)
+
+ def _inverse_date_deadline(self):
+ for record in self:
+ if record.create_date and record.date_deadline:
+ create_date = fields.Date.from_string(record.create_date)
+ record.validity = (record.date_deadline - create_date).days
+
+ def action_accept_offer(self):
+ self.ensure_one()
+ if self.property_id.buyer_id:
+ raise UserError('This property already has an accepted offer')
+ self.property_id.selling_price = self.price
+ self.property_id.state = 'offer_accepted'
+ self.status = 'accepted'
+ self.property_id.buyer_id = self.partner_id
+ return True
+
+ def action_refuse_offer(self):
+ self.ensure_one()
+ if self.property_id.buyer_id == self.partner_id:
+ self.property_id.buyer_id = False
+ self.property_id.state = 'offer_received'
+ self.property_id.selling_price = 0
+ self.status = 'refused'
+ return True
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ property_offers = [vals for vals in vals_list if vals.get('property_id')]
+ for offer_vals in property_offers:
+ property_id = self.env['estate.property'].browse(offer_vals.get('property_id'))
+ max_price = max(property_id.offer_ids.mapped('price'), default = 0.0)
+ if float_compare(
+ offer_vals.get('price'), max_price, precision_rounding = PROPERTY_PRICE_PRECISION_EPSILON
+ ) < 0:
+ raise UserError('The offer must be at least %s' % max_price)
+ property_id.state = 'offer_received'
+ return super().create(vals_list)
+
+ _sql_constraints = [
+ ('price_positive', 'CHECK(price > 0)', 'Price must be positive')
+ ]
diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py
new file mode 100644
index 00000000000..9fe79efa85c
--- /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 = 'the tag of the property being sold'
+ _order = 'name'
+ color = fields.Integer()
+
+ name = fields.Char(required = True)
+
+ _sql_constraints = [
+ ('name_uniq', 'unique(name)', '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..89c44cea1f7
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,22 @@
+from odoo import api, fields, models
+
+
+class EstatePropertyType(models.Model):
+ _name = 'estate.property.type'
+ _description = 'the type of the property being sold'
+ _order = 'sequence, name'
+ sequence = fields.Integer(default = 1)
+ offer_ids = fields.One2many('estate.property.offer', 'property_type_id', string = 'Offers')
+ offer_count = fields.Integer(compute='_compute_offer_count')
+
+ name = fields.Char(required = True)
+ property_ids = fields.One2many('estate.property', 'property_type_id', string = 'Properties')
+
+ @api.depends('offer_ids')
+ def _compute_offer_count(self):
+ for record in self:
+ record.offer_count = len(record.offer_ids)
+
+ _sql_constraints = [
+ ('name_uniq', 'unique(name)', 'Property type name must be unique!')
+ ]
diff --git a/estate/models/estate_property_user.py b/estate/models/estate_property_user.py
new file mode 100644
index 00000000000..492668a5895
--- /dev/null
+++ b/estate/models/estate_property_user.py
@@ -0,0 +1,9 @@
+from odoo import fields, models
+
+
+class EstatePropertyUser(models.Model):
+ _inherit = 'res.users'
+
+ property_ids = fields.Many2many(
+ 'estate.property', string = '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..a982d2a89c7
--- /dev/null
+++ b/estate/views/estate_menus.xml
@@ -0,0 +1,24 @@
+
+
+
+
diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml
new file mode 100644
index 00000000000..a64214b8ce5
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,56 @@
+
+
+
+ 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..a1824df1274
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,32 @@
+
+
+
+ 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..15fae3e03ac
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,53 @@
+
+
+
+ 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..b45464284c3
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,145 @@
+
+
+
+ estate.property.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.form
+ estate.property
+
+
+
+
+
+
+ estate.property.kanban
+ estate.property
+
+
+
+
+
+
+
+
+ Expected Price:
+
+
+
+ Best Price:
+
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
+
+ estate.property.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Properties
+ estate.property
+ kanban,list,form
+ {'search_default_available': True}
+
+
diff --git a/estate/views/estate_res_users_views.xml b/estate/views/estate_res_users_views.xml
new file mode 100644
index 00000000000..9f08fbd9027
--- /dev/null
+++ b/estate/views/estate_res_users_views.xml
@@ -0,0 +1,17 @@
+
+
+
+ res.users.view.inherit.show.properties
+ res.users
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/estate_account/__init__.py b/estate_account/__init__.py
new file mode 100644
index 00000000000..9a7e03eded3
--- /dev/null
+++ b/estate_account/__init__.py
@@ -0,0 +1 @@
+from . import models
\ No newline at end of file
diff --git a/estate_account/__manifest__.py b/estate_account/__manifest__.py
new file mode 100644
index 00000000000..1c346467585
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,14 @@
+{
+ 'name': 'Real Estate Account',
+ 'version': '1.0',
+ 'description': 'a model to enable creation of invoices for sold properties',
+ 'data': [],
+ 'depends': [
+ 'base',
+ 'estate',
+ 'account',
+ ],
+ 'application': True,
+ 'installable': True,
+ 'license': 'LGPL-3',
+}
diff --git a/estate_account/models/__init__.py b/estate_account/models/__init__.py
new file mode 100644
index 00000000000..f4c8fd6db6d
--- /dev/null
+++ b/estate_account/models/__init__.py
@@ -0,0 +1 @@
+from . import estate_property
\ No newline at end of file
diff --git a/estate_account/models/estate_property.py b/estate_account/models/estate_property.py
new file mode 100644
index 00000000000..14b4f33081d
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,28 @@
+from odoo import fields, models, Command
+
+
+class EstateProperty(models.Model):
+ _inherit = 'estate.property'
+
+ def action_sell_property(self):
+ for record in self:
+ record.env["account.move"].create(
+ {
+ "partner_id": record.buyer_id.id,
+ "move_type": "out_invoice",
+ "invoice_line_ids": [
+ Command.create({
+ "name": "6% of the selling price",
+ "price_unit": record.selling_price * 0.06,
+ "quantity": 1,
+ }),
+ Command.create({
+ "name": "Administration Fee",
+ "price_unit": 20,
+ "quantity": 1,
+ })
+ ]
+ },
+ )
+
+ return super().action_sell_property()