diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index c4fb245621b..d41e71bd5b5 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -1,8 +1,49 @@ -import { Component } from "@odoo/owl"; +import { Component, useState, onWillStart } 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"; + class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; + static components = { Layout, DashboardItem }; + + setup(){ + this.statisticsService = useService("awesome_dashboard.statistics"); + this.action = useService("action"); + this.display = useState({ + controlPanel: {} + }); + this.stats = useState({}); + onWillStart(async () => { + const result = await this.statisticsService.loadStatistics(); + this.stats = result; + }) + } + + openCustomers() { + /* this.action.doAction("base.action_partner_form"); */ + this.action.doAction({ + type: 'ir.actions.act_window', + name: 'Customers', + /* target: 'new', */ + res_model: 'res.partner', + views: [[false, 'kanban']], + }) + } + + openLeads() { + this.action.doAction({ + type: 'ir.actions.act_window', + name: 'Leads', + target: 'current', + /* res_id: 'crm_lead_action', */ + res_model: 'crm.lead', + views: [[false, 'list'],[false, 'form']], + }) + } + } registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard.scss b/awesome_dashboard/static/src/dashboard.scss new file mode 100644 index 00000000000..769fc1e72f9 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard.scss @@ -0,0 +1,3 @@ +.o_dashboard { + background-color: gray; +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index 1a2ac9a2fed..1cb713b7765 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -3,6 +3,34 @@ hello dashboard + + + + + + + Average amount of ... is + + + + Average time of ... is + + + + Number of cancelled orders is + + + + Number of new orders is + + + + The total amount of new orders is + + + + + diff --git a/awesome_dashboard/static/src/dashboard_item/dashboard_item.js b/awesome_dashboard/static/src/dashboard_item/dashboard_item.js new file mode 100644 index 00000000000..7dcf38870bc --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_item/dashboard_item.js @@ -0,0 +1,17 @@ +import { Component, useState } from "@odoo/owl"; + +export class DashboardItem extends Component { + static template = "awesome_dashboard.dashboard_item"; + static props = { + size:{ + type: Number, + optional: true, + default: 1, + } + } + + setup(){ + this.width = useState({value: this.props.size * 18}) + } + +} diff --git a/awesome_dashboard/static/src/dashboard_item/dashboard_item.scss b/awesome_dashboard/static/src/dashboard_item/dashboard_item.scss new file mode 100644 index 00000000000..00874b06b30 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_item/dashboard_item.scss @@ -0,0 +1,5 @@ +.card { + display: inline-block; + border: 1px solid grey; + padding: 10px; +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard_item/dashboard_item.xml b/awesome_dashboard/static/src/dashboard_item/dashboard_item.xml new file mode 100644 index 00000000000..5d76721e3c0 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_item/dashboard_item.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/awesome_dashboard/static/src/statistics_service.js b/awesome_dashboard/static/src/statistics_service.js new file mode 100644 index 00000000000..f0493a2633b --- /dev/null +++ b/awesome_dashboard/static/src/statistics_service.js @@ -0,0 +1,14 @@ +import { registry } from "@web/core/registry"; +import { rpc } from "@web/core/network/rpc"; +import { memoize } from "@web/core/utils/functions"; + +const statistics_service = { + async: ["loadStatistics"], + start(env) { + return { + loadStatistics: memoize(() => rpc("/awesome_dashboard/statistics")), + } + } +} + +registry.category("services").add("awesome_dashboard.statistics", statistics_service); \ No newline at end of file diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js new file mode 100644 index 00000000000..c0fb6e9c46c --- /dev/null +++ b/awesome_owl/static/src/card/card.js @@ -0,0 +1,24 @@ +import { markup, Component, useState } from "@odoo/owl"; + +export class Card extends Component { + static template = "awesome_owl.card"; + static props = { + title: { + type: String, + optional: true, + }, + slots: { + type: Object, + optional: true, + }, + }; + + setup() { + this.state = useState({htmlLink: markup('test')}) + this.isMinimized = useState({value: false}); + } + + toggle() { + this.isMinimized.value = !this.isMinimized.value; + } +} diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml new file mode 100644 index 00000000000..0ad7c9ed829 --- /dev/null +++ b/awesome_owl/static/src/card/card.xml @@ -0,0 +1,15 @@ + + + + +
+
+
+
+ + +

+

+
+
+
+
diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js new file mode 100644 index 00000000000..3e31ec8bdf6 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.js @@ -0,0 +1,18 @@ +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++; + 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..65a9f7e8833 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.xml @@ -0,0 +1,11 @@ + + + + +
+
Counter:
+ +
+
+ +
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 4ac769b0aa5..f6431540330 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,5 +1,17 @@ -import { Component } from "@odoo/owl"; +import { Component, useState } 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 components = { Counter, Card, TodoList }; + + setup(){ + this.sum = useState({value: 0}) + } + + incrementSum(){ + this.sum.value++; + } } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4fb905d59f9..025440a90df 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -1,10 +1,24 @@ -
- hello world +

hello world

+
Sum of counters:
+ +

+ Random content 1 +

+ +
+ +

+ Random content 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..56ed0c084ca --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_item.js @@ -0,0 +1,31 @@ +import { Component, useState } from "@odoo/owl"; + +export class TodoItem extends Component { + static template = "awesome_owl.todo_item"; + static props = { + todo: { + type: Object, + shape: { + id: {type: Number, optional: false}, + description: {type: String, optional: false}, + isCompleted: {type: Boolean, optional: false}, + }, + }, + toggleState: { + type: Function, + optional: false, + }, + removeTodo: { + type: Function, + optional: false, + }, + }; + + change(){ + this.props.toggleState(this.props.todo.id); + } + remove(){ + 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..d173cac5e85 --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_item.xml @@ -0,0 +1,15 @@ + + + + +
+ + [X + _] + - + + +
+
+ +
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..7f6365540d5 --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_list.js @@ -0,0 +1,41 @@ +import { Component, useState, useRef, onMounted } from "@odoo/owl"; +import { TodoItem } from "./todo_item"; + +export class TodoList extends Component { + static template = "awesome_owl.todo_list"; + static components = { TodoItem }; + + setup(){ + this.todos = useState([]); + this.todoCount = 1; + this.inputRef = useRef('taskInput'); + + onMounted(()=>{ + this.inputRef.el.focus(); + }) + } + + addTask(e){ + if(e.keyCode === 13 && e.target.value !== ""){ + this.todos.push({ + id: this.todoCount++, + description: e.target.value, + isCompleted: false, + }) + e.target.value = ""; + } + } + + toggleState(id){ + let todo = this.todos.find((todo) => todo.id === id); + todo.isCompleted = !todo.isCompleted; + } + + removeTodo(id){ + const index = this.todos.findIndex((todo) => todo.id === id); + 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..3faea0b59b3 --- /dev/null +++ b/awesome_owl/static/src/todo_list/todo_list.xml @@ -0,0 +1,11 @@ + + + + +
+ + +
+
+ +
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..504a35cd038 --- /dev/null +++ b/estate/__manifest__.py @@ -0,0 +1,21 @@ +{ + 'name': 'estate', + 'author': 'Odoo S.A.', + 'depends': ['base'], + 'application': True, + 'license': 'LGPL-3', + + 'data': [ + 'security/ir.model.access.csv', + + 'views/estate_property_views.xml', + 'views/estate_property_type_views.xml', + 'views/estate_property_tag_views.xml', + 'views/estate_property_offer_views.xml', + + 'views/estate_menus.xml', + + 'views/res_users_view_form.xml', + + ], +} 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..0fec1263d56 --- /dev/null +++ b/estate/models/estate_property.py @@ -0,0 +1,101 @@ +from odoo import fields, models, api, tools +from odoo.exceptions import UserError, ValidationError + + +class EstateProperty(models.Model): + _name = 'estate.property' + _description = "Estate properties" + _order = 'id desc' + + active = fields.Boolean(default=True) + state = fields.Selection([ + ('new', "New"), + ('offer_received', "Offer Received"), + ('offer_accepted', "Offer Accepted"), + ('sold', "Sold"), + ('cancelled', "Cancelled"), + ], + default='new' + ) + name = fields.Char(required=True, string="Title") + description = fields.Text() + postcode = fields.Char() + date_availability = fields.Date( + copy=False, + default=lambda self: fields.Date.add(fields.Date.today(), months=3), string="Available From") + 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() + garage = fields.Boolean() + garden = fields.Boolean() + garden_area = fields.Integer(string="Garden Area (sqm)") + garden_orientation = fields.Selection( + selection=[('north', "North"), ('south', "South"), ('east', "East"), ('west', "West")], + ) + property_type_id = fields.Many2one('estate.property.type', + string="Property Type") + buyer_id = fields.Many2one('res.partner', string="Buyer", copy=False) + salesman_id = fields.Many2one('res.users', string="Salesman", + default=lambda self: self.env.user) + property_tag_ids = fields.Many2many('estate.property.tag', string="Tags") + property_offer_ids = fields.One2many('estate.property.offer', 'property_id', string="Offers") + total_area = fields.Float(compute='_compute_total_area') + best_price = fields.Float(compute='_compute_best_price', + string="Best Offer") + + _check_expected_price = models.Constraint( + 'CHECK(expected_price > 0)', + "The expected price of a property must be strictly positive.", + ) + _check_selling_price = models.Constraint( + 'CHECK(selling_price >= 0)', + "The selling price of a property 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('property_offer_ids.price') + def _compute_best_price(self): + for record in self: + record.best_price = max(record.property_offer_ids.mapped('price'), default=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 = '' + + @api.constrains('selling_price', 'expected_price') + def _check_date_end(self): + for record in self: + if (len(record.property_offer_ids) != 0) and tools.float_utils.float_compare(record.expected_price * 0.9, record.selling_price, precision_digits=2) == 1: + raise ValidationError(self.env._("The selling price cannot be inferior to 90% of the expected price")) + + @api.ondelete(at_uninstall=False) + def _check_state_before_unlink(self): + for record in self: + if record.state not in {'new', 'cancelled'}: + raise UserError(self.env._("Only new or cancelled properties can be deleted...")) + + def action_sold(self): + for record in self: + if record.state == 'cancelled': + raise UserError(self.env._("Cancelled properties cannot be sold.")) + record.state = 'sold' + return True + + def action_cancelled(self): + for record in self: + if record.state == 'sold': + raise UserError(self.env._("Sold properties cannot be cancelled.")) + record.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..cd2367401df --- /dev/null +++ b/estate/models/estate_property_offer.py @@ -0,0 +1,58 @@ +from odoo import fields, models, api +from odoo.exceptions import UserError + + +class EstatePropertyOffer(models.Model): + _name = 'estate.property.offer' + _description = "Estate property offers" + _order = 'price desc' + + price = fields.Float() + status = fields.Selection( + selection=[('accepted', "Accepted"), ('refused', "Refused")], + copy=False + ) + partner_id = fields.Many2one('res.partner', string="Partner", required=True) + property_id = fields.Many2one('estate.property', string="Property", required=True) + property_type_id = fields.Many2one(related='property_id.property_type_id') + + validity = fields.Integer(default=7) + date_deadline = fields.Date(compute='_compute_deadline', inverse='_inverse_deadline', string="Deadline") + + _check_price = models.Constraint( + 'CHECK(price > 0)', + "The price of an offer must be positive.", + ) + + @api.depends('create_date', 'validity') + def _compute_deadline(self): + for record in self: + createDate = record.create_date or fields.Date.today() + record.date_deadline = fields.Date.add(createDate, days=record.validity) + + def _inverse_deadline(self): + for record in self: + record.validity = (record.date_deadline - fields.Date.to_date(record.create_date)).days + + @api.model + def create(self, vals_list): + for vals in vals_list: + propertyId = self.env['estate.property'].browse(vals['property_id']) + if propertyId.best_price > vals['price']: + raise UserError(self.env._("Cannot create an offer with a lower price than the best offer:%s",propertyId.best_price)) + propertyId.state = 'offer_received' + return super().create(vals_list) + + def action_refuse(self): + for record in self: + record.status = 'refused' + return True + + def action_accept(self): + for record in self: + for offer in record.property_id.property_offer_ids: + offer.status = 'refused' + record.status = 'accepted' + record.property_id.selling_price = record.price + record.property_id.buyer_id = record.partner_id + return True diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py new file mode 100644 index 00000000000..f245a0e2dac --- /dev/null +++ b/estate/models/estate_property_tag.py @@ -0,0 +1,15 @@ +from odoo import fields, models + + +class EstatePropertyTag(models.Model): + _name = 'estate.property.tag' + _description = "Estate property tags" + _order = 'name' + + name = fields.Char(required=True) + color = fields.Integer() + + _check_name = models.Constraint( + 'UNIQUE(name)', + "The name of property tag 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..9670152567b --- /dev/null +++ b/estate/models/estate_property_type.py @@ -0,0 +1,27 @@ +from odoo import fields, models, api + + +class EstatePropertyType(models.Model): + _name = 'estate.property.type' + _description = "Estate property types" + _order = 'sequence, name' + + sequence = fields.Integer('Sequence', default=1, help="Used to order stages. Lower is better.") + + name = fields.Char(required=True) + + property_ids = fields.One2many('estate.property', 'property_type_id') + + offer_ids = fields.One2many('estate.property.offer', 'property_type_id') + offer_count = fields.Integer(compute='_compute_offer_count') + + _check_name = models.Constraint( + 'UNIQUE(name)', + "The name of property type must be unique.", + ) + + @api.depends('offer_ids') + def _compute_offer_count(self): + for record in self: + record.offer_count = len(record.offer_ids) + return True diff --git a/estate/models/res_users.py b/estate/models/res_users.py new file mode 100644 index 00000000000..c5481f5d88b --- /dev/null +++ b/estate/models/res_users.py @@ -0,0 +1,8 @@ +from odoo import fields, models + + +class resUsers(models.Model): + _name = 'res.users' + _inherit = 'res.users' + + property_ids = fields.One2many('estate.property', 'salesman_id', 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..4c593ed42e4 --- /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,access_estate_property,model_estate_property,base.group_user,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,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml new file mode 100644 index 00000000000..b2489962d29 --- /dev/null +++ b/estate/views/estate_menus.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml new file mode 100644 index 00000000000..cb359cadf3b --- /dev/null +++ b/estate/views/estate_property_offer_views.xml @@ -0,0 +1,42 @@ + + + Properties Offers + estate.property.offer + list,form + [("property_type_id", "=", active_id)] + + + + + estate.property.offer.list + estate.property.offer + + + + + + + + +

+ +

+ + + + + + + + + +
+
+
\ No newline at end of file diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml new file mode 100644 index 00000000000..89e7773a1f7 --- /dev/null +++ b/estate/views/estate_property_views.xml @@ -0,0 +1,140 @@ + + + Properties + estate.property + list,form,kanban + {"search_default_filter_available_properties":True} + + + + + estate.property.list + estate.property + + + + + + + + + + + + + + + + + + estate.property.form + estate.property + +
+
+ +
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + estate.property.kanban + estate.property + + + + + + + + + + + estate.property.search + estate.property + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/estate/views/res_users_view_form.xml b/estate/views/res_users_view_form.xml new file mode 100644 index 00000000000..b26d51da95a --- /dev/null +++ b/estate/views/res_users_view_form.xml @@ -0,0 +1,14 @@ + + + res.users.view.form + 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..1ca3c419b34 --- /dev/null +++ b/estate_account/__manifest__.py @@ -0,0 +1,10 @@ +{ + 'name': 'Estate Accounting', + 'author': 'Odoo S.A.', + 'depends': ['estate', 'account'], + 'auto_install': True, + '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..29f15337722 --- /dev/null +++ b/estate_account/models/estate_property.py @@ -0,0 +1,27 @@ +from odoo import models, Command + + +class EstateProperty(models.Model): + _name = 'estate.property' + _inherit = 'estate.property' + + def action_sold(self): + for estate_property in self: + self.env['account.move'].create({ + 'name': estate_property.name, + 'move_type': 'out_invoice', + 'partner_id': estate_property.buyer_id.id, + 'line_ids': [ + Command.create({ + 'name': estate_property.env._("6% of selling price"), + 'quantity': '1', + 'price_unit': estate_property.selling_price * 0.06, + }), + Command.create({ + 'name': estate_property.env._("Administrative fee"), + 'quantity': '1', + 'price_unit': 100.00, + }), + ], + }) + return super().action_sold()