- hello world
+
+
+ hello world
+
+
+
+
+
+ This is simple text 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..1b272a33dce
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_item.js
@@ -0,0 +1,17 @@
+import { Component } from "@odoo/owl";
+
+export class TodoItem extends Component {
+ static template = "awesome_owl.TodoItem";
+
+ static props = {
+ todo: { type: Object },
+ toggleState: {type: Function},
+ removeTodo: { type: 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..e5505d509a1
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_item.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
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..e1e187fd253
--- /dev/null
+++ b/awesome_owl/static/src/todo/todo_list.js
@@ -0,0 +1,37 @@
+import { Component, useState, useRef, onMounted } 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 };
+
+ setup() {
+ this.todos = useState([]);
+ this.nextId = 0;
+ this.inputRef = useRef("input");
+ }
+ addTodo(ev) {
+ if (ev.keyCode == '13') {
+ console.log(ev.target.value)
+ if (ev.target.value != "") {
+ this.todos.push({
+ id: this.nextId++,
+ description: ev.target.value,
+ isCompleted: false
+ })
+ ev.target.value = ''
+ }
+ }
+ }
+ toggleTodo(id) {
+ const todo = this.todos.find(todo => todo.id === id);
+ todo.isCompleted = !todo.isCompleted;
+ }
+ removeTodo(id) {
+ const index = this.todos.findIndex((elem) => elem.id === id);
+ 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..c007bdad4ac
--- /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..904674232ce
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,13 @@
+import { useRef, onMounted } from "@odoo/owl";
+
+export function useAutofocus(refName) {
+ const ref = useRef(refName);
+
+ onMounted(() => {
+ if (ref.el) {
+ ref.el.focus();
+ }
+ });
+
+ return ref;
+}
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..4cd0ba006f0
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,21 @@
+{
+ 'name': "Real Estate",
+ 'description': """Real estate management tutorial module with properties, offers, types and tags.""",
+ 'version': '1.0',
+ 'license': 'LGPL-3',
+ 'summary': 'Real Estate advertisement tutorial module',
+ 'depends': ['base'],
+ 'author': "Harsh Maniya",
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'views/estate_property_offer_views.xml',
+ 'views/estate_property_type_views.xml',
+ 'views/estate_property_tag_views.xml',
+ 'views/estate_property_views.xml',
+ 'views/res_users_views.xml',
+ 'views/estate_menus.xml'
+ ],
+ 'category': 'Sales/Real Estate',
+ 'installable': True,
+ 'auto_install': False,
+}
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 00000000000..32834cf0ac3
--- /dev/null
+++ b/estate/models/__init__.py
@@ -0,0 +1,5 @@
+from . import estate_property
+from . import estate_property_offer
+from . import estate_property_type
+from . import estate_property_tag
+from . import res_users
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 00000000000..7e597c3be31
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,136 @@
+from dateutil.relativedelta import relativedelta
+from datetime import date
+
+from odoo import models, fields, api, exceptions, _
+from odoo.tools.float_utils import float_compare
+
+
+class EstateProperty(models.Model):
+ _name = "estate.property"
+ _description = "Real Estate Property"
+ _order = "id desc"
+
+ name = fields.Char(required=True)
+ description = fields.Text()
+ postcode = fields.Char()
+ date_availability = fields.Date(
+ default=lambda self: date.today() + relativedelta(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()
+ facades = fields.Integer()
+ garage = fields.Boolean()
+ garden = fields.Boolean()
+ garden_area = fields.Integer()
+ garden_orientation = fields.Selection(
+ selection=[
+ ('north', 'North'),
+ ('south', 'South'),
+ ('east', 'East'),
+ ('west', 'West'),
+ ],
+ )
+ active = fields.Boolean(default=True)
+ state = fields.Selection(
+ selection=[
+ ('new', 'New'),
+ ('offer_received', 'Offer Received'),
+ ('offer_accepted', 'Offer Accepted'),
+ ('sold', 'Sold'),
+ ('cancelled', 'Cancelled'),
+ ],
+ required=True,
+ copy=False,
+ default='new',
+ )
+ property_type_id = fields.Many2one(
+ "estate.property.type",
+ )
+ salesperson_id = fields.Many2one(
+ "res.users",
+ default=lambda self: self.env.user,
+ )
+ buyer_id = fields.Many2one(
+ "res.partner",
+ copy=False,
+ )
+ tag_ids = fields.Many2many(
+ "estate.property.tag",
+ )
+ offer_ids = fields.One2many(
+ "estate.property.offer",
+ "property_id",
+ )
+ total_area = fields.Float(
+ compute="_compute_total_area"
+ )
+ best_price = fields.Float(
+ compute="_compute_best_price",
+ )
+ _expected_price = models.Constraint(
+ 'CHECK(expected_price >= 0)',
+ 'The expected price must be positive.',
+ )
+ _selling_price = models.Constraint(
+ 'CHECK(selling_price >= 0)',
+ 'The selling price must be positive.',
+ )
+
+ @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:
+ prices = record.offer_ids.mapped('price')
+ record.best_price = max(prices) if prices else 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 = None
+
+ def action_cancel_property(self):
+ if self.filtered(lambda rec: rec.state == "sold"):
+ raise exceptions.UserError(_("Sold properties cannot be cancelled."))
+ self.write({"state": "cancelled"})
+ return True
+
+ def action_set_sold(self):
+ for rec in self:
+ if rec.state == "cancelled":
+ raise exceptions.UserError(_("Canceled properties cannot be sold."))
+ else:
+ rec.state = "sold"
+ return True
+
+ @api.constrains("selling_price", "expected_price")
+ def _check_selling_price(self):
+ for rec in self:
+ if rec.selling_price == 0:
+ return False
+ if float_compare(rec.selling_price, rec.expected_price * 0.9, precision_digits=2) < 0:
+ raise exceptions.ValidationError(_(
+ "The selling price must be at least 90% of the expected price!\n"
+ "You must reduce the expected price if you want to accept this offer."
+ ))
+
+ @api.ondelete(at_uninstall=False)
+ def _check_property_deletion(self):
+ for rec in self:
+ if rec.state not in ("new", "cancelled"):
+ raise exceptions.UserError(_(
+ "You can only delete properties in New or Cancelled state."
+ ))
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..71a58fb8212
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,81 @@
+from dateutil.relativedelta import relativedelta
+
+from odoo import models, fields, api, exceptions, _
+
+
+class EstatePropertyOffer(models.Model):
+ _name = "estate.property.offer"
+ _description = "Real Estate Property Offer"
+ _order = "price desc"
+
+ price = fields.Float(string="Price")
+ status = fields.Selection(
+ selection=[
+ ("accepted", "Accepted"),
+ ("refused", "Refused"),
+ ],
+ copy=False,
+ )
+ partner_id = fields.Many2one(
+ "res.partner",
+ required=True,
+ )
+ property_id = fields.Many2one(
+ "estate.property",
+ required=True,
+ )
+ validity = fields.Integer(
+ default=7,
+ )
+ date_deadline = fields.Date(
+ compute="_compute_date_deadline",
+ inverse="_inverse_date_deadline",
+ store=True,
+ )
+ property_type_id = fields.Many2one(
+ related="property_id.property_type_id", store=True
+ )
+ _offer_price = models.Constraint(
+ 'CHECK (price > 0)',
+ 'Offer price must be greater than 0',
+ )
+
+ @api.depends("validity")
+ def _compute_date_deadline(self):
+ for rec in self:
+ create = rec.create_date or fields.Date.today()
+ rec.date_deadline = (create + relativedelta(days=rec.validity))
+
+ def _inverse_date_deadline(self):
+ for rec in self:
+ create = rec.create_date or fields.Date.today()
+ rec.validity = (rec.date_deadline - fields.Date.today(create)).days
+
+ def action_accept(self):
+ for offer in self:
+ if offer.property_id.buyer_id:
+ raise exceptions.UserError(_('Only one offer can be accepted for a property.'))
+ offer.status = 'accepted'
+ offer.property_id.selling_price = offer.price
+ offer.property_id.buyer_id = offer.partner_id
+ offer.property_id.state = 'offer_accepted'
+ return True
+
+ def action_refuse(self):
+ for offer in self:
+ offer.status = 'refused'
+ return True
+
+ @api.model
+ def create(self, vals):
+ for rec in vals:
+ property_id = rec.get('property_id')
+ price = rec.get('price', 0.0)
+ if property_id:
+ property_obj = self.env['estate.property'].browse(property_id)
+ best_offer = property_obj.best_price or 0.0
+ if price < best_offer:
+ raise exceptions.UserError(_(
+ 'Offer price must be greater than or equal to the best offer price.'))
+ property_obj.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..bb994a59d28
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,15 @@
+from odoo import models, fields
+
+
+class EstatePropertyTag(models.Model):
+ _name = "estate.property.tag"
+ _description = "Real Estate Property Tag"
+ _order = "name"
+
+ name = fields.Char(required=True)
+ color = fields.Integer()
+
+ _unique_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..d70322a7242
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,25 @@
+from odoo import models, fields
+
+
+class EstatePropertyType(models.Model):
+ _name = "estate.property.type"
+ _description = "Real Estate Property Type"
+ _order = "sequence,name"
+
+ name = fields.Char(required=True)
+ property_ids = fields.One2many(
+ "estate.property",
+ "property_type_id",
+ )
+ sequence = fields.Integer(default=1, help="Used to order stages. Lower is better.")
+ offer_ids = fields.One2many("estate.property.offer", "property_type_id")
+ offer_count = fields.Integer(compute="_compute_offer_count")
+
+ _unique_name = models.Constraint(
+ 'unique(name)',
+ 'The property type name must be unique.',
+ )
+
+ def _compute_offer_count(self):
+ for rec in self:
+ rec.offer_count = len(rec.offer_ids)
diff --git a/estate/models/res_users.py b/estate/models/res_users.py
new file mode 100644
index 00000000000..ed3cc97d2f5
--- /dev/null
+++ b/estate/models/res_users.py
@@ -0,0 +1,11 @@
+from odoo import models, fields
+
+
+class ResUsers(models.Model):
+ _inherit = "res.users"
+
+ property_ids = fields.One2many(
+ "estate.property",
+ "salesperson_id",
+ domain=[("state", "=", "new")]
+ )
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..341f97bd0a2
--- /dev/null
+++ b/estate/views/estate_menus.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml
new file mode 100644
index 00000000000..1b0e1960db1
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,23 @@
+
+
+ Property Offers
+ estate.property.offer
+ list,form
+ [('property_type_id', '=', active_id)]
+
+
+ estate.property.offer.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_property_tag_views.xml b/estate/views/estate_property_tag_views.xml
new file mode 100644
index 00000000000..57400bbfb52
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,20 @@
+
+
+ Property Tags
+ estate.property.tag
+ list,form
+
+ Create and manage tags for your properties.
+
+
+
+ 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..aeb03797f4d
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,51 @@
+
+
+ Property Types
+ estate.property.type
+ list,form
+
+
+ estate.property.type.form
+ estate.property.type
+
+
+
+
+
+ estate.property.type.list
+ 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..6f5dbe79a9d
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,154 @@
+
+
+ Properties
+ estate.property
+ kanban,list,form
+ {'search_default_available': 1}
+
+
+
+ estate.property.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.form
+ estate.property
+
+
+
+
+
+
+ estate.property.kanban
+ estate.property
+
+
+
+
+
+
+
+
+
+
+ Expected Price:
+
+
Best Offer:
+
+
+
Selling Price:
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/res_users_views.xml b/estate/views/res_users_views.xml
new file mode 100644
index 00000000000..8fd1af52b91
--- /dev/null
+++ b/estate/views/res_users_views.xml
@@ -0,0 +1,25 @@
+
+
+ res.users.form.inherit.estate
+ 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..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..85039f0f5e5
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,10 @@
+{
+ "name": "Estate Account",
+ "description": "Link real estate properties with invoicing",
+ "version": "1.0",
+ "category": "Real Estate",
+ "depends": ["estate", "account"],
+ "author": "Harsh Maniya",
+ "license": "LGPL-3",
+ "data": [],
+}
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..ce0c2b495d6
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,30 @@
+from odoo import models, Command
+
+
+class EstateProperty(models.Model):
+ _inherit = "estate.property"
+
+ def action_set_sold(self):
+ self.env["account.move"].create(
+ {
+ "move_type": "out_invoice",
+ "partner_id": self.buyer_id.id,
+ "invoice_line_ids": [
+ Command.create(
+ {
+ "name": "6% of selling price",
+ "quantity": 1,
+ "price_unit": self.selling_price * 0.6,
+ }
+ ),
+ Command.create(
+ {
+ "name": "Administrative fees",
+ "quantity": 1,
+ "price_unit": 100.0,
+ }
+ ),
+ ],
+ }
+ )
+ return super().action_set_sold()