diff --git a/.gitignore b/.gitignore
index b6e47617de1..4502b2438eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -127,3 +127,6 @@ dmypy.json
# Pyre type checker
.pyre/
+
+# Linting
+pyproject.toml
diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js
deleted file mode 100644
index c4fb245621b..00000000000
--- a/awesome_dashboard/static/src/dashboard.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Component } from "@odoo/owl";
-import { registry } from "@web/core/registry";
-
-class AwesomeDashboard extends Component {
- static template = "awesome_dashboard.AwesomeDashboard";
-}
-
-registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml
deleted file mode 100644
index 1a2ac9a2fed..00000000000
--- a/awesome_dashboard/static/src/dashboard.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
- hello dashboard
-
-
-
diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js
new file mode 100644
index 00000000000..da1ae0c84bf
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard.js
@@ -0,0 +1,112 @@
+import { Component, onWillStart, useState } from "@odoo/owl";
+import { registry } from "@web/core/registry";
+import { Layout } from "@web/search/layout";
+import { useService } from "@web/core/utils/hooks";
+import { AwesomeDashboardItem } from "./dashboard_item";
+import { rpc } from "@web/core/network/rpc";
+import { PieChart } from "./pie_chart/pie_chart";
+import { Dialog } from "@web/core/dialog/dialog";
+import { CheckBox } from "@web/core/checkbox/checkbox";
+import { browser } from "@web/core/browser/browser";
+
+class AwesomeDashboard extends Component {
+ static components = { AwesomeDashboardItem, PieChart, Layout };
+ static template = "awesome_dashboard.AwesomeDashboard";
+
+ setup() {
+ this.action = useService("action");
+ this.stats = useState(useService("awesome_dashboard.statistics"));
+ this.items = registry.category("awesome_dashboard").getAll();
+ this.dialog = useService("dialog");
+
+ const hiddenItems = JSON.parse(
+ browser.localStorage
+ .getItem("disabled_dashboard_items")
+ ?.split(",") || '[]',
+ );
+ this.state = useState({ disabledItems: hiddenItems });
+
+ onWillStart(async () => {
+ const res = await rpc("/awesome_dashboard/statistics");
+ console.log(res);
+ Object.assign(this.stats, res);
+ });
+ }
+
+ openCustomers() {
+ this.action.doAction("base.action_partner_form");
+ }
+
+ openLeads() {
+ this.action.doAction({
+ type: "ir.actions.act_window",
+ name: "Leads",
+ res_model: "crm.lead",
+ views: [
+ [false, "form"],
+ [false, "list"],
+ ],
+ });
+ }
+
+ openConfig() {
+ this.dialog.add(ConfigDialog, {
+ items: this.items,
+ disabled: this.state.disabledItems,
+ onUpdate: (newDisabledItems) => {
+ this.state.disabledItems = newDisabledItems;
+ browser.localStorage.setItem(
+ "disabled_dashboard_items",
+ JSON.stringify(newDisabledItems),
+ );
+ },
+ });
+ }
+}
+
+class ConfigDialog extends Component {
+ static template = "awesome_dashboard.config";
+ static components = { CheckBox, Dialog };
+
+ static props = {
+ items: Array,
+ close: Function,
+ disabled: Array,
+ onUpdate: Function,
+ };
+
+ setup() {
+ this.items = useState(
+ this.props.items.map((item) => ({
+ ...item,
+ isEnabled: !this.props.disabled.includes(item.id),
+ })),
+ );
+ }
+
+ apply() {
+ const disabledIds = this.items
+ .filter((i) => !i.isEnabled)
+ .map((i) => i.id);
+
+ this.props.onUpdate(disabledIds);
+ this.props.close();
+ }
+
+ onCheck(item, value) {
+ console.log(item, value)
+ item.isEnabled = value;
+ const updatedDisabledItemsList = Object.values(this.items)
+ .filter((item) => !item.isEnabled)
+ .map((item) => item.id);
+
+ browser.localStorage.setItem(
+ "disabled_dashboard_items",
+ updatedDisabledItemsList,
+ );
+
+ this.props.onUpdate(updatedDisabledItemsList);
+ }
+}
+
+registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard);
diff --git a/awesome_dashboard/static/src/dashboard/dashboard.scss b/awesome_dashboard/static/src/dashboard/dashboard.scss
new file mode 100644
index 00000000000..32862ec0d82
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard.scss
@@ -0,0 +1,3 @@
+.o_dashboard {
+ background-color: gray;
+}
diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml
new file mode 100644
index 00000000000..51e490e7843
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item.js b/awesome_dashboard/static/src/dashboard/dashboard_item.js
new file mode 100644
index 00000000000..e3e590364f1
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard_item.js
@@ -0,0 +1,21 @@
+import { Component } from "@odoo/owl";
+import { Layout } from "@web/search/layout";
+
+export class AwesomeDashboardItem extends Component {
+ static components = { Layout };
+ static template = "awesome_dashboard.AwesomeDashboardItem";
+
+ static defaultProps = {
+ size: 1,
+ };
+
+ static props = {
+ size: { type: Number, optional: true },
+ slots: {
+ type: Object,
+ shape: {
+ default: true,
+ },
+ },
+ };
+}
diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item.xml b/awesome_dashboard/static/src/dashboard/dashboard_item.xml
new file mode 100644
index 00000000000..788ff534ac9
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard_item.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/awesome_dashboard/static/src/dashboard/dashboard_items.js b/awesome_dashboard/static/src/dashboard/dashboard_items.js
new file mode 100644
index 00000000000..ea84f5acce2
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard_items.js
@@ -0,0 +1,65 @@
+import { NumberCard } from "./number_card/number_card";
+import { PieChartCard } from "./pie_chart_card/pie_chart_card";
+import {registry} from "@web/core/registry";
+
+const items = [
+ {
+ id: "average_quantity",
+ description: "Average amount of t-shirt",
+ Component: NumberCard,
+ props: (data) => ({
+ title: "Average amount of t-shirt by order this month",
+ value: data.average_quantity,
+ }),
+ },
+ {
+ id: "average_time",
+ description: "Average order processing time",
+ Component: NumberCard,
+ size: 2,
+ props: (data) => ({
+ title: "Average time for an order to go from 'new' to 'sent' or 'cancelled' ",
+ value: data.average_time,
+ }),
+ },
+ {
+ id: "nb_new_orders",
+ description: "Number of new orders",
+ Component: NumberCard,
+ props: (data) => ({
+ title: "Number of new orders this month",
+ value: data.nb_new_orders,
+ }),
+ },
+ {
+ id: "nb_cancelled_orders",
+ description: "Number of cancelled orders",
+ Component: NumberCard,
+ props: (data) => ({
+ title: "Number of cancelled orders this month",
+ value: data.nb_cancelled_orders,
+ }),
+ },
+ {
+ id: "total_amount",
+ description: "Total new orders",
+ Component: NumberCard,
+ props: (data) => ({
+ title: "Total amount of new orders this month",
+ value: data.total_amount,
+ }),
+ },
+ {
+ id: "orders_by_size",
+ description: "Shirt orders by size",
+ Component: PieChartCard,
+ props: (data) => ({
+ title: "Shirt orders by size",
+ data: data.orders_by_size,
+ }),
+ },
+];
+
+items.forEach((item) => {
+ registry.category("awesome_dashboard").add(item.id, item);
+});
diff --git a/awesome_dashboard/static/src/dashboard/number_card/number_card.js b/awesome_dashboard/static/src/dashboard/number_card/number_card.js
new file mode 100644
index 00000000000..0d1ae8deadf
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/number_card/number_card.js
@@ -0,0 +1,9 @@
+import { Component } from "@odoo/owl";
+
+export class NumberCard extends Component {
+ static template = "awesome_dashboard.NumberCard";
+ static props = {
+ title: String,
+ value: Number,
+ };
+}
diff --git a/awesome_dashboard/static/src/dashboard/number_card/number_card.xml b/awesome_dashboard/static/src/dashboard/number_card/number_card.xml
new file mode 100644
index 00000000000..0a18342f386
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/number_card/number_card.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js
new file mode 100644
index 00000000000..25cba9eb5ad
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js
@@ -0,0 +1,86 @@
+import { Component, useEffect, useRef, onWillStart } from "@odoo/owl";
+import { Layout } from "@web/search/layout";
+import { loadJS } from "@web/core/assets";
+
+const D3_COLORS = [
+ "#1f77b4",
+ "#ff7f0e",
+ "#aec7e8",
+ "#ffbb78",
+ "#2ca02c",
+ "#98df8a",
+ "#d62728",
+ "#ff9896",
+ "#9467bd",
+ "#c5b0d5",
+ "#8c564b",
+ "#c49c94",
+ "#e377c2",
+ "#f7b6d2",
+ "#7f7f7f",
+ "#c7c7c7",
+ "#bcbd22",
+ "#dbdb8d",
+ "#17becf",
+ "#9edae5",
+];
+
+export class PieChart extends Component {
+ static components = { Layout };
+ static template = "awesome_dashboard.PieChart";
+
+ static defaultProps = {
+ s: 0,
+ m: 0,
+ l: 0,
+ xl: 0,
+ xxl: 0,
+ };
+
+ setup() {
+ onWillStart(() => loadJS("/web/static/lib/Chart/Chart.js"));
+ this.canvasRef = useRef("canvas");
+ useEffect(() => this.renderChart());
+ }
+
+ destroyChart() {
+ if (this.chart) {
+ this.chart.destroy();
+ }
+ }
+
+ renderChart() {
+ this.destroyChart();
+ const ctx = this.canvasRef.el.getContext("2d");
+ this.chart = new Chart(ctx, this.getChartConfig());
+ }
+
+getChartConfig() {
+ const data = this.props.data || {};
+ const labels = Object.keys(data);
+ const counts = Object.values(data);
+
+ return {
+ type: "pie",
+ data: {
+ labels: labels,
+ datasets: [
+ {
+ data: counts,
+ backgroundColor: labels.map((_, index) => D3_COLORS[index % 20]),
+ hoverOffset: 4
+ },
+ ],
+ },
+ options: {
+ responsive: true,
+ maintainAspectRatio: false,
+ plugins: {
+ legend: {
+ position: 'bottom',
+ }
+ }
+ },
+ };
+}
+}
diff --git a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml
new file mode 100644
index 00000000000..65b8b37895d
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js
new file mode 100644
index 00000000000..3352040539d
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js
@@ -0,0 +1,13 @@
+import { Component } from "@odoo/owl";
+import { PieChart } from "../pie_chart/pie_chart";
+
+export class PieChartCard extends Component {
+ static template = "awesome_dashboard.PieChartCard";
+ static components = {
+ PieChart,
+ };
+ static props = {
+ title: String,
+ data: Object,
+ };
+}
diff --git a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml
new file mode 100644
index 00000000000..064c5263f64
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/awesome_dashboard/static/src/dashboard/statistics_service.js b/awesome_dashboard/static/src/dashboard/statistics_service.js
new file mode 100644
index 00000000000..4b7cb82181f
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/statistics_service.js
@@ -0,0 +1,24 @@
+import { memoize } from "@web/core/utils/functions";
+import { reactive } from "@odoo/owl";
+import { registry } from "@web/core/registry";
+import { rpc } from "@web/core/network/rpc";
+
+const statisticsService = {
+ start() {
+ const stats = reactive({ isReady: false });
+
+ async function loadData() {
+ const res = memoize(() => rpc("/awesome_dashboard/statistics"));
+ Object.assign(stats, res, { isReady: true });
+ }
+
+ setInterval(loadData, 600);
+ loadData();
+
+ return stats;
+ },
+};
+
+registry
+ .category("services")
+ .add("awesome_dashboard.statistics", statisticsService);
diff --git a/awesome_dashboard/static/src/dashboard_loader.js b/awesome_dashboard/static/src/dashboard_loader.js
new file mode 100644
index 00000000000..1212ccf2a5c
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard_loader.js
@@ -0,0 +1,14 @@
+import { LazyComponent } from "@web/core/assets";
+import { Component, xml } from "@odoo/owl";
+import { registry } from "@web/core/registry";
+
+export class AwesomeDashboardLoader extends Component {
+ static components = { LazyComponent };
+ static template = xml`
+
+ `;
+}
+
+registry
+ .category("actions")
+ .add("awesome_dashboard.dashboard", AwesomeDashboardLoader);
diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js
new file mode 100644
index 00000000000..84ccaa5c1bd
--- /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.isOpen = useState({ toggleOpen: true });
+ }
+
+ toggleCard() {
+ this.isOpen.toggleOpen = !this.isOpen.toggleOpen;
+ }
+}
diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml
new file mode 100644
index 00000000000..76f5a132fc8
--- /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..e06375f1f7d
--- /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({ 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..49a6e493140
--- /dev/null
+++ b/awesome_owl/static/src/counter/counter.xml
@@ -0,0 +1,7 @@
+
+
+
+ Counter:
+
+
+
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js
index 4ac769b0aa5..66056e878a9 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 { Card } from "./card/card";
+import { Counter } from "./counter/counter";
+import { TodoList } from "./todo_list/todo_list";
export class Playground extends Component {
static template = "awesome_owl.playground";
+ static components = { Card, Counter, TodoList };
+
+ setup() {
+ this.state = useState({ sum: 2 });
+ }
+
+ value1 = "
some text 1
";
+ value2 = markup("some text 2
");
+
+ incrementSum() {
+ this.state.sum++;
+ }
}
diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml
index 4fb905d59f9..84d530d4504 100644
--- a/awesome_owl/static/src/playground.xml
+++ b/awesome_owl/static/src/playground.xml
@@ -1,10 +1,24 @@
-
+
-
hello world
+
+
+
+
+
+
+ content of card 2
+
+
+
+
+
-
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..281d2a51b61
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_item.js
@@ -0,0 +1,25 @@
+import { Component } 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..b6006ef69bb
--- /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..c0ea0374967
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_list.js
@@ -0,0 +1,40 @@
+import { Component, useState, useRef, onMounted } from "@odoo/owl";
+import { TodoItem } from "./todo_item";
+
+export class TodoList extends Component {
+ static template = "awesome_owl.TodoList";
+ static components = { TodoItem };
+
+ addTodo(ev) {
+ if (ev.keyCode !== 13 || ev.target.value.length === 0) {
+ return
+ }
+ this.todos.push({
+ id: this.count,
+ description: ev.target.value,
+ isCompleted: false
+ });
+ this.count++;
+ }
+
+ setup() {
+ this.todos = useState([]);
+ this.count = 1;
+ this.todoRef = useRef("todo_input")
+ onMounted(() => {
+ this.todoRef.el.focus();
+ });
+ }
+
+ toggleTodoItem(id) {
+ const todoItem = this.todos.find(todo => {
+ return todo.id === id
+ });
+ todoItem.isCompleted = !todoItem.isCompleted;
+ }
+
+ deleteTodoItem(id) {
+ const todoItemIndex = this.todos.findIndex((todo) => todo.id === id);
+ this.todos.splice(todoItemIndex, 1)
+ }
+}
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..933ff634276
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_list.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
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..1da5968ce99
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,17 @@
+{
+ 'name': 'Real Estate',
+ 'version': '1.0',
+ 'depends': ['base'],
+ 'author': 'Anmol Dhaliwal',
+ 'category': 'Category',
+ '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_views.xml',
+ ],
+ 'license': 'OEEL-1',
+}
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..6b4bc2a7a10
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,131 @@
+from odoo import api, fields, models, exceptions
+from dateutil.relativedelta import relativedelta
+from odoo.tools.float_utils import float_compare, float_is_zero
+
+
+class EstateProperty(models.Model):
+ _name = 'estate.property'
+ _description = 'A specific property'
+ _order = 'id desc'
+
+ name = fields.Char('Title', required=True)
+ description = fields.Text()
+ postcode = fields.Char()
+ date_availability = fields.Date(
+ 'Available From',
+ copy=False,
+ default=lambda _: fields.Date.today() + relativedelta(months=3),
+ )
+ expected_price = fields.Float(required=True)
+ _expected_price = models.Constraint(
+ 'CHECK(expected_price > 0)',
+ 'The expected price must be strictly positive.',
+ )
+ selling_price = fields.Float(readonly=True, copy=False)
+ _selling_price = models.Constraint(
+ 'CHECK(expected_price >= 0)',
+ 'The selling price must be positive.',
+ )
+ bedrooms = fields.Integer(default=2)
+ living_area = fields.Integer('Living Area (sqm)')
+ facades = fields.Integer()
+ garage = fields.Boolean()
+ garden = fields.Boolean()
+ garden_area = fields.Integer(string='Garden Area (sqm)')
+ garden_orientation = fields.Selection(
+ string='Garden Orientation',
+ selection=[
+ ('north', 'North'),
+ ('east', 'East'),
+ ('south', 'South'),
+ ('west', 'West'),
+ ],
+ )
+ 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'),
+ ],
+ required=True,
+ copy=False,
+ default='new',
+ )
+ property_type_id = fields.Many2one('estate.property.type', string='Property Type')
+ salesperson_id = fields.Many2one(
+ 'res.users', string='Salesperson', default=lambda self: self.env.uid
+ )
+ 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', string='Offers'
+ )
+ total_area = fields.Integer(
+ compute='_compute_total_area', string='Total Area (sqm)'
+ )
+ best_price = fields.Float(string='Best Price', compute='_compute_best_price')
+
+ @api.depends('living_area', 'garden_area', 'garden')
+ def _compute_total_area(self):
+ for record in self:
+ record.total_area = record.living_area + (
+ record.garden_area if record.garden else 0
+ )
+
+ @api.depends('offer_ids')
+ def _compute_best_price(self):
+ for record in self:
+ record.best_price = (
+ max(record.offer_ids.mapped('price')) if record.offer_ids else 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_sold(self):
+ for record in self:
+ if record.state == 'cancelled':
+ raise exceptions.UserError('A cancelled listing cannot be sold')
+ elif record.state == 'sold':
+ raise exceptions.UserError('This listing has already been sold')
+ else:
+ record.state = 'sold'
+ return True
+
+ def action_cancel(self):
+ for record in self:
+ if record.state == 'sold':
+ raise exceptions.UserError('Sold listings cannot be cancelled')
+ elif record.state == 'cancelled':
+ raise exceptions.UserError('This listing is already cancelled')
+ else:
+ record.state = 'cancelled'
+ return True
+
+ @api.constrains('selling_price', 'expected_price')
+ def _validate_selling_price(self):
+ for record in self:
+ if float_compare(
+ record.selling_price, record.expected_price * 0.9, 2
+ ) == -1 and not float_is_zero(record.selling_price, 2):
+ raise exceptions.ValidationError(
+ 'The selling price must be at least 90%% of the expected price'
+ )
+
+ @api.ondelete(at_uninstall=False)
+ def _check_before_delete(self):
+ for record in self:
+ if record.state not in ('new', 'cancelled'):
+ raise exceptions.UserError(
+ 'A property cannot be deleted unless its state is 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..0beb569417c
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,82 @@
+from odoo import api, exceptions, fields, models
+from dateutil.relativedelta import relativedelta
+from odoo.tools import float_compare
+
+
+class EstatePropertyOffer(models.Model):
+ _name = 'estate.property.offer'
+ _description = 'An offer made on a property'
+ _order = 'price desc'
+
+ price = fields.Float(string='Price')
+ _price = models.Constraint(
+ 'CHECK(price > 0)',
+ 'The offer price must be strictly positive.',
+ )
+ status = fields.Selection(
+ copy=False,
+ selection=[
+ ('accepted', 'Accepted'),
+ ('refused', 'Refused'),
+ ],
+ )
+ 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(string='Validity (days)', default=7)
+ date_deadline = fields.Date(
+ string='Deadline',
+ compute='_compute_date_deadline',
+ inverse='_inverse_date_deadline',
+ )
+ property_type_id = fields.Many2one(
+ 'estate.property.type', related='property_id.property_type_id', store=True
+ )
+
+ @api.depends('validity')
+ def _compute_date_deadline(self):
+ for record in self:
+ record.date_deadline = (
+ (record.create_date + relativedelta(days=record.validity))
+ if record.create_date
+ else (fields.Date.today() + relativedelta(days=record.validity))
+ )
+
+ def _inverse_date_deadline(self):
+ for record in self:
+ record.validity = relativedelta(
+ record.date_deadline,
+ record.create_date if record.create_date else fields.Date.today(),
+ ).days
+
+ def action_accept(self):
+ for record in self:
+ for offer in record.property_id.offer_ids:
+ if offer.status == 'accepted':
+ raise exceptions.UserError(
+ 'An offer has already been accepted for this property'
+ )
+ else:
+ record.status = 'accepted'
+ record.property_id.state = 'offer_accepted'
+ record.property_id.buyer_id = record.partner_id
+ record.property_id.selling_price = record.price
+ return True
+
+ def action_refuse(self):
+ for record in self:
+ record.status = 'refused'
+ return True
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ for val in vals_list:
+ property_for_offer = self.env['estate.property'].browse(val['property_id'])
+ if float_compare(val['price'], property_for_offer.best_price, 2) == -1:
+ raise exceptions.UserError(
+ 'New offers cannot be lower than existing offers'
+ )
+ property_for_offer.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..d6023c2bc55
--- /dev/null
+++ b/estate/models/estate_property_tag.py
@@ -0,0 +1,11 @@
+from odoo import fields, models
+
+
+class EstatePropertyType(models.Model):
+ _name = 'estate.property.tag'
+ _description = 'A property tag'
+ _order = 'name'
+
+ name = fields.Char(string='Tag Name', required=True)
+ _unique_name = models.Constraint('UNIQUE(name)', 'The name must be unique.')
+ color = fields.Integer()
diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py
new file mode 100644
index 00000000000..1a4d6510ca6
--- /dev/null
+++ b/estate/models/estate_property_type.py
@@ -0,0 +1,21 @@
+from odoo import api, fields, models
+
+
+class EstatePropertyType(models.Model):
+ _name = 'estate.property.type'
+ _description = 'A type of property'
+ _order = 'sequence asc'
+
+ name = fields.Char(string='Title', required=True)
+ _unique_name = models.Constraint('UNIQUE(name)', 'The name must be unique.')
+ property_ids = fields.One2many(
+ 'estate.property', 'property_type_id', string='Properties'
+ )
+ 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..a59fda82478
--- /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='Property',
+ 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..0b5f1d26656
--- /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_property_user,estate_property_user,model_estate_property,base.group_user,1,1,1,1
+estate_property_type_user,estate_property_type_user,model_estate_property_type,base.group_user,1,1,1,1
+estate_property_tag_user,estate_property_tag_user,model_estate_property_tag,base.group_user,1,1,1,1
+estate_property_offer_user,estate_property_offer_user,model_estate_property_offer,base.group_user,1,1,1,1
diff --git a/estate/views/estate_list_views.xml b/estate/views/estate_list_views.xml
new file mode 100644
index 00000000000..6fa84137e47
--- /dev/null
+++ b/estate/views/estate_list_views.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml
new file mode 100644
index 00000000000..802df407e49
--- /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..c2fc871bd4d
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,48 @@
+
+
+
+ View Property Offers
+ estate.property.offer
+ list,form
+ [('property_type_id', '=', active_id)]
+
+
+
+ estate.property.offer.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.offer.form
+ 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..313abed2489
--- /dev/null
+++ b/estate/views/estate_property_tag_views.xml
@@ -0,0 +1,19 @@
+
+
+
+ View Property Tags
+ estate.property.tag
+ list,form
+
+
+
+ Property Tags
+ 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..ed4ac43cb95
--- /dev/null
+++ b/estate/views/estate_property_type_views.xml
@@ -0,0 +1,58 @@
+
+
+
+ View Property Types
+ estate.property.type
+ list,form
+
+
+
+ estate.property.type.list
+ estate.property.type
+
+
+
+
+
+
+
+
+
+ estate.property.type.form
+ estate.property.type
+
+
+
+
+
+
+ estate.property.type.search
+ 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..857b048653a
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,140 @@
+
+
+
+ View Properties
+ estate.property
+ list,form,kanban
+ {'search_default_available_properties': 1}
+
+
+
+ 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..b73a5fae7d3
--- /dev/null
+++ b/estate/views/res_users_views.xml
@@ -0,0 +1,15 @@
+
+
+
+ res.users.view.form
+ 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..a531e7d3d37
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,9 @@
+{
+ 'name': 'Real Estate Accounting',
+ 'version': '1.0',
+ 'depends': ['base', 'estate', 'account'],
+ 'author': 'Anmol Dhaliwal',
+ 'category': 'Category',
+ 'data': [],
+ 'license': 'OEEL-1',
+}
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..4a12ba6c068
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,34 @@
+from odoo import Command, models
+
+
+class EstateProperty(models.Model):
+ _inherit = 'estate.property'
+
+ def action_sold(self):
+ self.env['account.move'].create(
+ {
+ 'move_type': 'out_invoice',
+ 'partner_id': self.buyer_id.id,
+ 'invoice_line_ids': [
+ Command.create(
+ {
+ 'name': 'Down Payment',
+ 'quantity': 1,
+ 'price_unit': self.selling_price * 0.06,
+ }
+ ),
+ Command.create(
+ {
+ 'name': 'Administrative Fees',
+ 'quantity': 1,
+ 'price_unit': 100.00,
+ }
+ ),
+ ],
+ }
+ )
+ res = super().action_sold()
+ return res
+
+ def _create_invoices(self):
+ pass