diff --git a/awesome_dashboard/__manifest__.py b/awesome_dashboard/__manifest__.py
index a1cd72893d7..f7c3c507aed 100644
--- a/awesome_dashboard/__manifest__.py
+++ b/awesome_dashboard/__manifest__.py
@@ -25,6 +25,9 @@
'web.assets_backend': [
'awesome_dashboard/static/src/**/*',
],
+ 'awesome_dashboard.dashboard': [
+ 'awesome_dashboard/static/src/dashboard/**/*'
+ ]
},
'license': 'AGPL-3'
}
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..f89821384c0
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard.js
@@ -0,0 +1,102 @@
+import { Component, useState } from "@odoo/owl";
+import { registry } from "@web/core/registry";
+import { Layout } from "@web/search/layout";
+import { useService } from "@web/core/utils/hooks";
+import { DashboardItem } from "./dashboard_item/dashboard_item";
+import { Dialog } from "@web/core/dialog/dialog";
+import { CheckBox } from "@web/core/checkbox/checkbox";
+import { browser } from "@web/core/browser/browser";
+import "./statistics_service"; // ← add this
+import "./dashboard_items"; // ← add this ← THIS IS THE FIX
+
+class AwesomeDashboard extends Component {
+ static template = "awesome_dashboard.AwesomeDashboard";
+ static components = { Layout, DashboardItem };
+
+ setup() {
+ this.action = useService("action");
+ this.dialog = useService("dialog");
+ this.display = { controlPanel: {} };
+ this.stats = useService("awesome_dashboard.statistics");
+
+ this.state = useState({
+ disabledItems: JSON.parse(
+ browser.localStorage.getItem("disabledDashboardItems") || "[]"
+ )
+ });
+
+ this.allItems = registry
+ .category("awesome_dashboard.items")
+ .getAll();
+ }
+
+ get items() {
+ return this.allItems.filter(
+ item => !this.state.disabledItems.includes(item.id)
+ );
+ }
+
+ openConfiguration() {
+ this.dialog.add(ConfigurationDialog, {
+ items: this.allItems,
+ disabledItems: this.state.disabledItems,
+ onUpdate: this.updateConfiguration.bind(this),
+ });
+ }
+
+ updateConfiguration(newDisabledItems) {
+ this.state.disabledItems = newDisabledItems;
+ browser.localStorage.setItem(
+ "disabledDashboardItems",
+ JSON.stringify(newDisabledItems)
+ );
+ }
+
+ 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, "list"], [false, "form"]],
+ });
+ }
+}
+
+class ConfigurationDialog extends Component {
+ static template = "awesome_dashboard.ConfigurationDialog";
+ static components = { Dialog, CheckBox };
+ static props = ["close", "items", "disabledItems", "onUpdate"];
+
+ setup() {
+ const disabled = Array.isArray(this.props.disabledItems)
+ ? this.props.disabledItems
+ : [];
+
+ this.items = useState(
+ this.props.items.map(item => ({
+ ...item,
+ enabled: !disabled.includes(item.id),
+ }))
+ );
+ }
+
+ onChange(checked, item) {
+ item.enabled = checked;
+ const disabled = this.items
+ .filter(i => !i.enabled)
+ .map(i => i.id);
+ this.props.onUpdate(disabled);
+ }
+
+ done() {
+ this.props.close();
+ }
+}
+
+registry
+ .category("lazy_components")
+ .add("awesome_dashboard.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..ecdd85b5210
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard.scss
@@ -0,0 +1,3 @@
+.o_dashboard {
+ background-color: rgb(16, 18, 20);
+}
\ No newline at end of file
diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml
new file mode 100644
index 00000000000..b67ba1eecc0
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.js b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.js
new file mode 100644
index 00000000000..818c69c580f
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.js
@@ -0,0 +1,9 @@
+import { Component } from "@odoo/owl";
+
+export class DashboardItem extends Component {
+ static template = "awesome_dashboard.DashboardItem";
+
+ static slots = {
+ default: {},
+ };
+}
diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.xml b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.xml
new file mode 100644
index 00000000000..18367dea592
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
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..2edfb5b04b6
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard_items.js
@@ -0,0 +1,70 @@
+import { dashboardItemRegistry } from "./dashboard_registry";
+import { NumberCard } from "./number_card/number_card";
+import { PieChartCard } from "./pie_chart_card/pie_chart_card";
+import { _t } from "@web/core/l10n/translation";
+
+dashboardItemRegistry.add("avg_quantity", {
+ id: "avg_quantity",
+ description: _t("Average amount of t-shirt"),
+ Component: NumberCard,
+ size: 1,
+ props: (data) => ({
+ title: _t("Average amount of t-shirt by order this month"),
+ value: data?.average_quantity || 0,
+ }),
+});
+
+dashboardItemRegistry.add("average_time", {
+ id: "average_time",
+ description: _t("Average time new to sent/cancelled"),
+ Component: NumberCard,
+ size: 1,
+ props: (data) => ({
+ title: _t("Average time for an order to go from 'new' to 'sent' or 'cancelled'"),
+ value: data?.average_time || 0,
+ }),
+});
+
+dashboardItemRegistry.add("new_orders", {
+ id: "new_orders",
+ description: _t("New orders this month"),
+ Component: NumberCard,
+ size: 1,
+ props: (data) => ({
+ title: _t("Number of new orders this month"),
+ value: data?.nb_new_orders || 0,
+ }),
+});
+
+dashboardItemRegistry.add("nb_cancelled_orders", {
+ id: "nb_cancelled_orders",
+ description: _t("Cancelled orders this month"),
+ Component: NumberCard,
+ size: 1,
+ props: (data) => ({
+ title: _t("Number of cancelled orders this month"),
+ value: data?.nb_cancelled_orders || 0,
+ }),
+});
+
+dashboardItemRegistry.add("total_amount", {
+ id: "total_amount",
+ description: _t("Total amount orders this month"),
+ Component: NumberCard,
+ size: 1,
+ props: (data) => ({
+ title: _t("Total amount of new orders this month"),
+ value: data?.total_amount || 0,
+ }),
+});
+
+dashboardItemRegistry.add("pie_chart", {
+ id: "pie_chart",
+ description: _t("Shirt orders by size"),
+ Component: PieChartCard,
+ size: 2,
+ props: (data) => ({
+ title: _t("Shirt orders by size"),
+ data: data?.orders_by_size || {},
+ }),
+});
diff --git a/awesome_dashboard/static/src/dashboard/dashboard_registry.js b/awesome_dashboard/static/src/dashboard/dashboard_registry.js
new file mode 100644
index 00000000000..e3fe596f7ad
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/dashboard_registry.js
@@ -0,0 +1,3 @@
+import { registry } from "@web/core/registry";
+
+export const dashboardItemRegistry = registry.category("awesome_dashboard.items");
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..95cc39c8b33
--- /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: { type: Number, optional: true },
+ };
+}
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..6a3a97a9566
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/number_card/number_card.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
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..4fb8c3bacaa
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js
@@ -0,0 +1,34 @@
+import { Component, onWillStart, onMounted, useRef } from "@odoo/owl";
+import { loadJS } from "@web/core/assets";
+
+export class PieChart extends Component {
+ static template = "awesome_dashboard.PieChart";
+
+ static props = {
+ data: Object,
+ };
+
+ setup() {
+ this.canvasRef = useRef("chart");
+ onWillStart(async () => {
+ await loadJS("/web/static/lib/Chart/Chart.js");
+ });
+ onMounted(() => {
+ this.renderChart();
+ });
+ }
+
+ renderChart() {
+ const ctx = this.canvasRef.el.getContext("2d");
+
+ new Chart(ctx, {
+ type: "pie",
+ data: {
+ labels: Object.keys(this.props.data),
+ datasets: [{
+ data: Object.values(this.props.data),
+ }],
+ },
+ });
+ }
+}
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..e2f0b4e1ec8
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
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..23aa93ec2c3
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js
@@ -0,0 +1,11 @@
+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..cd52b55e2bb
--- /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..0b08c20b4ec
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard/statistics_service.js
@@ -0,0 +1,24 @@
+import { registry } from "@web/core/registry";
+import { rpc } from "@web/core/network/rpc";
+import { reactive } from "@odoo/owl";
+
+const statisticsService = {
+ name: "awesome_dashboard.statistics",
+
+ start() {
+ const stats = reactive({});
+
+ async function loadStatistics() {
+ const data = await rpc("/awesome_dashboard/statistics");
+ Object.assign(stats, data);
+ }
+
+ loadStatistics();
+ setInterval(loadStatistics, 10 * 60 * 1000);
+ return stats;
+ },
+};
+
+registry
+ .category("services")
+ .add("awesome_dashboard.statistics", statisticsService);
diff --git a/awesome_dashboard/static/src/dashboard_action.js b/awesome_dashboard/static/src/dashboard_action.js
new file mode 100644
index 00000000000..52decad3f86
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard_action.js
@@ -0,0 +1,10 @@
+import { Component } from "@odoo/owl";
+import { LazyComponent } from "@web/core/assets";
+import { registry } from "@web/core/registry";
+
+export class DashboardAction extends Component {
+ static components = { LazyComponent };
+ static template = "awesome_dashboard.DashboardLoader";
+}
+
+registry.category("actions").add("awesome_dashboard.dashboard", DashboardAction);
diff --git a/awesome_dashboard/static/src/dashboard_action.xml b/awesome_dashboard/static/src/dashboard_action.xml
new file mode 100644
index 00000000000..5beaede125b
--- /dev/null
+++ b/awesome_dashboard/static/src/dashboard_action.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/awesome_owl/__init__.py b/awesome_owl/__init__.py
index 457bae27e11..b0f26a9a602 100644
--- a/awesome_owl/__init__.py
+++ b/awesome_owl/__init__.py
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
-from . import controllers
\ No newline at end of file
+from . import controllers
diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js
new file mode 100644
index 00000000000..5531a5f581c
--- /dev/null
+++ b/awesome_owl/static/src/card/card.js
@@ -0,0 +1,18 @@
+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 });
+ }
+
+ toggleContent() {
+ this.state.isOpen = !this.state.isOpen;
+ }
+}
diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml
new file mode 100644
index 00000000000..f62a7fcbaf9
--- /dev/null
+++ b/awesome_owl/static/src/card/card.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js
new file mode 100644
index 00000000000..1d6c0c5a0a8
--- /dev/null
+++ b/awesome_owl/static/src/counter/counter.js
@@ -0,0 +1,20 @@
+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(this.state.value);
+ }
+ }
+}
diff --git a/awesome_owl/static/src/counter/counter.xml b/awesome_owl/static/src/counter/counter.xml
new file mode 100644
index 00000000000..6c58b742189
--- /dev/null
+++ b/awesome_owl/static/src/counter/counter.xml
@@ -0,0 +1,8 @@
+
+
+
+ Counter:
+
+
+
+
diff --git a/awesome_owl/static/src/main.js b/awesome_owl/static/src/main.js
index 1aaea902b55..6c108687e29 100644
--- a/awesome_owl/static/src/main.js
+++ b/awesome_owl/static/src/main.js
@@ -9,4 +9,3 @@ const config = {
// Mount the Playground component when the document.body is ready
whenReady(() => mountComponent(Playground, document.body, config));
-
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js
index 4ac769b0aa5..77b0ae5f35a 100644
--- a/awesome_owl/static/src/playground.js
+++ b/awesome_owl/static/src/playground.js
@@ -1,5 +1,19 @@
-import { Component } from "@odoo/owl";
+import { Component, useState, markup } from "@odoo/owl";
+import { Counter } from "./counter/counter";
+import { Card } from "./card/card";
+import { TodoList } from "./todo_list/todo_list";
export class Playground extends Component {
- static template = "awesome_owl.playground";
+ static template = "awesome_owl.Playground";
+ static components = { Counter, Card, TodoList };
+
+ setup() {
+ this.state = useState({ sum: 0 });
+ this.str1 = markup("
some content
");
+ // this.str2 = "This is a card"
+ }
+
+ incrementSum() {
+ this.state.sum++;
+ }
}
diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml
index 4fb905d59f9..18d41871132 100644
--- a/awesome_owl/static/src/playground.xml
+++ b/awesome_owl/static/src/playground.xml
@@ -1,10 +1,24 @@
-
-
-
+
- hello world
+
hello world
+
+
+
+
The sum is:
+
+
+
+
+
+
+
+
+
+
+
+
+
-
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..a834d1cd87f
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_item.js
@@ -0,0 +1,16 @@
+import { Component } from "@odoo/owl";
+
+export class TodoItem extends Component {
+ static template = "awesome_owl.TodoItem";
+
+ static props = {
+ todo: {
+ type: Object,
+ shape: {
+ id: Number, description: String, isCompleted: Boolean,
+ },
+ },
+ toggleState: { type: Function },
+ removeTodo: { type: Function },
+ };
+}
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..3a57a140e56
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_item.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ .
+
+
+
+
+
+
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..4cfab5b092e
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_list.js
@@ -0,0 +1,44 @@
+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 };
+
+ setup() {
+ this.todos = useState([]);
+ this.nextId = 1;
+ this.inputRef = useRef("todoInput");
+
+ onMounted(() => {
+ this.inputRef.el.focus();
+ });
+ }
+
+ addTodo(ev) {
+ if (ev.keyCode === 13) {
+ const description = ev.target.value.trim();
+ if (!description) return;
+ this.todos.push({
+ id: this.nextId++,
+ description: description,
+ isCompleted: false,
+ });
+ ev.target.value = "";
+ }
+ }
+
+ toggleState(todoId) {
+ const todo = this.todos.find(t => t.id === todoId);
+ if (todo) {
+ todo.isCompleted = !todo.isCompleted;
+ }
+ }
+
+ removeTodo(todoId) {
+ const index = this.todos.findIndex(t => t.id === todoId);
+ if (index >= 0) {
+ this.todos.splice(index, 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..045e7356aff
--- /dev/null
+++ b/awesome_owl/static/src/todo_list/todo_list.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
Todo List
+
+
+
+
+
+
+
+
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js
new file mode 100644
index 00000000000..f452f103aa0
--- /dev/null
+++ b/awesome_owl/static/src/utils.js
@@ -0,0 +1,8 @@
+import { useRef, onMounted } from "@odoo/owl";
+
+export function useAutofocus(refName) {
+ const ref = useRef(refName);
+ onMounted(() => {
+ ref.el.focus();
+ });
+}
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..92077c9d555
--- /dev/null
+++ b/estate/__manifest__.py
@@ -0,0 +1,23 @@
+{
+ 'name': 'Real Estate',
+ 'author': 'Aditi (adpaw)',
+ 'license': 'LGPL-3',
+ 'depends': [
+ 'base', 'calendar', 'mail'
+ ],
+ 'data': [
+ 'security/estate_security.xml',
+ 'security/ir.model.access.csv',
+ 'data/mail_template.xml',
+ 'views/estate_property_visit_views.xml',
+ 'views/estate_property_tags_views.xml',
+ 'views/estate_property_offer_views.xml',
+ 'views/estate_property_types_views.xml',
+ 'views/estate_property_issues_views.xml',
+ 'views/res_user.xml',
+ 'views/estate_property_views.xml',
+ 'views/estate_property_menus.xml',
+ ],
+ 'installable': True,
+ 'application': True,
+}
diff --git a/estate/data/mail_template.xml b/estate/data/mail_template.xml
new file mode 100644
index 00000000000..7dba1f6dd73
--- /dev/null
+++ b/estate/data/mail_template.xml
@@ -0,0 +1,20 @@
+
+
+
+ Estate: Property sold Confirmation
+
+ Property Sold: {{ object.name }}
+ {{ (object.salesperson_id.email_formatted or object.buyer_id.email_formatted)}}
+ {{ (object.salesperson_id.partner_id.id or object.buyer_id.id) }}
+
+
+
+
Property: Property Name
+
Salesperson: Salesperson
+
Price: 0.00
+
Description: Description
+
+
+
+
+
diff --git a/estate/models/__init__.py b/estate/models/__init__.py
new file mode 100644
index 00000000000..8bce8ee65fb
--- /dev/null
+++ b/estate/models/__init__.py
@@ -0,0 +1,7 @@
+from . import estate_property
+from . import estate_property_types
+from . import estate_property_tags
+from . import estate_property_offer
+from . import estate_property_visit
+from . import estate_property_issues
+from . import res_users
diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py
new file mode 100644
index 00000000000..9d715d144ae
--- /dev/null
+++ b/estate/models/estate_property.py
@@ -0,0 +1,189 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError, ValidationError
+from odoo.tools import float_compare, float_is_zero
+
+
+class EstateProperty(models.Model):
+ _name = 'estate.property'
+ _description = "Real Estate Property"
+ _inherit = 'mail.thread'
+ _order = 'id desc'
+
+ name = fields.Char(required=True)
+ description = fields.Text()
+ postcode = fields.Char()
+ date_availability = fields.Date(copy=False, default=lambda self: 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(string="living area(sqm)")
+ facades = fields.Integer()
+ active = fields.Boolean(default=True)
+ garage = fields.Boolean()
+ garden = fields.Boolean()
+ garden_area = fields.Integer(string="Garden area(sqm)")
+ garden_orientation = fields.Selection(
+ string="Orientation",
+ selection=[
+ ('north', "North"), ('south', "South"), ('east', "East"), ('west', "West")],
+ help="Direction the garden faces"
+ )
+ tag_ids = fields.Many2many('estate.property.tag', compute='_dynamic_tag_ids', string="Tags")
+ 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)
+ state = fields.Selection(
+ selection=[
+ ('new', "New"),
+ ('offer_received', "Offer Received"),
+ ("offer_accepted", "Offer Accepted"),
+ ('sold', "Sold"),
+ ('cancelled', "Cancelled"),
+ ],
+ string="Status",
+ required=True,
+ copy=False,
+ default="new",
+ tracking=2
+ )
+ total_area = fields.Float(string="Total Area (sqm)", compute="_compute_total_area")
+ best_price = fields.Float(string="Best Offer", compute="_compute_best_price")
+ offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers", copy=True)
+ issue_ids = fields.One2many('estate.property.issues', 'property_id')
+ sold_date = fields.Date()
+ sold_within = fields.Integer(string='Sold Within (Days)', compute='_compute_sold_within', store=True)
+ has_suspicious_offers = fields.Boolean(string="Has Suspicious Offers", compute="_compute_has_suspicious_offers", store=False)
+ visit_ids = fields.One2many('estate.property.visit', 'property_id', string="Visits")
+ visit_count = fields.Integer(string="Visit Count", compute='_compute_visit_count')
+
+ _check_expected_price = models.Constraint(
+ 'CHECK(expected_price > 0)',
+ "The expected price must be strictly positive."
+ )
+ _check_selling_price_positive = 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:
+ if record.offer_ids:
+ record.best_price = max(record.offer_ids.mapped("price"))
+ else:
+ record.best_price = 0.0
+
+ @api.depends('expected_price', 'offer_ids', 'sold_within')
+ def _dynamic_tag_ids(self):
+ all_tags = self.env['estate.property.tag'].search([('name', 'in', ('High Value', 'Quick Sale', 'Low Interest'))])
+
+ if 'High Value' not in all_tags.mapped('name'):
+ all_tags |= self.env['estate.property.tag'].create({'name': 'High Value'})
+ if 'Low Interest' not in all_tags.mapped('name'):
+ all_tags |= self.env['estate.property.tag'].create({'name': 'Low Interest'})
+ if 'Quick Sale' not in all_tags.mapped('name'):
+ all_tags |= self.env['estate.property.tag'].create({'name': 'Quick Sale'})
+
+ high_value_tag = all_tags.filtered(lambda t: t.name == 'High Value')
+ low_interest_tag = all_tags.filtered(lambda t: t.name == 'Low Interest')
+ quick_sale_tag = all_tags.filtered(lambda t: t.name == 'Quick Sale')
+
+ for record in self:
+ tags_to_add = self.env['estate.property.tag']
+ if record.expected_price > 1000:
+ tags_to_add |= high_value_tag
+ if len(record.offer_ids) < 2:
+ tags_to_add |= low_interest_tag
+ if record.sold_within and record.sold_within <= 10:
+ tags_to_add |= quick_sale_tag
+ record.tag_ids = [(6, 0, tags_to_add.ids)]
+
+ @api.depends('sold_date', 'create_date')
+ def _compute_sold_within(self):
+ for record in self:
+ if record.sold_date and record.create_date:
+ record.sold_within = (record.sold_date - record.create_date.date()).days
+ else:
+ record.sold_within = 0
+
+ @api.depends('offer_ids.suspicious_offer')
+ def _compute_has_suspicious_offers(self):
+ for record in self:
+ record.has_suspicious_offers = any(offer.suspicious_offer for offer in record.offer_ids)
+
+ @api.depends('visit_ids')
+ def _compute_visit_count(self):
+ for record in self:
+ record.visit_count = len(record.visit_ids)
+
+ @api.constrains('selling_price', 'expected_price')
+ def _check_selling_price(self):
+ for record in self:
+ if float_is_zero(record.selling_price, precision_digits=2):
+ continue
+ if float_compare(
+ record.selling_price,
+ record.expected_price * 0.90,
+ precision_digits=2
+ ) < 0:
+ raise ValidationError(
+ "The selling price cannot be lower than 90% of the expected price."
+ )
+
+ @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.ondelete(at_uninstall=False)
+ def _check_state_before_delete(self):
+ for property in self:
+ if property.state not in ('new', 'cancelled'):
+ raise UserError(
+ "You cannot delete a property that is not 'New' or 'Cancelled'."
+ )
+
+ def action_sold(self):
+ for record in self:
+ if any(i.issue_state != 'resolved' and i.priority == 'high' for i in record.issue_ids):
+ raise UserError("Cannot sell! Property has unresolved high-priority issues.")
+ if not any(offer.status == 'accepted' for offer in record.offer_ids):
+ raise UserError("You cannot sell a property without an accepted offer!")
+ if record.state == 'cancelled':
+ raise UserError("Cancelled properties cannot be sold!")
+ record.state = 'sold'
+ record.sold_date = fields.Date.today()
+
+ template_id = self.env.ref('estate.mail_template_sold_confirmation', raise_if_not_found=False)
+ ctx = {
+ 'default_model': 'estate.property',
+ 'default_res_ids': self.ids,
+ 'force_email': True,
+ 'default_template_id': template_id.id,
+ }
+
+ action = {
+ 'name': ('Sold'),
+ 'type': 'ir.actions.act_window',
+ 'view_mode': 'form',
+ 'res_model': 'mail.compose.message',
+ 'target': 'new',
+ 'context': ctx,
+ }
+ return action
+
+ def action_cancel(self):
+ for record in self:
+ if record.state == 'sold':
+ raise UserError("Sold properties cannot be cancelled!")
+ record.state = 'cancelled'
+ return True
diff --git a/estate/models/estate_property_issues.py b/estate/models/estate_property_issues.py
new file mode 100644
index 00000000000..c12fe7146ab
--- /dev/null
+++ b/estate/models/estate_property_issues.py
@@ -0,0 +1,79 @@
+from datetime import timedelta
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+
+
+class EstatepropertyIssues(models.Model):
+ _name = 'estate.property.issues'
+ _description = 'Property Issues'
+
+ name = fields.Char(required=True, string="Issue")
+ property_id = fields.Many2one('estate.property', string="Property")
+ reported_by = fields.Many2one('res.partner', string="Reported By")
+ assigned_to = fields.Many2one('res.users', string="Assigned To")
+ issue_type = fields.Selection(
+ selection=[
+ ('plumbing', "Plumbing"), ('electrical', "Electrical"),
+ ('structural', "Structural"), ('other', "Other")],
+ required=True
+ )
+ issue_state = fields.Selection(
+ selection=[
+ ('new', "New"),
+ ('in progress', "In Progress"),
+ ('resolved', "Resolved"),
+ ('cancelled', "Cancelled")
+ ],
+ default='new',
+ string="Status"
+ )
+ priority = fields.Selection(
+ selection=[
+ ('low', "Low"),
+ ('medium', "Medium"),
+ ('high', "High")],
+ readonly=True,
+ compute='_compute_priority',
+ store=True
+ )
+ reported_date = fields.Date(string="When reported", default=lambda self: fields.Date.today())
+ resolved_date = fields.Date(readonly=True)
+ description = fields.Text()
+ is_overdue = fields.Boolean(compute='_compute_is_overdue')
+
+ @api.depends('issue_type')
+ def _compute_priority(self):
+ if self.issue_type == 'other':
+ self.priority = 'low'
+ if self.issue_type == 'structural':
+ self.priority = 'high'
+ if self.issue_type in ('plumbing', 'electrical'):
+ self.priority = 'medium'
+
+ @api.depends('reported_date', 'priority', 'issue_state')
+ def _compute_is_overdue(self):
+ for record in self:
+ if record.issue_state in ('resolved', 'cancelled'):
+ record.is_overdue = False
+ continue
+ days = {'high': 2, 'medium': 5, 'low': 10}.get(record.priority, 0)
+ deadline = record.reported_date + timedelta(days=days)
+ record.is_overdue = fields.Date.today() > deadline
+
+ @api.onchange('assigned_to')
+ def _onchange_assigned_to(self):
+ if self.assigned_to:
+ self.issue_state = 'in progress'
+
+ def action_resolve(self):
+ for record in self:
+ if record.issue_state == 'cancelled':
+ raise UserError("Cancelled issues cannot be resolved!")
+ record.issue_state = "resolved"
+ record.resolved_date = fields.Date.today()
+ return True
+
+ def action_cancel(self):
+ for record in self:
+ record.issue_state = 'cancelled'
+ return True
diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py
new file mode 100644
index 00000000000..dee5838e7c4
--- /dev/null
+++ b/estate/models/estate_property_offer.py
@@ -0,0 +1,103 @@
+from datetime import timedelta
+
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+
+
+class EstatepropertyOffer(models.Model):
+ _name = 'estate.property.offer'
+ _description = "Property Offers"
+ _order = 'price desc'
+
+ price = fields.Float()
+ 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)
+ property_type_id = fields.Many2one(related="property_id.property_type_id", string="Property Type", store=True)
+ validity = fields.Integer(string="Validity (days)", default=7)
+ date_deadline = fields.Date(string="Deadline", compute="_compute_date_deadline", inverse="_inverse_date_deadline")
+ suspicious_offer = fields.Boolean(string="Suspicious Offer", compute="_compute_is_suspicious_offer", store=False)
+
+ _check_offer_price = models.Constraint(
+ 'CHECK(price > 0)',
+ 'The offer price must be strictly positive.'
+ )
+
+ @api.depends("validity", "create_date")
+ 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
+ )
+ else:
+ record.date_deadline = fields.Date.add(
+ fields.Date.today(), days=record.validity
+ )
+
+ def _inverse_date_deadline(self):
+ for record in self:
+ if record.create_date and record.date_deadline:
+ record.validity = (
+ record.date_deadline - record.create_date.date()
+ ).days
+
+ @api.depends('partner_id', 'create_date')
+ def _compute_is_suspicious_offer(self):
+ all_offers = self.env['estate.property.offer'].search([])
+
+ for record in self:
+ if record.create_date:
+ same_partner = all_offers.filtered(lambda offer: offer.partner_id == record.partner_id)
+
+ def within_5_mins(offer):
+ if offer.create_date:
+ diff = abs(offer.create_date - record.create_date)
+ return diff <= timedelta(minutes=5)
+
+ suspicious_window = same_partner.filtered(within_5_mins)
+ record.suspicious_offer = len(suspicious_window) >= 3
+ else:
+ record.suspicious_offer = False
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ for vals in vals_list:
+ property_id = vals.get('property_id')
+ if not property_id:
+ continue
+ estate_property = self.env['estate.property'].browse(property_id)
+ if estate_property.offer_ids:
+ max_existing_offer = max(estate_property.offer_ids.mapped('price'))
+ if vals.get('price', 0) < max_existing_offer:
+ raise UserError(
+ f"Your offer ({vals.get('price')}) is lower than "
+ f"an existing offer ({max_existing_offer}). Please raise your offer."
+ )
+ estate_property.state = 'offer_received'
+ return super().create(vals_list)
+
+ def action_accept(self):
+ if self.env.user.has_group('estate.group_estate_agent'):
+ raise UserError("Agents can add offers but cannot accept them.")
+ for record in self:
+ if record.property_id.state == 'sold':
+ raise UserError("This property is already sold!")
+ if 'accepted' in record.property_id.offer_ids.mapped('status'):
+ raise UserError("An offer has already been accepted!")
+ record.status = 'accepted'
+ record.property_id.selling_price = record.price
+ record.property_id.buyer_id = record.partner_id
+ record.property_id.state = 'offer_accepted'
+
+ for offer in record.property_id.offer_ids:
+ if offer.id != record.id:
+ offer.status = "refused"
+ return True
+
+ def action_refuse(self):
+ if self.env.user.has_group('estate.group_estate_agent'):
+ raise UserError("Agents can add offers but cannot refuse them.")
+ for record in self:
+ record.status = 'refused'
+ return True
diff --git a/estate/models/estate_property_tags.py b/estate/models/estate_property_tags.py
new file mode 100644
index 00000000000..413d09a0332
--- /dev/null
+++ b/estate/models/estate_property_tags.py
@@ -0,0 +1,15 @@
+from odoo import fields, models
+
+
+class EstatePropertyTags(models.Model):
+ _name = 'estate.property.tag'
+ _description = "Property Tags"
+ _order = 'name'
+
+ name = fields.Char(required=True)
+ color = fields.Integer(string="Color")
+
+ _unique_name = models.Constraint(
+ 'UNIQUE(name)',
+ 'A property tag with this name already exists.'
+ )
diff --git a/estate/models/estate_property_types.py b/estate/models/estate_property_types.py
new file mode 100644
index 00000000000..7a3b3c8a6f5
--- /dev/null
+++ b/estate/models/estate_property_types.py
@@ -0,0 +1,23 @@
+from odoo import api, fields, models
+
+
+class EstatePropertyType(models.Model):
+ _name = 'estate.property.type'
+ _description = "Property Type"
+ _order = 'sequence, name'
+
+ name = fields.Char(required=True)
+ sequence = fields.Integer('Sequence', default=1, help="Used to order stages. Lower is better.")
+ 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(string="Offer Count", compute='_compute_offer_count')
+
+ _unique_name = models.Constraint(
+ 'UNIQUE(name)',
+ 'A property type with this name already exists.'
+ )
+
+ @api.depends('offer_ids.price')
+ def _compute_offer_count(self):
+ for record in self:
+ record.offer_count = len(record.offer_ids)
diff --git a/estate/models/estate_property_visit.py b/estate/models/estate_property_visit.py
new file mode 100644
index 00000000000..e50e86abab4
--- /dev/null
+++ b/estate/models/estate_property_visit.py
@@ -0,0 +1,38 @@
+from datetime import timedelta
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+
+
+class EstatepropertyVisit(models.Model):
+ _name = 'estate.property.visit'
+ _description = "Property Visits"
+
+ property_id = fields.Many2one("estate.property")
+ buyer_id = fields.Many2one("res.partner", required=True)
+ visit_date = fields.Datetime(string="Visit Date")
+ stop_date = fields.Datetime(string="Stop date")
+ state = fields.Selection(selection=[
+ ('Scheduled', "Scheduled"),
+ ('Done', "Done")
+ ],
+ default="Scheduled")
+
+ @api.constrains('visit_date', 'property_id')
+ def _check_visit_time(self):
+ for record in self:
+ for visit in record.property_id.visit_ids:
+ if record.id == visit.id or record.visit_date.date() != visit.visit_date.date():
+ continue
+ if record.visit_date - visit.visit_date < timedelta(hours=1):
+ raise UserError("Visit alredy scheduled for this time-slot!!")
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ records = super().create(vals_list)
+ for record in records:
+ self.env['calendar.event'].create({
+ 'name': f'Visit: {record.property_id.name} - {record.buyer_id.name}',
+ 'start': record.visit_date,
+ 'stop': record.stop_date
+ })
+ return records
diff --git a/estate/models/res_users.py b/estate/models/res_users.py
new file mode 100644
index 00000000000..90fef268fc6
--- /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='Propertiesss',
+ domain=[('state', 'in', ['new', 'offer_received'])],
+ )
diff --git a/estate/security/estate_security.xml b/estate/security/estate_security.xml
new file mode 100644
index 00000000000..0dedd414151
--- /dev/null
+++ b/estate/security/estate_security.xml
@@ -0,0 +1,32 @@
+
+
+ Estate
+ 130
+
+
+
+ Estate
+ 1
+
+
+
+
+ User
+
+
+
+
+ Agent
+
+
+
+
+ Manager
+
+
+
+
+
+
+
+
diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv
new file mode 100644
index 00000000000..bd34e93304f
--- /dev/null
+++ b/estate/security/ir.model.access.csv
@@ -0,0 +1,14 @@
+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,estate.group_estate_users,1,1,1,0
+access_estate_property_agent,access_estate_property_agent,model_estate_property,estate.group_estate_agent,1,1,1,0
+access_estate_property_manager,access_estate_property_manager,model_estate_property,estate.group_estate_manager,1,1,1,1
+
+access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1
+access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1
+
+access_estate_property_offer_user,access_estate_property_offer,model_estate_property_offer,estate.group_estate_users,1,1,1,0
+access_estate_property_offer_agent,access_estate_property_offer_agent,model_estate_property_offer,estate.group_estate_agent,1,1,1,0
+access_estate_property_offer_manager,access_estate_property_offer_manager,model_estate_property_offer,estate.group_estate_manager,1,1,0,0
+
+access_estate_property_visit,access_estate_property_visit,model_estate_property_visit,base.group_user,1,1,1,1
+access_estate_property_issues,access_estate_property_issues,model_estate_property_issues,base.group_user,1,1,1,1
diff --git a/estate/views/estate_property_issues_views.xml b/estate/views/estate_property_issues_views.xml
new file mode 100644
index 00000000000..2aaea4ba602
--- /dev/null
+++ b/estate/views/estate_property_issues_views.xml
@@ -0,0 +1,62 @@
+
+
+ estate.property.issues.view.list
+ estate.property.issues
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.issues.form
+ estate.property.issues
+
+
+
+
+
+
+ Issues
+ estate.property.issues
+ list,form
+ [('property_id', '=', active_id)]
+ {'default_property_id': active_id}
+
+
diff --git a/estate/views/estate_property_menus.xml b/estate/views/estate_property_menus.xml
new file mode 100644
index 00000000000..baf77cf5463
--- /dev/null
+++ b/estate/views/estate_property_menus.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml
new file mode 100644
index 00000000000..8f22ca8897b
--- /dev/null
+++ b/estate/views/estate_property_offer_views.xml
@@ -0,0 +1,57 @@
+
+
+ Property Offers
+ estate.property.offer
+ list,form
+
+
+
+ estate.property.offer.list
+ estate.property.offer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.offer.view.form
+ estate.property.offer
+
+
+
+
+
+
+ Property Offers
+ estate.property.offer
+ list,form
+ [('property_type_id', '=', active_id)]
+
+
diff --git a/estate/views/estate_property_tags_views.xml b/estate/views/estate_property_tags_views.xml
new file mode 100644
index 00000000000..7475ac48858
--- /dev/null
+++ b/estate/views/estate_property_tags_views.xml
@@ -0,0 +1,33 @@
+
+
+ Property Tags
+ estate.property.tag
+ list,form
+
+
+
+ estate.property.tag.view.list
+ estate.property.tag
+
+
+
+
+
+
+
+
+
+ estate.property.tag.view.form
+ estate.property.tag
+
+
+
+
+
diff --git a/estate/views/estate_property_types_views.xml b/estate/views/estate_property_types_views.xml
new file mode 100644
index 00000000000..1724fa5282e
--- /dev/null
+++ b/estate/views/estate_property_types_views.xml
@@ -0,0 +1,50 @@
+
+
+ Property Types
+ estate.property.type
+ list,form
+
+
+
+ estate.property.type.view.list
+ estate.property.type
+
+
+
+
+
+
+
+
+
+ estate.property.type.view.form
+ 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..8bfc3028072
--- /dev/null
+++ b/estate/views/estate_property_views.xml
@@ -0,0 +1,175 @@
+
+
+ Properties
+ estate.property
+ list,form,kanban
+ {'search_default_available': 1, 'search_default_Bedroomss': 2}
+
+
+
+ estate.property.view.list
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.view.form
+ estate.property
+
+
+
+
+
+
+ estate.property.view.search
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ estate.property.view.kanban
+ estate.property
+
+
+
+
+
+
+
+
+
+
+
Expected Price:
+
+ Best Offer:
+
+
+ Selling Price:
+
+
+
+
+
+
+
+
+
+
+
diff --git a/estate/views/estate_property_visit_views.xml b/estate/views/estate_property_visit_views.xml
new file mode 100644
index 00000000000..c031e957e82
--- /dev/null
+++ b/estate/views/estate_property_visit_views.xml
@@ -0,0 +1,40 @@
+
+
+ estate.property.visits.view.list
+ estate.property.visit
+
+
+
+
+
+
+
+
+
+ estate.property.visits.view.form
+ estate.property.visit
+
+
+
+
+
+
+ Estate Property Stat Button
+ estate.property.visit
+ list,form
+ [('property_id', '=', active_id)]
+ {'default_property_id': active_id}
+
+
diff --git a/estate/views/res_user.xml b/estate/views/res_user.xml
new file mode 100644
index 00000000000..b762b90aca9
--- /dev/null
+++ b/estate/views/res_user.xml
@@ -0,0 +1,25 @@
+
+
+ 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..48b3cbc9ca2
--- /dev/null
+++ b/estate_account/__manifest__.py
@@ -0,0 +1,9 @@
+{
+ 'name': 'Real Estate Account',
+ 'author': 'Aditi (adpaw)',
+ 'license': 'LGPL-3',
+ 'depends': [
+ 'estate', 'account'
+ ],
+ 'installable': True,
+}
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..623126b02e8
--- /dev/null
+++ b/estate_account/models/estate_property.py
@@ -0,0 +1,27 @@
+from odoo import models, Command
+
+
+class EstateProperty(models.Model):
+ _inherit = "estate.property"
+
+ def action_sold(self):
+ res = super().action_sold()
+
+ for record in self:
+ self.env["account.move"].create({
+ "partner_id": record.buyer_id.id,
+ "move_type": "out_invoice",
+ "invoice_line_ids": [
+ Command.create({
+ "name": f"Commission for {record.name}",
+ "quantity": 1,
+ "price_unit": record.selling_price * 0.06
+ }),
+ Command.create({
+ "name": "Administrative fees",
+ "quantity": 1,
+ "price_unit": 100.0
+ }),
+ ],
+ })
+ return res
diff --git a/estate_crm/__init__.py b/estate_crm/__init__.py
new file mode 100644
index 00000000000..0650744f6bc
--- /dev/null
+++ b/estate_crm/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/estate_crm/__manifest__.py b/estate_crm/__manifest__.py
new file mode 100644
index 00000000000..4f696f19d5f
--- /dev/null
+++ b/estate_crm/__manifest__.py
@@ -0,0 +1,9 @@
+{
+ 'name': 'Real Estate Offer',
+ 'author': 'Aditi (adpaw)',
+ 'license': 'LGPL-3',
+ 'depends': [
+ 'estate', 'crm'
+ ],
+ 'installable': True,
+}
diff --git a/estate_crm/models/__init__.py b/estate_crm/models/__init__.py
new file mode 100644
index 00000000000..6b65f241225
--- /dev/null
+++ b/estate_crm/models/__init__.py
@@ -0,0 +1 @@
+from . import estate_property_offer
diff --git a/estate_crm/models/estate_property_offer.py b/estate_crm/models/estate_property_offer.py
new file mode 100644
index 00000000000..846591d9987
--- /dev/null
+++ b/estate_crm/models/estate_property_offer.py
@@ -0,0 +1,36 @@
+from odoo import api, fields, models
+
+
+class EstatePropertyOffer(models.Model):
+ _inherit = "estate.property.offer"
+
+ crm_lead_id = fields.Many2one('crm.lead', string='CRM Lead', copy=False)
+
+ @api.model_create_multi
+ def create(self, vals_list):
+ records = super().create(vals_list)
+ for record in records:
+ lead = self.env["crm.lead"].create({
+ "name": record.property_id.name,
+ "expected_revenue": record.price,
+ "partner_id": record.partner_id.id,
+ })
+ record.crm_lead_id = lead
+ return records
+
+ def action_accept(self):
+ res = super().action_accept()
+ for offer in self:
+ if offer.crm_lead_id:
+ offer.crm_lead_id.action_set_won()
+ for offer in self:
+ other_offers = offer.property_id.offer_ids - offer
+ other_offers.action_refuse()
+ return res
+
+ def action_refuse(self):
+ res = super().action_refuse()
+ for offer in self:
+ if offer.crm_lead_id:
+ offer.crm_lead_id.action_set_lost()
+ return res
diff --git a/second_uom/__init__.py b/second_uom/__init__.py
new file mode 100644
index 00000000000..0650744f6bc
--- /dev/null
+++ b/second_uom/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/second_uom/__manifest__.py b/second_uom/__manifest__.py
new file mode 100644
index 00000000000..c4b228d208e
--- /dev/null
+++ b/second_uom/__manifest__.py
@@ -0,0 +1,19 @@
+{
+ 'name': 'POS Second Unit of Measure',
+ 'author': 'Aditi (adpaw)',
+ 'category': 'Point of Sale',
+ 'summary': 'Allow cashier to enter quantity using a second UOM in POS',
+ 'depends': ['point_of_sale', 'product'],
+ 'license': 'LGPL-3',
+ 'data': [
+ 'views/product_template_views.xml',
+ ],
+ 'assets': {
+ 'point_of_sale._assets_pos': [
+ 'second_uom/static/src/second_uom_popup/second_uom_popup.xml',
+ 'second_uom/static/src/second_uom_button/second_uom_button.xml',
+ 'second_uom/static/src/second_uom_popup/second_uom_popup.js',
+ 'second_uom/static/src/second_uom_button/second_uom_button.js',
+ ],
+ },
+}
diff --git a/second_uom/models/__init__.py b/second_uom/models/__init__.py
new file mode 100644
index 00000000000..049669dd0fe
--- /dev/null
+++ b/second_uom/models/__init__.py
@@ -0,0 +1,2 @@
+from . import product_template
+from . import product_product
diff --git a/second_uom/models/product_product.py b/second_uom/models/product_product.py
new file mode 100644
index 00000000000..e744cb01c56
--- /dev/null
+++ b/second_uom/models/product_product.py
@@ -0,0 +1,11 @@
+from odoo import api, models
+
+
+class InheritedProductProduct(models.Model):
+ _inherit = 'product.product'
+
+ @api.model
+ def _load_pos_data_fields(self, config_id):
+ result = super()._load_pos_data_fields(config_id)
+ result.append('pos_second_uom_id')
+ return result
diff --git a/second_uom/models/product_template.py b/second_uom/models/product_template.py
new file mode 100644
index 00000000000..58d0e031955
--- /dev/null
+++ b/second_uom/models/product_template.py
@@ -0,0 +1,28 @@
+from odoo import api, fields, models
+
+
+class InheritedProductTemplate(models.Model):
+ _inherit = 'product.template'
+
+ pos_second_uom_id = fields.Many2one('uom.uom', string="POS Second UoM")
+ pos_uom_reference_id = fields.Many2one(
+ 'uom.uom', string="UoM Root", compute='_compute_pos_uom_reference_id', store=True
+ )
+
+ @api.depends('uom_id')
+ def _compute_pos_uom_reference_id(self):
+ for record in self:
+ if record.uom_id:
+ record.pos_uom_reference_id = (
+ record.uom_id.relative_uom_id or record.uom_id
+ )
+ else:
+ record.pos_uom_reference_id = False
+
+ @api.onchange('uom_id')
+ def _onchange_uom_id_clear_second(self):
+ if self.pos_second_uom_id:
+ second_ref = self.pos_second_uom_id.relative_uom_id or self.pos_second_uom_id
+ main_ref = self.uom_id.relative_uom_id or self.uom_id
+ if second_ref != main_ref:
+ self.pos_second_uom_id = False
diff --git a/second_uom/static/src/second_uom_button/second_uom_button.js b/second_uom/static/src/second_uom_button/second_uom_button.js
new file mode 100644
index 00000000000..7b6ab53bce0
--- /dev/null
+++ b/second_uom/static/src/second_uom_button/second_uom_button.js
@@ -0,0 +1,32 @@
+import { ControlButtons } from "@point_of_sale/app/screens/product_screen/control_buttons/control_buttons";
+import { SecondUomPopup } from "@second_uom/second_uom_popup/second_uom_popup";
+import { patch } from "@web/core/utils/patch";
+import { makeAwaitable } from "@point_of_sale/app/utils/make_awaitable_dialog";
+
+patch(ControlButtons.prototype, {
+ displaySecondUomBtn() {
+ const selectedLine = this.currentOrder?.getSelectedOrderline();
+ return selectedLine && selectedLine.product_id.pos_second_uom_id;
+ },
+
+ async clickSecondUom() {
+ const selectedLine = this.currentOrder.getSelectedOrderline();
+ if (!selectedLine) return;
+
+ const secondUom = selectedLine.product_id.pos_second_uom_id;
+ const mainUom = selectedLine.product_id.uom_id;
+
+ const result = await makeAwaitable(this.dialog, SecondUomPopup, {
+ title: "Secondary Unit Entry",
+ uomName: secondUom.name,
+ startingValue: 0,
+ });
+
+ if (result !== null && result !== undefined) {
+ const enteredQty = parseFloat(result);
+ if (isNaN(enteredQty)) return;
+ const newMainQty = (enteredQty * secondUom.factor) / mainUom.factor;
+ selectedLine.setQuantity(newMainQty);
+ }
+ }
+});
diff --git a/second_uom/static/src/second_uom_button/second_uom_button.xml b/second_uom/static/src/second_uom_button/second_uom_button.xml
new file mode 100644
index 00000000000..748b08d4d69
--- /dev/null
+++ b/second_uom/static/src/second_uom_button/second_uom_button.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/second_uom/static/src/second_uom_popup/second_uom_popup.js b/second_uom/static/src/second_uom_popup/second_uom_popup.js
new file mode 100644
index 00000000000..43164cf6f90
--- /dev/null
+++ b/second_uom/static/src/second_uom_popup/second_uom_popup.js
@@ -0,0 +1,14 @@
+import { NumberPopup } from "@point_of_sale/app/components/popups/number_popup/number_popup";
+
+export class SecondUomPopup extends NumberPopup {
+ static template = "second_uom.SecondUomPopup";
+ static props = {
+ ...NumberPopup.props,
+ uomName: { type: String },
+ };
+
+ confirm() {
+ this.props.getPayload(this.state.buffer);
+ this.props.close();
+ }
+}
diff --git a/second_uom/static/src/second_uom_popup/second_uom_popup.xml b/second_uom/static/src/second_uom_popup/second_uom_popup.xml
new file mode 100644
index 00000000000..17685b3236d
--- /dev/null
+++ b/second_uom/static/src/second_uom_popup/second_uom_popup.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ Unit:
+
+
+
+
+ ()
+
+
+
+
diff --git a/second_uom/views/product_template_views.xml b/second_uom/views/product_template_views.xml
new file mode 100644
index 00000000000..401d09c00c1
--- /dev/null
+++ b/second_uom/views/product_template_views.xml
@@ -0,0 +1,19 @@
+
+
+
+ product.template.form.inherit.second.uom
+ product.template
+
+
+
+
+
+
+
+
+
\ No newline at end of file