From 3f513aed466b52ad5ab1c26fef25097da0f132f1 Mon Sep 17 00:00:00 2001 From: zadh-odoo Date: Wed, 2 Jul 2025 18:59:03 +0530 Subject: [PATCH 01/11] [ADD] estate: initial module for real estate properties - Created new 'estate' module. - Added base model 'estate.property' with fields mentioned in exercise. - Set up module structure. - Set 'name' and 'expected_price' as required fields. --- estate/__init__.py | 1 + estate/__manifest__.py | 9 +++++++++ estate/models/__init__.py | 1 + estate/models/estate_property.py | 24 ++++++++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 estate/__init__.py create mode 100644 estate/__manifest__.py create mode 100644 estate/models/__init__.py create mode 100644 estate/models/estate_property.py diff --git a/estate/__init__.py b/estate/__init__.py new file mode 100644 index 00000000000..9a7e03eded3 --- /dev/null +++ b/estate/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/estate/__manifest__.py b/estate/__manifest__.py new file mode 100644 index 00000000000..c844e7c8840 --- /dev/null +++ b/estate/__manifest__.py @@ -0,0 +1,9 @@ +{ + 'name':"Real Estate", + 'summary':"This is real estate module", + 'category':"Tutorials", + 'description':"This is real estate module", + 'author':"Dhruvrajsinh Zala (zadh)", + 'application':True, + 'installable':True +} \ No newline at end of file diff --git a/estate/models/__init__.py b/estate/models/__init__.py new file mode 100644 index 00000000000..f4c8fd6db6d --- /dev/null +++ b/estate/models/__init__.py @@ -0,0 +1 @@ +from . import estate_property \ No newline at end of file diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py new file mode 100644 index 00000000000..bd5494cc877 --- /dev/null +++ b/estate/models/estate_property.py @@ -0,0 +1,24 @@ +from odoo import models,fields + +class EstateProperty(models.Model): + _name = 'estate.property' + _description = 'Real Estate Property' + + name = fields.Char(required=True) + description = fields.Text() + postcode = fields.Char() + date_availability = fields.Date() + expected_price = fields.Float(required=True) + selling_price = fields.Float() + bedrooms = fields.Integer() + living_area = fields.Integer() + facades = fields.Integer() + garage = fields.Boolean() + garden = fields.Boolean() + garden_area = fields.Integer() + garden_orientation = fields.Selection([ + ('north','North'), + ('south','South'), + ('east','East'), + ('west','West') + ]) \ No newline at end of file From b1b460502ee0711243419cc026048024789043e6 Mon Sep 17 00:00:00 2001 From: zadh-odoo Date: Fri, 4 Jul 2025 10:11:42 +0530 Subject: [PATCH 02/11] [IMP] estate: implement security, UI actions, and basic views - Added security rules for the estate. - Registered the security files in __manifest__.py to enable permission. - Created menu items for the estate.property model. - Added XML files for actions and menus. - Added basic views for the estate.property model, including form and list views. - Set default values for fields, made certain fields readonly. --- estate/__manifest__.py | 5 +- estate/models/estate_property.py | 23 +++++- estate/security/ir.model.access.csv | 2 + estate/views/estate_menus.xml | 10 +++ estate/views/estate_property_views.xml | 103 +++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 estate/security/ir.model.access.csv create mode 100644 estate/views/estate_menus.xml create mode 100644 estate/views/estate_property_views.xml diff --git a/estate/__manifest__.py b/estate/__manifest__.py index c844e7c8840..5eb0b035fd0 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -4,6 +4,7 @@ 'category':"Tutorials", 'description':"This is real estate module", 'author':"Dhruvrajsinh Zala (zadh)", - 'application':True, - 'installable':True + 'installable': True, + 'application': True, + 'data':['security/ir.model.access.csv', 'views/estate_property_views.xml','views/estate_menus.xml'] } \ No newline at end of file diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index bd5494cc877..83ef833a5a2 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,3 +1,4 @@ +from dateutil.relativedelta import relativedelta from odoo import models,fields class EstateProperty(models.Model): @@ -7,18 +8,32 @@ class EstateProperty(models.Model): name = fields.Char(required=True) description = fields.Text() postcode = fields.Char() - date_availability = fields.Date() + date_availability = fields.Date( + default=lambda self: fields.Date.today() + relativedelta(months=3), + copy=False) expected_price = fields.Float(required=True) - selling_price = fields.Float() - bedrooms = fields.Integer() + selling_price = fields.Float(readonly=True,copy=False) + bedrooms = fields.Integer(default=2) living_area = fields.Integer() facades = fields.Integer() garage = fields.Boolean() garden = fields.Boolean() garden_area = fields.Integer() + active = fields.Boolean(default=True) garden_orientation = fields.Selection([ ('north','North'), ('south','South'), ('east','East'), ('west','West') - ]) \ No newline at end of file + ]) + state = fields.Selection( + [ + ('new', 'New'), + ('offer_received', 'Offer Received'), + ('offer_accepted', 'Offer Accepted'), + ('sold', 'Sold'), + ('cancelled', 'Cancelled') + ], + required=True, + copy=False, + default='new') \ No newline at end of file diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv new file mode 100644 index 00000000000..e0b328dc7fe --- /dev/null +++ b/estate/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +estate.access_estate_property,access_estate_property,estate.model_estate_property,,1,1,1,1 diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml new file mode 100644 index 00000000000..5349474fef3 --- /dev/null +++ b/estate/views/estate_menus.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ 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..81a481bbad1 --- /dev/null +++ b/estate/views/estate_property_views.xml @@ -0,0 +1,103 @@ + + + Properties + estate.property + list,form + + + + estate.property.list + estate.property + list + + + + + + + + + + + + + + + estate.property.form + estate.property + form + +
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + estate.property.search + estate.property + search + + + + + + + + + + + + + + + + +
\ No newline at end of file From 74f6cce7c1c8bf66c2ba7d1e3fd82e49a361f5ec Mon Sep 17 00:00:00 2001 From: zadh-odoo Date: Mon, 7 Jul 2025 12:17:49 +0530 Subject: [PATCH 03/11] [IMP] esatate: added relations, computed fields, and actions -Created new models for property offers,tags and types. -Defined relation between these data models for accessing data across the model. -Created new views for property types,property tags. -Defined action on button click , created computed fields . --- estate/__manifest__.py | 2 +- estate/models/__init__.py | 5 +- estate/models/esatate_property_type.py | 8 ++ estate/models/estate_property.py | 71 +++++++++++++-- estate/models/estate_property_offer.py | 43 +++++++++ estate/models/estate_property_tags.py | 7 ++ estate/security/ir.model.access.csv | 3 + estate/views/estate_menus.xml | 17 ++-- estate/views/estate_property_tags.xml | 35 ++++++++ estate/views/estate_property_type_views.xml | 35 ++++++++ estate/views/estate_property_views.xml | 96 ++++++++++++--------- 11 files changed, 266 insertions(+), 56 deletions(-) create mode 100644 estate/models/esatate_property_type.py create mode 100644 estate/models/estate_property_offer.py create mode 100644 estate/models/estate_property_tags.py create mode 100644 estate/views/estate_property_tags.xml create mode 100644 estate/views/estate_property_type_views.xml diff --git a/estate/__manifest__.py b/estate/__manifest__.py index 5eb0b035fd0..023fe7a7f72 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -6,5 +6,5 @@ 'author':"Dhruvrajsinh Zala (zadh)", 'installable': True, 'application': True, - 'data':['security/ir.model.access.csv', 'views/estate_property_views.xml','views/estate_menus.xml'] + 'data':['security/ir.model.access.csv', 'views/estate_property_views.xml','views/estate_menus.xml','views/estate_property_type_views.xml','views/estate_property_tags.xml'] } \ No newline at end of file diff --git a/estate/models/__init__.py b/estate/models/__init__.py index f4c8fd6db6d..dc190a3e8ee 100644 --- a/estate/models/__init__.py +++ b/estate/models/__init__.py @@ -1 +1,4 @@ -from . import estate_property \ No newline at end of file +from . import estate_property +from . import esatate_property_type +from . import estate_property_tags +from . import estate_property_offer diff --git a/estate/models/esatate_property_type.py b/estate/models/esatate_property_type.py new file mode 100644 index 00000000000..aa6ea5c4671 --- /dev/null +++ b/estate/models/esatate_property_type.py @@ -0,0 +1,8 @@ +from odoo import models,fields + + +class EstatePropertyTyeps(models.Model): + _name="estate.property.types" + _description="Types of Estate Property" + + name=fields.Char(required=True) \ No newline at end of file diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 83ef833a5a2..472fdf27174 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,31 +1,33 @@ from dateutil.relativedelta import relativedelta -from odoo import models,fields +from odoo import models,fields,api,_ +from odoo.exceptions import UserError class EstateProperty(models.Model): _name = 'estate.property' _description = 'Real Estate Property' - name = fields.Char(required=True) + name = fields.Char(required=True,string="Title") description = fields.Text() postcode = fields.Char() date_availability = fields.Date( default=lambda self: fields.Date.today() + relativedelta(months=3), - copy=False) + copy=False,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() + living_area = fields.Integer(string="Living Area (sqm)") + total_area = fields.Float(compute='_compute_total_area',store=True) facades = fields.Integer() garage = fields.Boolean() garden = fields.Boolean() - garden_area = fields.Integer() + garden_area = fields.Integer(string="Garden Area (sqm)") active = fields.Boolean(default=True) garden_orientation = fields.Selection([ ('north','North'), ('south','South'), ('east','East'), ('west','West') - ]) + ],string="Garden Orientation") state = fields.Selection( [ ('new', 'New'), @@ -36,4 +38,59 @@ class EstateProperty(models.Model): ], required=True, copy=False, - default='new') \ No newline at end of file + default='new') + property_type_id = fields.Many2one( + "estate.property.types", 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 + ) + tag_ids = fields.Many2many('estate.property.tags',string="Tags") + + offer_ids = fields.One2many('estate.property.offer','property_id',string="Offers") + + best_price = fields.Float(compute='_get_best_offer_price',store=True) + + + + @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 _get_best_offer_price(self): + for record in self: + prices=record.offer_ids.mapped('price') + record.best_price = max(prices) if prices else 0.0 + + @api.onchange('garden') + def _onchange_garden(self): + for record in self: + if record.garden: + record.garden_area = 10 + record.garden_orientation = 'north' + else: + record.garden_area = 0 + record.garden_orientation = '' + + def action_set_state_sold(self): + for record in self: + if(record.state == 'cancelled'): + raise UserError(_("Cancelled property cannot be sold.")) + print("Cancelled can't be sold") + else: + record.state = 'sold' + return True + + def action_set_state_cancel(self): + for record in self: + if(record.state == 'sold'): + raise UserError(_("Sold property cannot be cancelled.")) + print("Sold can't be cancelled") + else: + record.state = 'cancelled' + return True \ No newline at end of file diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py new file mode 100644 index 00000000000..53284f5d5c2 --- /dev/null +++ b/estate/models/estate_property_offer.py @@ -0,0 +1,43 @@ +from odoo import fields,models,api,_ +from odoo.exceptions import UserError +from datetime import timedelta,datetime + +class EstatePropertyOffer(models.Model): + _name="estate.property.offer" + _description="Offers of Estate Property" + price = fields.Float() + status = fields.Selection([('accepted','Accepted'),('refused','Refused')],copy=False) + partner_id = fields.Many2one('res.partner',string="Partner",required=True) + property_id = fields.Many2one('estate.property',string="Property",required=True) + validity = fields.Integer(default=7) + date_deadline = fields.Date(compute="_compute_deadline",inverse="_inverse_deadline",store=True) + @api.depends('validity') + def _compute_deadline(self): + for record in self: + create_date = record.create_date or datetime.now() + record.date_deadline = create_date + timedelta(days=record.validity) + def _inverse_deadline(self): + for record in self: + create_date = record.create_date or datetime.now() + if record.date_deadline: + delta = record.date_deadline - create_date.date() + record.validity = delta.days + + def action_accept_offer(self): + for record in self: + existing = self.search([ + ('property_id','=',record.property_id.id), + ('status','=','accepted') + ]) + if existing: + raise UserError(_("Another offer has been already accepted.")) + record.status = "accepted" + record.property_id.selling_price = record.price + record.property_id.buyer_id = record.partner_id.id + def action_refuse_offer(self): + for record in self: + if(record.status == 'accepted'): + raise UserError(_("Accepted Offer cannot be Refused")) + else: + record.status = "refused" + diff --git a/estate/models/estate_property_tags.py b/estate/models/estate_property_tags.py new file mode 100644 index 00000000000..61fd46d2dfe --- /dev/null +++ b/estate/models/estate_property_tags.py @@ -0,0 +1,7 @@ +from odoo import fields,models + +class EstatePropertyTags(models.Model): + _name="estate.property.tags" + _description="Estate Property Tags" + + name=fields.Char(required=True) diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv index e0b328dc7fe..5c7225816e9 100644 --- a/estate/security/ir.model.access.csv +++ b/estate/security/ir.model.access.csv @@ -1,2 +1,5 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink estate.access_estate_property,access_estate_property,estate.model_estate_property,,1,1,1,1 +estate.access_estate_property_types,access_estate_property_types,estate.model_estate_property_types,base.group_user,1,1,1,1 +estate.access_estate_property_tags,access_estate_property_tags,estate.model_estate_property_tags,base.group_user,1,1,1,1 +estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml index 5349474fef3..83a27f68ae2 100644 --- a/estate/views/estate_menus.xml +++ b/estate/views/estate_menus.xml @@ -1,10 +1,13 @@ - - - - - + - - + + + + + + + + + \ No newline at end of file diff --git a/estate/views/estate_property_tags.xml b/estate/views/estate_property_tags.xml new file mode 100644 index 00000000000..59eb625f206 --- /dev/null +++ b/estate/views/estate_property_tags.xml @@ -0,0 +1,35 @@ + + + Property Tags + estate.property.tags + list,form + + + + + + + estate.property.tags.list + estate.property.tags + + + + + + + + + + estate.property.tags.form + estate.property.tags + form + +
+ + + +
+
+ +
+
\ No newline at end of file diff --git a/estate/views/estate_property_type_views.xml b/estate/views/estate_property_type_views.xml new file mode 100644 index 00000000000..1203fd2527d --- /dev/null +++ b/estate/views/estate_property_type_views.xml @@ -0,0 +1,35 @@ + + + Property Types + estate.property.types + list,form + + + + + + + estate.property.types.list + estate.property.types + + + + + + + + + + estate.property.types.form + estate.property.types + form + +
+ + + +
+
+ +
+
\ No newline at end of file diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 81a481bbad1..46cd5ff56a0 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -11,13 +11,13 @@ list - - - - - - - + + + + + + + @@ -28,51 +28,65 @@ form
+
+

+
+
+
- - - + + + - - + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +
+

+ +

+
+ + + + + + + + + + + +
diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 46cd5ff56a0..3c114c3c302 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -3,6 +3,7 @@ Properties estate.property list,form + {'search_default_available':1} @@ -10,14 +11,20 @@ estate.property list - + + + - + @@ -29,8 +36,11 @@
-
@@ -39,11 +49,11 @@
- +
- + @@ -62,21 +72,25 @@ - - + + - - + + - - + +
+ +

- - - - - - - - - + + + + + + + + +
-
- +
- \ No newline at end of file + diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 3c114c3c302..215118425ff 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -5,7 +5,6 @@ list,form {'search_default_available':1} - estate.property.list estate.property @@ -28,8 +27,7 @@
- - + estate.property.form estate.property form @@ -38,18 +36,16 @@
-
+

-
- +
+
@@ -66,15 +62,15 @@ - - - - - - - - - + + + + + + + + + @@ -91,7 +87,6 @@ 'accepted','refused')"/> +
+

+ +

+
+ + + diff --git a/awesome_owl/static/src/components/counter/counter.js b/awesome_owl/static/src/components/counter/counter.js new file mode 100644 index 00000000000..c31bda38769 --- /dev/null +++ b/awesome_owl/static/src/components/counter/counter.js @@ -0,0 +1,22 @@ +import { Component, useState } from "@odoo/owl" + +export class Counter extends Component{ + static template = "awsome_owl.Counter" + static props = { + onChange: {type: Function, optional: true} + } + + setup(){ + this.info = { message: "Hello from Card!" }; + this.state = useState({ count:0 }); + + } + + increment(){ + this.state.count++; + + if(this.props.onChange){ + this.props.onChange() + } + } +} \ No newline at end of file diff --git a/awesome_owl/static/src/components/counter/counter.xml b/awesome_owl/static/src/components/counter/counter.xml new file mode 100644 index 00000000000..feb03d6d11f --- /dev/null +++ b/awesome_owl/static/src/components/counter/counter.xml @@ -0,0 +1,9 @@ + + + +
+

Counter:

+ +
+
+
diff --git a/awesome_owl/static/src/components/todo_list/todo_item.js b/awesome_owl/static/src/components/todo_list/todo_item.js new file mode 100644 index 00000000000..8e0adc32430 --- /dev/null +++ b/awesome_owl/static/src/components/todo_list/todo_item.js @@ -0,0 +1,27 @@ +import { Component } from "@odoo/owl" + +export class TodoItem extends Component{ + static template = "awsome_owl.todo_item" + + static props = { + deleteTodo:{ type : Function}, + toggleState: { type: Function }, + todo : { + type : Object, + shape :{ + id : Number, + description : String, + isCompleted : Boolean + } + } + } + + toggleState() { + this.props.toggleState(this.props.todo.id); + } + + + removeTodo(){ + this.props.deleteTodo(this.props.todo.id) + } +} \ No newline at end of file diff --git a/awesome_owl/static/src/components/todo_list/todo_item.xml b/awesome_owl/static/src/components/todo_list/todo_item.xml new file mode 100644 index 00000000000..31dffed0587 --- /dev/null +++ b/awesome_owl/static/src/components/todo_list/todo_item.xml @@ -0,0 +1,12 @@ + + + +
+ +
+ . +
+ +
+
+
diff --git a/awesome_owl/static/src/components/todo_list/todo_list.js b/awesome_owl/static/src/components/todo_list/todo_list.js new file mode 100644 index 00000000000..81e9807df59 --- /dev/null +++ b/awesome_owl/static/src/components/todo_list/todo_list.js @@ -0,0 +1,46 @@ +import { Component, useState, useRef, onMounted} from "@odoo/owl" +import { TodoItem } from "./todo_item" +import { useAutoFocus } from "../../lib/utils"; + +export class TodoList extends Component { + static template = "awsome_owl.todo_list"; + static components = { TodoItem }; + + setup(){ + this.todos = useState([]) + this.state = useState({nextId:1}) + this.inputRef = useAutoFocus("add-input"); + } + + addTodo(e){ + if(e.keyCode === 13){ + const todoDesc = e.target.value.trim(); + e.target.value = ""; + if(todoDesc){ + const newTodo = { + id: this.state.nextId++, + description: todoDesc, + isCompleted: false + } + this.todos.push(newTodo); + } + } + } + + deleteTodo(id){ + const index = this.todos.findIndex(t=>t.id == id) + + if(index>=0){ + this.todos.splice(index,1) + } + } + + + toggleTodoState(id) { + const todo = this.todos.find(t => t.id == id); + if (todo) { + todo.isCompleted = !todo.isCompleted; + } +} + +} diff --git a/awesome_owl/static/src/components/todo_list/todo_list.xml b/awesome_owl/static/src/components/todo_list/todo_list.xml new file mode 100644 index 00000000000..48bdcaa35b1 --- /dev/null +++ b/awesome_owl/static/src/components/todo_list/todo_list.xml @@ -0,0 +1,20 @@ + + + +
+
+ +
+
+ + + + + + +

No Todos.

+
+
+
+
+
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 657fb8b07bb..d036b9cee98 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,7 +1,21 @@ /** @odoo-module **/ -import { Component } from "@odoo/owl"; +import { Component, useState, markup } from "@odoo/owl"; +import { Counter } from "./components/counter/counter"; +import { Card } from "./components/card/card"; +import { TodoList } from "./components/todo_list/todo_list"; export class Playground extends Component { static template = "awesome_owl.playground"; + static components = { Counter,Card, TodoList }; + + + setup(){ + this.state = useState({ sum : 0 }); + this.html = markup("
some content
"); + } + + incrementSum(){ + this.state.sum++; + } } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4fb905d59f9..1842264ea2b 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -3,8 +3,20 @@
- hello world + + +
The sum is:
+
+
+ + + + + + +
+
+
- From f093f18a8d6ead04e285084009933470b3b4b2b4 Mon Sep 17 00:00:00 2001 From: zadh-odoo Date: Mon, 21 Jul 2025 18:26:22 +0530 Subject: [PATCH 10/11] [ADD] awesome_dashboard: implement dashboard module using owl Developed a custom dashboard module utilizing OWL and JavaScript to present important business metrics in a visually appealing and interactive interface. The dashboard pulls real-time data from backend models, displaying it through summary cards and various charts. This module serves as a practical example of constructing responsive dashboards in Odoo with client-side rendering and tailor-made components --- awesome_dashboard/static/src/dashboard.js | 10 -- awesome_dashboard/static/src/dashboard.xml | 8 -- .../dashboard_item/dashboard_item.js | 22 +++++ .../dashboard_item/dashboard_item.xml | 10 ++ .../components/number_card/number_card.js | 13 +++ .../components/number_card/number_card.xml | 8 ++ .../pie_chart_card/pie_chart_card.js | 50 ++++++++++ .../pie_chart_card/pie_chart_card.xml | 8 ++ .../components/services/statistics_service.js | 31 +++++++ .../static/src/dashboard/dashboard.js | 91 +++++++++++++++++++ .../static/src/dashboard/dashboard.scss | 10 ++ .../static/src/dashboard/dashboard.xml | 42 +++++++++ .../static/src/dashboard/dashboard_items.js | 65 +++++++++++++ .../static/src/dashboard_action.js | 12 +++ 14 files changed, 362 insertions(+), 18 deletions(-) delete mode 100644 awesome_dashboard/static/src/dashboard.js delete mode 100644 awesome_dashboard/static/src/dashboard.xml create mode 100644 awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.js create mode 100644 awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.xml create mode 100644 awesome_dashboard/static/src/dashboard/components/number_card/number_card.js create mode 100644 awesome_dashboard/static/src/dashboard/components/number_card/number_card.xml create mode 100644 awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.js create mode 100644 awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.xml create mode 100644 awesome_dashboard/static/src/dashboard/components/services/statistics_service.js create mode 100644 awesome_dashboard/static/src/dashboard/dashboard.js create mode 100644 awesome_dashboard/static/src/dashboard/dashboard.scss create mode 100644 awesome_dashboard/static/src/dashboard/dashboard.xml create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_items.js create mode 100644 awesome_dashboard/static/src/dashboard_action.js diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js deleted file mode 100644 index 637fa4bb972..00000000000 --- a/awesome_dashboard/static/src/dashboard.js +++ /dev/null @@ -1,10 +0,0 @@ -/** @odoo-module **/ - -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/components/dashboard_item/dashboard_item.js b/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.js new file mode 100644 index 00000000000..b3b257ec877 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.js @@ -0,0 +1,22 @@ +import { Component } from "@odoo/owl" + +export class DashboardItem extends Component{ + static template = "awesome_dashboard.dashboard_item" + static props = { + slots:{ + type: Object, + shape: { + default: Object + } + }, + size:{ + type: Number, + default: 1, + optional: true + } + } + + setup(){ + this.size = this.props.size || 1 + } +} diff --git a/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.xml b/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.xml new file mode 100644 index 00000000000..adebcefe291 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.xml @@ -0,0 +1,10 @@ + + + +
+
+ +
+
+
+
diff --git a/awesome_dashboard/static/src/dashboard/components/number_card/number_card.js b/awesome_dashboard/static/src/dashboard/components/number_card/number_card.js new file mode 100644 index 00000000000..5a6c39dc2a5 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/components/number_card/number_card.js @@ -0,0 +1,13 @@ +import { Component } from "@odoo/owl"; + +export class NumberCard extends Component{ + static template = "awesome_dashboard.number_card" + static props = { + title :{ + type:String + }, + value:{ + type:[Number,String] + } + } +} diff --git a/awesome_dashboard/static/src/dashboard/components/number_card/number_card.xml b/awesome_dashboard/static/src/dashboard/components/number_card/number_card.xml new file mode 100644 index 00000000000..a80cb4e1d99 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/components/number_card/number_card.xml @@ -0,0 +1,8 @@ + +

+ +

+
+ +
+
diff --git a/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.js b/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.js new file mode 100644 index 00000000000..ccdfaaffc00 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.js @@ -0,0 +1,50 @@ +import { Component, onWillStart,onMounted, useRef, onWillUpdateProps } from "@odoo/owl"; +import { loadJS } from "@web/core/assets"; +import { _t } from "@web/core/l10n/translation"; + + +export class PieChartCard extends Component{ + static template = "awesome_dashboard.pie_chart" + + setup(){ + this.canvasRef = useRef("canvas") + + onWillStart(async()=>{ + await loadJS("/web/static/lib/Chart/Chart.js") + }) + onMounted(() => { + this.renderChart(); + }); + onWillUpdateProps((nextProps) => { + if (this.chart) { + this.chart.destroy(); + } + this.renderChart(nextProps.data); + }); + } + + + renderChart(){ + const labels = Object.keys(this.props.data); + const data = Object.values(this.props.data); + const color = ["#007BFF", "#FFA500", "#808090",]; + const ctx = this.canvasRef.el.getContext("2d"); + this.chart = new Chart(ctx,{ + type:"pie", + data:{ + labels:labels, + datasets: [ + { + label: this.props.title, + data:data, + backgroundColor: color + } + ] + }, + options: { + responsive: true, + maintainAspectRatio: false + }, + }) + } +} diff --git a/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.xml b/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.xml new file mode 100644 index 00000000000..986cc145e31 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.xml @@ -0,0 +1,8 @@ + +

+ +

+
+ +
+
diff --git a/awesome_dashboard/static/src/dashboard/components/services/statistics_service.js b/awesome_dashboard/static/src/dashboard/components/services/statistics_service.js new file mode 100644 index 00000000000..ad328b333fe --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/components/services/statistics_service.js @@ -0,0 +1,31 @@ +import { registry } from "@web/core/registry"; +import { rpc } from "@web/core/network/rpc"; +import { reactive } from "@odoo/owl"; + +const statisticsService = { + start(){ + const stats = reactive({ + nb_new_orders: 0, + total_amount: 0, + average_quantity: 0, + nb_cancelled_orders: 0, + average_time: 0, + orders_by_size: { m: 0, s: 0, xl: 0 } + }); + const loadStatistics = async () => { + const result = await rpc("/awesome_dashboard/statistics"); + + if (result) { + Object.assign(stats, result); + } + }; + loadStatistics(); + setInterval(() => { + loadStatistics(); + }, 10*60*1000); + + return {data : stats}; + } +} + +registry.category("services").add("awesome_dashboard.statistics", statisticsService); diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js new file mode 100644 index 00000000000..734815e6980 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -0,0 +1,91 @@ +/** @odoo-module **/ + +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 { Dialog } from "@web/core/dialog/dialog"; +import { CheckBox } from "@web/core/checkbox/checkbox"; +import { browser } from "@web/core/browser/browser"; +import { DashboardItem } from "@awesome_dashboard/dashboard/components/dashboard_item/dashboard_item"; + +class AwesomeDashboard extends Component { + static template = "awesome_dashboard.AwesomeDashboard"; + static components = { Layout ,DashboardItem } + + setup(){ + this.action = useService("action") + this.dialog = useService("dialog") + this.statisticsService = useService("awesome_dashboard.statistics"); + this.statistics = useState(this.statisticsService.data); + this.display = { controlPanel: {} } + this.items = registry.category("awesome_dashboard").getAll(); + this.state = useState({ + disabledItems: browser.localStorage.getItem("disabledDashboardItems")?.split(",") || [] + }) + } + + openCustomersKanban(){ + 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"] + ] + }) + } + + openConfigDialog(){ + this.dialog.add(ConfigurationDialog, { + items: this.items, + disabledItems: this.state.disabledItems, + onUpdateConfiguration: this.updateConfiguration.bind(this), + }) + } + + updateConfiguration(newDisabledItems) { + this.state.disabledItems = newDisabledItems; + } + +} + +class ConfigurationDialog extends Component{ + static template = "awesome_dashboard.ConfigurationDialog"; + static components = { CheckBox, Dialog }; + + + setup(){ + this.items = useState(this.props.items.map((item)=>{ + return { + ...item, + enabled: !this.props.disabledItems.includes(item.id) + } + })) + } + + done(){ + this.props.close(); + } + + onChange(checked, changedItem) { + changedItem.enabled = checked; + const newDisabledItems = Object.values(this.items).filter( + (item) => !item.enabled + ).map((item) => item.id) + + browser.localStorage.setItem( + "disabledDashboardItems", + newDisabledItems, + ); + + this.props.onUpdateConfiguration(newDisabledItems); + } +} + +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..d1c3017ae50 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard.scss @@ -0,0 +1,10 @@ +.o_dashboard{ + background-color: gray; +} + +@media (max-width: 767px) { + .pie-chart-card { + width: 100% !important; + margin-bottom: 16px; + } +} diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml new file mode 100644 index 00000000000..f909b28ed71 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + +
+ + + + + + +
+
+
+ + + + Which cards do you want to see? + + + + + + + + + + + +
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..6b70ebb6ff5 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_items.js @@ -0,0 +1,65 @@ +import { NumberCard } from "@awesome_dashboard/dashboard/components/number_card/number_card"; +import { registry } from "@web/core/registry"; +import { PieChartCard } from "@awesome_dashboard/dashboard/components/pie_chart_card/pie_chart_card"; +import { _t } from "@web/core/l10n/translation"; + + +const items = [ + { + id:"new_orders", + description:_t("Number of new orders this month"), + Component: NumberCard, + props:(data)=>({ + title:_t("Number of new orders this month"), + value:data.nb_new_orders + }) + }, + { + id:"amount_new_orders", + description:_t("Total amount of new orders this month"), + Component: NumberCard, + props:(data)=>({ + title:_t("Total amount of new orders this month"), + value:data.total_amount + }) + }, + { + id:"average_quantity", + description:_t("Average amount of t-shirt by order this month"), + Component: NumberCard, + props:(data)=>({ + title:_t("Average amount of t-shirt by order this month"), + value:data.average_quantity + }) + }, + { + id:"cancelled_orders", + description:_t("Number of cancelled orders this month"), + Component: NumberCard, + props:(data)=>({ + title:_t("Number of cancelled orders this month"), + value:data.nb_cancelled_orders + }) + }, + { + id:"average_time", + description:_t("Average time for an order to go from ‘new’ to ‘sent’ or ‘cancelled’"), + Component: NumberCard, + props:(data)=>({ + title:_t("Average time for an order to go from ‘new’ to ‘sent’ or ‘cancelled’"), + value:data.average_time + }) + }, + { + 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 + }) + } +] + +items.forEach((item)=>{registry.category("awesome_dashboard").add(item.id,item)}) diff --git a/awesome_dashboard/static/src/dashboard_action.js b/awesome_dashboard/static/src/dashboard_action.js new file mode 100644 index 00000000000..54cb1cdd940 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard_action.js @@ -0,0 +1,12 @@ +import { Component, xml } from "@odoo/owl"; +import { LazyComponent } from "@web/core/assets"; +import { registry } from "@web/core/registry"; + +class AwesomeDashboardAction extends Component{ + static components = { LazyComponent }; + static template = xml` + + ` +} + +registry.category("actions").add("awesome_dashboard.dashboard",AwesomeDashboardAction); From 112b3af33388beb34bb4c917aa7d7f5a5b4b58b0 Mon Sep 17 00:00:00 2001 From: zadh-odoo Date: Tue, 22 Jul 2025 10:28:06 +0530 Subject: [PATCH 11/11] [FIX] estate,estate_estate,awesome_owl,awesome_dashboard: fix issues and code improvements - Fixed linting issues - Added missing licensing - Removed unnecessary code --- .../dashboard_item/dashboard_item.js | 19 +----- .../dashboard_item/dashboard_item.xml | 10 +-- .../components/number_card/number_card.js | 10 +-- .../components/number_card/number_card.xml | 16 ++--- .../pie_chart_card/pie_chart_card.js | 37 +++++------ .../pie_chart_card/pie_chart_card.xml | 15 +++-- .../components/services/statistics_service.js | 7 +-- .../static/src/dashboard/dashboard.js | 37 ++++++----- .../static/src/dashboard/dashboard.scss | 4 -- .../static/src/dashboard/dashboard.xml | 31 +++++----- .../static/src/dashboard/dashboard_items.js | 62 +++++++++---------- .../static/src/dashboard_action.js | 4 +- .../static/src/components/card/card.js | 6 +- .../static/src/components/card/card.xml | 4 +- .../static/src/components/counter/counter.js | 20 +++--- .../static/src/components/counter/counter.xml | 6 +- .../src/components/todo_list/todo_item.js | 22 +++---- .../src/components/todo_list/todo_item.xml | 4 +- .../src/components/todo_list/todo_list.js | 36 +++++------ .../src/components/todo_list/todo_list.xml | 8 +-- awesome_owl/static/src/playground.js | 18 +++--- awesome_owl/static/src/playground.xml | 17 ++--- estate/__manifest__.py | 24 ++++++- estate/demo/demo_data.xml | 13 ++-- estate/models/__init__.py | 4 +- estate/models/esatate_property_type.py | 21 ++----- estate/models/estate_property.py | 48 +++++++------- estate/models/estate_property_offer.py | 30 +++------ estate/models/estate_property_tags.py | 7 +-- estate/models/inherited_res_users.py | 12 ---- estate/models/res_users.py | 10 +++ estate/report/estate_property_reports.xml | 21 ++++--- estate/report/estate_property_templates.xml | 21 +++---- .../report/estate_user_properties_report.xml | 19 +++--- .../estate_user_properties_templates.xml | 59 +++++++++--------- estate/security/ir.model.access.csv | 3 +- estate/security/security.xml | 9 ++- estate/views/estate_menus.xml | 9 +-- estate/views/estate_property_offers.xml | 12 ++-- estate/views/estate_property_tags.xml | 3 +- estate/views/estate_property_type_views.xml | 8 +-- estate/views/estate_property_views.xml | 22 +++---- estate/views/res_users_views.xml | 1 + estate_account/__init__.py | 2 + estate_account/models/estate_property.py | 42 ++++--------- .../report/estate_property_report_inherit.xml | 1 + 46 files changed, 360 insertions(+), 434 deletions(-) delete mode 100644 estate/models/inherited_res_users.py create mode 100644 estate/models/res_users.py diff --git a/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.js b/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.js index b3b257ec877..b383b9bc812 100644 --- a/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.js +++ b/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.js @@ -1,22 +1,9 @@ import { Component } from "@odoo/owl" -export class DashboardItem extends Component{ +export class DashboardItem extends Component { static template = "awesome_dashboard.dashboard_item" static props = { - slots:{ - type: Object, - shape: { - default: Object - } - }, - size:{ - type: Number, - default: 1, - optional: true - } - } - - setup(){ - this.size = this.props.size || 1 + slots: { type: Object, shape: { default: Object } }, + size: { type: Number, default: 1, optional: true } } } diff --git a/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.xml b/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.xml index adebcefe291..b338385c421 100644 --- a/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.xml +++ b/awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.xml @@ -1,10 +1,10 @@ - + -
-
- +
+
+ +
-
diff --git a/awesome_dashboard/static/src/dashboard/components/number_card/number_card.js b/awesome_dashboard/static/src/dashboard/components/number_card/number_card.js index 5a6c39dc2a5..27399dc4d24 100644 --- a/awesome_dashboard/static/src/dashboard/components/number_card/number_card.js +++ b/awesome_dashboard/static/src/dashboard/components/number_card/number_card.js @@ -1,13 +1,9 @@ import { Component } from "@odoo/owl"; -export class NumberCard extends Component{ +export class NumberCard extends Component { static template = "awesome_dashboard.number_card" static props = { - title :{ - type:String - }, - value:{ - type:[Number,String] - } + title: { type: String }, + value: { type: [Number, String] } } } diff --git a/awesome_dashboard/static/src/dashboard/components/number_card/number_card.xml b/awesome_dashboard/static/src/dashboard/components/number_card/number_card.xml index a80cb4e1d99..6b12226a555 100644 --- a/awesome_dashboard/static/src/dashboard/components/number_card/number_card.xml +++ b/awesome_dashboard/static/src/dashboard/components/number_card/number_card.xml @@ -1,8 +1,8 @@ - -

- -

-
- -
-
+ + + +

+
+
+
+
diff --git a/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.js b/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.js index ccdfaaffc00..125e9c8192b 100644 --- a/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.js +++ b/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.js @@ -1,15 +1,15 @@ -import { Component, onWillStart,onMounted, useRef, onWillUpdateProps } from "@odoo/owl"; +import { Component, onWillStart, onMounted, useRef, onWillUpdateProps } from "@odoo/owl"; import { loadJS } from "@web/core/assets"; import { _t } from "@web/core/l10n/translation"; -export class PieChartCard extends Component{ +export class PieChartCard extends Component { static template = "awesome_dashboard.pie_chart" - setup(){ + setup() { this.canvasRef = useRef("canvas") - onWillStart(async()=>{ + onWillStart(async () => { await loadJS("/web/static/lib/Chart/Chart.js") }) onMounted(() => { @@ -23,28 +23,21 @@ export class PieChartCard extends Component{ }); } - - renderChart(){ - const labels = Object.keys(this.props.data); - const data = Object.values(this.props.data); - const color = ["#007BFF", "#FFA500", "#808090",]; - const ctx = this.canvasRef.el.getContext("2d"); - this.chart = new Chart(ctx,{ - type:"pie", - data:{ - labels:labels, - datasets: [ - { - label: this.props.title, - data:data, - backgroundColor: color - } - ] + renderChart() { + this.chart = new Chart(this.canvasRef.el.getContext("2d"), { + type: "pie", + data: { + labels: Object.keys(this.props.data), + datasets: [{ + label: this.props.title, + data: Object.values(this.props.data), + backgroundColor: ["#007BFF", "#FFA500", "#808090"] + }] }, options: { responsive: true, maintainAspectRatio: false - }, + }, }) } } diff --git a/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.xml b/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.xml index 986cc145e31..c88c31d97da 100644 --- a/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.xml +++ b/awesome_dashboard/static/src/dashboard/components/pie_chart_card/pie_chart_card.xml @@ -1,8 +1,7 @@ - -

- -

-
- -
-
+ + + +

+
+
+
diff --git a/awesome_dashboard/static/src/dashboard/components/services/statistics_service.js b/awesome_dashboard/static/src/dashboard/components/services/statistics_service.js index ad328b333fe..c39a1f060e8 100644 --- a/awesome_dashboard/static/src/dashboard/components/services/statistics_service.js +++ b/awesome_dashboard/static/src/dashboard/components/services/statistics_service.js @@ -3,7 +3,7 @@ import { rpc } from "@web/core/network/rpc"; import { reactive } from "@odoo/owl"; const statisticsService = { - start(){ + start() { const stats = reactive({ nb_new_orders: 0, total_amount: 0, @@ -14,7 +14,6 @@ const statisticsService = { }); const loadStatistics = async () => { const result = await rpc("/awesome_dashboard/statistics"); - if (result) { Object.assign(stats, result); } @@ -22,9 +21,9 @@ const statisticsService = { loadStatistics(); setInterval(() => { loadStatistics(); - }, 10*60*1000); + }, 10 * 60 * 1000); - return {data : stats}; + return { data: stats }; } } diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index 734815e6980..c1205c3be16 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -1,5 +1,3 @@ -/** @odoo-module **/ - import { Component, useState, onWillStart } from "@odoo/owl"; import { registry } from "@web/core/registry"; import { Layout } from "@web/search/layout"; @@ -11,13 +9,13 @@ import { DashboardItem } from "@awesome_dashboard/dashboard/components/dashboard class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; - static components = { Layout ,DashboardItem } + static components = { Layout, DashboardItem } - setup(){ + setup() { this.action = useService("action") this.dialog = useService("dialog") this.statisticsService = useService("awesome_dashboard.statistics"); - this.statistics = useState(this.statisticsService.data); + this.statistics = useState(this.statisticsService.data); this.display = { controlPanel: {} } this.items = registry.category("awesome_dashboard").getAll(); this.state = useState({ @@ -25,23 +23,23 @@ class AwesomeDashboard extends Component { }) } - openCustomersKanban(){ + openCustomersKanban() { this.action.doAction("base.action_partner_form") } - openLeads(){ + openLeads() { this.action.doAction({ type: "ir.actions.act_window", name: "Leads", res_model: "crm.lead", - views:[ - [false,"list"], - [false,"form"] + views: [ + [false, "list"], + [false, "form"] ] }) } - openConfigDialog(){ + openConfigDialog() { this.dialog.add(ConfigurationDialog, { items: this.items, disabledItems: this.state.disabledItems, @@ -55,13 +53,18 @@ class AwesomeDashboard extends Component { } -class ConfigurationDialog extends Component{ +class ConfigurationDialog extends Component { static template = "awesome_dashboard.ConfigurationDialog"; static components = { CheckBox, Dialog }; - - - setup(){ - this.items = useState(this.props.items.map((item)=>{ + static props = { + items: { type: Array }, + disabledItems: { type: Array }, + onUpdateConfiguration: { type: Function }, + close: { type: Function } + }; + + setup() { + this.items = useState(this.props.items.map((item) => { return { ...item, enabled: !this.props.disabledItems.includes(item.id) @@ -69,7 +72,7 @@ class ConfigurationDialog extends Component{ })) } - done(){ + done() { this.props.close(); } diff --git a/awesome_dashboard/static/src/dashboard/dashboard.scss b/awesome_dashboard/static/src/dashboard/dashboard.scss index d1c3017ae50..d76f98760b5 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.scss +++ b/awesome_dashboard/static/src/dashboard/dashboard.scss @@ -1,7 +1,3 @@ -.o_dashboard{ - background-color: gray; -} - @media (max-width: 767px) { .pie-chart-card { width: 100% !important; diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml index f909b28ed71..bcbf60f7cb6 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -1,42 +1,39 @@ - + - - + - - + + -
- - - - - - + + + + + +
- Which cards do you want to see? - + - - - +
diff --git a/awesome_dashboard/static/src/dashboard/dashboard_items.js b/awesome_dashboard/static/src/dashboard/dashboard_items.js index 6b70ebb6ff5..af421ea8fe8 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard_items.js +++ b/awesome_dashboard/static/src/dashboard/dashboard_items.js @@ -6,60 +6,60 @@ import { _t } from "@web/core/l10n/translation"; const items = [ { - id:"new_orders", - description:_t("Number of new orders this month"), + id: "new_orders", + description: _t("Number of new orders this month"), Component: NumberCard, - props:(data)=>({ - title:_t("Number of new orders this month"), - value:data.nb_new_orders + props: (data) => ({ + title: _t("Number of new orders this month"), + value: data.nb_new_orders }) }, { - id:"amount_new_orders", - description:_t("Total amount of new orders this month"), + id: "amount_new_orders", + description: _t("Total amount of new orders this month"), Component: NumberCard, - props:(data)=>({ - title:_t("Total amount of new orders this month"), - value:data.total_amount + props: (data) => ({ + title: _t("Total amount of new orders this month"), + value: data.total_amount }) }, { - id:"average_quantity", - description:_t("Average amount of t-shirt by order this month"), + id: "average_quantity", + description: _t("Average amount of t-shirt by order this month"), Component: NumberCard, - props:(data)=>({ - title:_t("Average amount of t-shirt by order this month"), - value:data.average_quantity + props: (data) => ({ + title: _t("Average amount of t-shirt by order this month"), + value: data.average_quantity }) }, { - id:"cancelled_orders", - description:_t("Number of cancelled orders this month"), + id: "cancelled_orders", + description: _t("Number of cancelled orders this month"), Component: NumberCard, - props:(data)=>({ - title:_t("Number of cancelled orders this month"), - value:data.nb_cancelled_orders + props: (data) => ({ + title: _t("Number of cancelled orders this month"), + value: data.nb_cancelled_orders }) }, { - id:"average_time", - description:_t("Average time for an order to go from ‘new’ to ‘sent’ or ‘cancelled’"), + id: "average_time", + description: _t("Average time for an order to go from ‘new’ to ‘sent’ or ‘cancelled’"), Component: NumberCard, - props:(data)=>({ - title:_t("Average time for an order to go from ‘new’ to ‘sent’ or ‘cancelled’"), - value:data.average_time + props: (data) => ({ + title: _t("Average time for an order to go from ‘new’ to ‘sent’ or ‘cancelled’"), + value: data.average_time }) }, { - id:"pie_chart", - description:_t("Shirt orders by size"), + id: "pie_chart", + description: _t("Shirt orders by size"), Component: PieChartCard, - size:2, - props:(data)=>({ - title:_t("Shirt orders by size"), + size: 2, + props: (data) => ({ + title: _t("Shirt orders by size"), data: data.orders_by_size }) } ] -items.forEach((item)=>{registry.category("awesome_dashboard").add(item.id,item)}) +items.forEach((item) => { registry.category("awesome_dashboard").add(item.id, item) }) diff --git a/awesome_dashboard/static/src/dashboard_action.js b/awesome_dashboard/static/src/dashboard_action.js index 54cb1cdd940..edffe8ceefe 100644 --- a/awesome_dashboard/static/src/dashboard_action.js +++ b/awesome_dashboard/static/src/dashboard_action.js @@ -2,11 +2,11 @@ import { Component, xml } from "@odoo/owl"; import { LazyComponent } from "@web/core/assets"; import { registry } from "@web/core/registry"; -class AwesomeDashboardAction extends Component{ +class AwesomeDashboardAction extends Component { static components = { LazyComponent }; static template = xml` ` } -registry.category("actions").add("awesome_dashboard.dashboard",AwesomeDashboardAction); +registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboardAction); diff --git a/awesome_owl/static/src/components/card/card.js b/awesome_owl/static/src/components/card/card.js index f6bce4d6b4b..e26af1a990f 100644 --- a/awesome_owl/static/src/components/card/card.js +++ b/awesome_owl/static/src/components/card/card.js @@ -1,9 +1,9 @@ import { Component, useState } from "@odoo/owl" -export class Card extends Component{ - static template="awsome_owl123.Card"; +export class Card extends Component { + static template = "awsome_owl123.Card"; static props = { - title : {type: String}, + title: { type: String }, slots: { type: Object, optional: true }, }; setup() { diff --git a/awesome_owl/static/src/components/card/card.xml b/awesome_owl/static/src/components/card/card.xml index 416b5bc0d87..f92312f076c 100644 --- a/awesome_owl/static/src/components/card/card.xml +++ b/awesome_owl/static/src/components/card/card.xml @@ -1,10 +1,10 @@ - +
-
+
diff --git a/awesome_owl/static/src/components/todo_list/todo_item.js b/awesome_owl/static/src/components/todo_list/todo_item.js index 8e0adc32430..9e074b895e4 100644 --- a/awesome_owl/static/src/components/todo_list/todo_item.js +++ b/awesome_owl/static/src/components/todo_list/todo_item.js @@ -1,27 +1,27 @@ import { Component } from "@odoo/owl" -export class TodoItem extends Component{ +export class TodoItem extends Component { static template = "awsome_owl.todo_item" static props = { - deleteTodo:{ type : Function}, + deleteTodo: { type: Function }, toggleState: { type: Function }, - todo : { - type : Object, - shape :{ - id : Number, - description : String, - isCompleted : Boolean + todo: { + type: Object, + shape: { + id: Number, + description: String, + isCompleted: Boolean } } } toggleState() { - this.props.toggleState(this.props.todo.id); + this.props.toggleState(this.props.todo.id); } - removeTodo(){ + removeTodo() { this.props.deleteTodo(this.props.todo.id) } -} \ No newline at end of file +} diff --git a/awesome_owl/static/src/components/todo_list/todo_item.xml b/awesome_owl/static/src/components/todo_list/todo_item.xml index 31dffed0587..a109fd88840 100644 --- a/awesome_owl/static/src/components/todo_list/todo_item.xml +++ b/awesome_owl/static/src/components/todo_list/todo_item.xml @@ -1,10 +1,10 @@ - +
- . + .
diff --git a/awesome_owl/static/src/components/todo_list/todo_list.js b/awesome_owl/static/src/components/todo_list/todo_list.js index 81e9807df59..fa5427d222f 100644 --- a/awesome_owl/static/src/components/todo_list/todo_list.js +++ b/awesome_owl/static/src/components/todo_list/todo_list.js @@ -1,46 +1,44 @@ -import { Component, useState, useRef, onMounted} from "@odoo/owl" -import { TodoItem } from "./todo_item" -import { useAutoFocus } from "../../lib/utils"; +import { Component, useState } from "@odoo/owl"; +import { TodoItem } from "@awesome_owl/components/todo_list/todo_item"; +import { useAutoFocus } from "@awesome_owl/lib/utils"; export class TodoList extends Component { static template = "awsome_owl.todo_list"; static components = { TodoItem }; - setup(){ - this.todos = useState([]) - this.state = useState({nextId:1}) + setup() { + this.state = useState({ nextId: 1, todos: [] }) this.inputRef = useAutoFocus("add-input"); } - addTodo(e){ - if(e.keyCode === 13){ + addTodo(e) { + if (e.keyCode === 13) { const todoDesc = e.target.value.trim(); e.target.value = ""; - if(todoDesc){ + if (todoDesc) { const newTodo = { id: this.state.nextId++, description: todoDesc, isCompleted: false } - this.todos.push(newTodo); + this.state.todos.push(newTodo); } } } - deleteTodo(id){ - const index = this.todos.findIndex(t=>t.id == id) - - if(index>=0){ - this.todos.splice(index,1) + deleteTodo(id) { + const index = this.state.todos.findIndex(t => t.id == id) + if (index >= 0) { + this.state.todos.splice(index, 1) } } toggleTodoState(id) { - const todo = this.todos.find(t => t.id == id); - if (todo) { - todo.isCompleted = !todo.isCompleted; + const todo = this.state.todos.find(t => t.id == id); + if (todo) { + todo.isCompleted = !todo.isCompleted; + } } -} } diff --git a/awesome_owl/static/src/components/todo_list/todo_list.xml b/awesome_owl/static/src/components/todo_list/todo_list.xml index 48bdcaa35b1..bea43b373e9 100644 --- a/awesome_owl/static/src/components/todo_list/todo_list.xml +++ b/awesome_owl/static/src/components/todo_list/todo_list.xml @@ -1,4 +1,4 @@ - +
@@ -6,9 +6,9 @@
- - - + + + diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index d036b9cee98..2b4895d71c1 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,21 +1,19 @@ /** @odoo-module **/ -import { Component, useState, markup } from "@odoo/owl"; -import { Counter } from "./components/counter/counter"; -import { Card } from "./components/card/card"; -import { TodoList } from "./components/todo_list/todo_list"; +import { Component, useState } from "@odoo/owl"; +import { Counter } from "@awesome_owl/components/counter/counter"; +import { Card } from "@awesome_owl/components/card/card"; +import { TodoList } from "@awesome_owl/components/todo_list/todo_list"; export class Playground extends Component { static template = "awesome_owl.playground"; - static components = { Counter,Card, TodoList }; - + static components = { Counter, Card, TodoList }; - setup(){ - this.state = useState({ sum : 0 }); - this.html = markup("
some content
"); + setup() { + this.state = useState({ sum: 0 }); } - incrementSum(){ + incrementSum() { this.state.sum++; } } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 1842264ea2b..d80394e8ba8 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -1,19 +1,14 @@ - + -
- - -
The sum is:
+ + +
The sum is:
- - - - - - + +
diff --git a/estate/__manifest__.py b/estate/__manifest__.py index edc6f244817..670e5c5baa6 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -1,12 +1,30 @@ { 'name': "Real Estate", - 'summary': "This is real estate module", + 'summary': "Manage real estate properties, offers, and sales in Odoo", 'category': "Real Estate/Brokerage", - 'description': "This is real estate module", + 'description': ( + "This module allows you to manage real estate properties, offers, property types, and related data. " + "It includes basic listing management, offer tracking, reporting capabilities, and user access controls. " + "Suitable for use in property management workflows within the Odoo system." + ), 'author': "Dhruvrajsinh Zala (zadh)", 'installable': True, 'application': True, - 'data': ['security/security.xml', 'security/ir.model.access.csv', 'report/estate_property_templates.xml', 'report/estate_user_properties_templates.xml', 'report/estate_user_properties_report.xml', 'report/estate_property_reports.xml', 'views/estate_property_views.xml', 'views/estate_property_offers.xml', 'views/estate_property_type_views.xml', 'views/estate_property_tags.xml', 'views/res_users_views.xml', 'views/estate_menus.xml', 'data/estate.property.types.csv'], + 'data': [ + 'security/security.xml', + 'security/ir.model.access.csv', + 'report/estate_property_templates.xml', + 'report/estate_user_properties_templates.xml', + 'report/estate_user_properties_report.xml', + 'report/estate_property_reports.xml', + 'views/estate_property_views.xml', + 'views/estate_property_offers.xml', + 'views/estate_property_type_views.xml', + 'views/estate_property_tags.xml', + 'views/res_users_views.xml', + 'views/estate_menus.xml', + 'data/estate.property.types.csv', + ], 'demo': ['demo/demo_data.xml'], 'license': 'AGPL-3' } diff --git a/estate/demo/demo_data.xml b/estate/demo/demo_data.xml index 0a68bd348cd..2366868f468 100644 --- a/estate/demo/demo_data.xml +++ b/estate/demo/demo_data.xml @@ -1,3 +1,4 @@ + Big Villa @@ -46,7 +47,9 @@ 200000 south - + @@ -69,9 +72,9 @@ 1500001 14 - + - + 1000 @@ -92,10 +95,10 @@ 1500001 14 - + - + diff --git a/estate/models/__init__.py b/estate/models/__init__.py index 20abfcfc336..3561724904f 100644 --- a/estate/models/__init__.py +++ b/estate/models/__init__.py @@ -1,5 +1,7 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + from . import estate_property from . import esatate_property_type from . import estate_property_tags from . import estate_property_offer -from . import inherited_res_users +from . import res_users diff --git a/estate/models/esatate_property_type.py b/estate/models/esatate_property_type.py index 35d25b23211..28bcefeaefa 100644 --- a/estate/models/esatate_property_type.py +++ b/estate/models/esatate_property_type.py @@ -1,3 +1,5 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + from odoo import models, fields, api @@ -5,24 +7,13 @@ class EstatePropertyTyeps(models.Model): _name = "estate.property.types" _description = "Types of Estate Property" _order = "sequence, name" - - _sql_constraints = [ - ("_unique_type_name", "UNIQUE(name)", "Property type name must be unique.") - ] + _sql_constraints = [("_unique_type_name", "UNIQUE(name)", "Property type name must be unique.")] name = fields.Char(required=True, string="Title") - property_ids = fields.One2many( - "estate.property", "property_type_id", string="Properties" - ) + property_ids = fields.One2many("estate.property", "property_type_id", string="Properties") sequence = fields.Integer(default=1, string="sequence") - - offer_ids = fields.One2many( - "estate.property.offer", "property_type_id", string="Offers" - ) - - offer_count = fields.Integer( - string="Offer Count", compute="_compute_offer_count", store=True - ) + offer_ids = fields.One2many("estate.property.offer", "property_type_id", string="Offers") + offer_count = fields.Integer(string="Offer Count", compute="_compute_offer_count", store=True) @api.depends("offer_ids") def _compute_offer_count(self): diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 5bf24b15b7b..7b2673cebb6 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,3 +1,5 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + from dateutil.relativedelta import relativedelta from odoo import models, fields, api, _ from odoo.tools.float_utils import float_compare, float_is_zero @@ -10,26 +12,15 @@ class EstateProperty(models.Model): _order = "id desc" _sql_constraints = [ - ( - "_check_expected_price", - "CHECK(expected_price > 0)", - "The expected price must be positive.", - ), - ( - "_check_selling_price", - "CHECK(selling_price >= 0)", - "The selling price must be positive.", - ), + ("_check_expected_price", "CHECK(expected_price > 0)", "The expected price must be positive."), + ("_check_selling_price", "CHECK(selling_price >= 0)", "The selling price must be positive.") ] name = fields.Char(required=True, string="Title") description = fields.Text(string="Description") postcode = fields.Char(string="Postcode") - date_availability = fields.Date( - default=lambda self: fields.Date.today() + relativedelta(months=3), - copy=False, - string="Available From", - ) + date_availability = fields.Date(default=lambda self: fields.Date.today() + relativedelta(months=3), + copy=False, string="Available From") expected_price = fields.Float(required=True, string="Expected Price") selling_price = fields.Float(readonly=True, copy=False, string="Selling Price") bedrooms = fields.Integer(default=2, string="Bedrooms") @@ -40,22 +31,25 @@ class EstateProperty(models.Model): garden = fields.Boolean(string="Garden") garden_area = fields.Integer(string="Garden Area (sqm)") active = fields.Boolean(default=True, string="Active") - garden_orientation = fields.Selection( - [("north", "North"), ("south", "South"), ("east", "East"), ("west", "West")], - string="Garden Orientation", - ) - state = fields.Selection([("new", "New"), ("offer_received", "Offer Received"), ("offer_accepted", "Offer Accepted"), ("sold", "Sold"), ("cancelled", "Cancelled")], required=True, copy=False, default="new", string="State") + garden_orientation = fields.Selection([ + ("north", "North"), + ("south", "South"), + ("east", "East"), + ("west", "West") + ], string="Garden Orientation") + state = fields.Selection([ + ("new", "New"), + ("offer_received", "Offer Received"), + ("offer_accepted", "Offer Accepted"), + ("sold", "Sold"), + ("cancelled", "Cancelled") + ], required=True, copy=False, default="new", string="State") property_type_id = fields.Many2one("estate.property.types", 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 - ) + salesperson_id = fields.Many2one("res.users", string="Salesperson", default=lambda self: self.env.user) tag_ids = fields.Many2many("estate.property.tags", string="Tags") - offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers") - best_price = fields.Float(compute="_get_best_offer_price", store=True, string="Best Price") - company_id = fields.Many2one('res.company', required=True, default=lambda self: self.env.company) @api.ondelete(at_uninstall=False) @@ -89,7 +83,7 @@ def action_set_state_sold(self): for record in self: if record.state == "cancelled": raise UserError(_("Cancelled property cannot be sold.")) - if not record.offer_ids.filtered(lambda o: o.status == "accepted"): + if not record.offer_ids.filtered(lambda offer: offer.status == "accepted"): raise UserError(_("You cannot sell a property without an accepted offer.")) record.state = "sold" return True diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 9cb1c25ec69..e5974c1d19c 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -1,3 +1,5 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + from odoo import fields, models, api, _ from odoo.exceptions import UserError, ValidationError from datetime import timedelta, datetime @@ -7,22 +9,14 @@ class EstatePropertyOffer(models.Model): _name = "estate.property.offer" _description = "Offers of Estate Property" _order = "price desc" - _sql_constraints = [ - ("_check_offer_price", "CHECK(price > 0)", "The Offer price must be positive.") - ] + _sql_constraints = [("_check_offer_price", "CHECK(price > 0)", "The Offer price must be positive.")] price = fields.Float(string="Price") - status = fields.Selection( - [("accepted", "Accepted"), ("refused", "Refused")], copy=False, string="Status" - ) + status = fields.Selection([("accepted", "Accepted"), ("refused", "Refused")], copy=False, string="Status") 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( - "estate.property.types", - related="property_id.property_type_id", - string="Property Type", - required=True, - ) + property_type_id = fields.Many2one("estate.property.types", related="property_id.property_type_id", + string="Property Type", required=True) validity = fields.Integer(default=7, string="Validity") date_deadline = fields.Date(compute="_compute_deadline", inverse="_inverse_deadline", store=True, string="Deadline Date") @@ -38,18 +32,13 @@ def create(self, vals): fields=["price:max"], groupby=[], ) - max_price = result[0]["price"] if result else 0 - if property.state == 'sold': raise ValidationError(_("Cannot create an offer on a sold property.")) - if max_price >= offer_price: raise UserError(_("You cannot create an offer with a lower or equal amount than an existing offer for this property.")) - if is_state_new: property.state = "offer_received" - return super().create(vals) @api.depends("validity") @@ -67,12 +56,7 @@ def _inverse_deadline(self): def action_accept_offer(self): for record in self: - existing = self.search( - [ - ("property_id", "=", record.property_id.id), - ("status", "=", "accepted"), - ] - ) + existing = self.search([("property_id", "=", record.property_id.id), ("status", "=", "accepted")]) if existing: raise UserError(_("Another offer has been already accepted.")) record.status = "accepted" diff --git a/estate/models/estate_property_tags.py b/estate/models/estate_property_tags.py index dea946fcf3a..37c7130825c 100644 --- a/estate/models/estate_property_tags.py +++ b/estate/models/estate_property_tags.py @@ -1,3 +1,5 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + from odoo import fields, models @@ -5,10 +7,7 @@ class EstatePropertyTags(models.Model): _name = "estate.property.tags" _description = "Estate Property Tags" _order = "name" - - _sql_constraints = [ - ("_unique_tag_name", "UNIQUE(name)", "Tag name must be unique.") - ] + _sql_constraints = [("_unique_tag_name", "UNIQUE(name)", "Tag name must be unique.")] name = fields.Char(required=True, string="Title") color = fields.Integer(default=3, string="Color") diff --git a/estate/models/inherited_res_users.py b/estate/models/inherited_res_users.py deleted file mode 100644 index d64f961e841..00000000000 --- a/estate/models/inherited_res_users.py +++ /dev/null @@ -1,12 +0,0 @@ -from odoo import models, fields - - -class InheritedResUsers(models.Model): - _inherit = "res.users" - - property_ids = fields.One2many( - "estate.property", - "salesperson_id", - string="Available Properties", - domain=[("state", "in", ["new", "offer_received"])], - ) diff --git a/estate/models/res_users.py b/estate/models/res_users.py new file mode 100644 index 00000000000..37511537056 --- /dev/null +++ b/estate/models/res_users.py @@ -0,0 +1,10 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models, fields + + +class ResUsers(models.Model): + _inherit = "res.users" + + property_ids = fields.One2many("estate.property", "salesperson_id", string="Available Properties", + domain=[("state", "in", ["new", "offer_received"])]) diff --git a/estate/report/estate_property_reports.xml b/estate/report/estate_property_reports.xml index 8b9821b41dc..ee201b1db61 100644 --- a/estate/report/estate_property_reports.xml +++ b/estate/report/estate_property_reports.xml @@ -1,12 +1,13 @@ + - - Property Offers Report - estate.property - qweb-pdf - estate.report_property_offers - estate.report_property_offers - 'Property Offers - %s' % (object.name) - - report - + + Property Offers Report + estate.property + qweb-pdf + estate.report_property_offers + estate.report_property_offers + 'Property Offers - %s' % (object.name) + + report + diff --git a/estate/report/estate_property_templates.xml b/estate/report/estate_property_templates.xml index 366c345a823..f929486da04 100644 --- a/estate/report/estate_property_templates.xml +++ b/estate/report/estate_property_templates.xml @@ -1,10 +1,11 @@ + diff --git a/estate/report/estate_user_properties_report.xml b/estate/report/estate_user_properties_report.xml index 20717fc4777..9f7bd042433 100644 --- a/estate/report/estate_user_properties_report.xml +++ b/estate/report/estate_user_properties_report.xml @@ -1,12 +1,13 @@ + - - User Properties Report - res.users - qweb-pdf - estate.report_user_properties - estate.report_user_properties - 'User Properties - %s' % (object.name) - - report + + User Properties Report + res.users + qweb-pdf + estate.report_user_properties + estate.report_user_properties + 'User Properties - %s' % (object.name) + + report diff --git a/estate/report/estate_user_properties_templates.xml b/estate/report/estate_user_properties_templates.xml index 92b8e3ea415..6c1183727c9 100644 --- a/estate/report/estate_user_properties_templates.xml +++ b/estate/report/estate_user_properties_templates.xml @@ -1,35 +1,36 @@ + - diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv index fcfdcd6119d..8b34a30f8aa 100644 --- a/estate/security/ir.model.access.csv +++ b/estate/security/ir.model.access.csv @@ -1,9 +1,10 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +estate.access_estate_property_user,access_estate_property_user,estate.model_estate_property,base.group_user,1,0,0,0 estate.access_estate_property_manager,access_estate_property_manager,estate.model_estate_property,estate.estate_group_manager,1,1,1,0 estate.access_estate_property_agent,access_estate_property_agent,estate.model_estate_property,estate.estate_group_agent,1,1,1,0 estate.access_estate_property_types_manager,access_estate_property_types_manager,estate.model_estate_property_types,estate.estate_group_manager,1,1,1,0 estate.access_estate_property_types_agent,access_estate_property_types_agent,estate.model_estate_property_types,estate.estate_group_agent,1,0,0,0 estate.access_estate_property_tags_manager,access_estate_property_tags_manager,estate.model_estate_property_tags,estate.estate_group_manager,1,1,1,0 -estate.access_estate_property_tags_agent,access_estate_property_tags_agent,estate.model_estate_property_tags,estate.estate_group_agent,1,0,0,0 +estate.access_estate_property_tags_agent,access_estate_property_tags_agent,estate.model_estate_property_types,estate.estate_group_agent,1,0,0,0 estate.access_estate_property_offer_manager,access_estate_property_offer_manager,estate.model_estate_property_offer,estate.estate_group_manager,1,1,1,0 estate.access_estate_property_offer_agent,access_estate_property_offer_agent,estate.model_estate_property_offer,estate.estate_group_agent,1,1,1,0 diff --git a/estate/security/security.xml b/estate/security/security.xml index 7de2f4cab33..3f4f0f73fd2 100644 --- a/estate/security/security.xml +++ b/estate/security/security.xml @@ -1,3 +1,4 @@ + Agent @@ -6,14 +7,13 @@ Manager - + Agent: Own or Unassigned Properties - - ['|',('salesperson_id','=',user.id),('salesperson_id','=',0)] + ['|',('salesperson_id','=',user.id),('salesperson_id','=',0)] @@ -39,4 +39,7 @@ + + + diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml index 446dad58806..4cd0aa9e303 100644 --- a/estate/views/estate_menus.xml +++ b/estate/views/estate_menus.xml @@ -1,11 +1,12 @@ + - + - - - + + + diff --git a/estate/views/estate_property_offers.xml b/estate/views/estate_property_offers.xml index 460c4fe13a1..adbcb03a82a 100644 --- a/estate/views/estate_property_offers.xml +++ b/estate/views/estate_property_offers.xml @@ -10,13 +10,13 @@ estate.property.offer - - - - -
diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 215118425ff..9740f753060 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -1,3 +1,4 @@ + Properties @@ -10,11 +11,7 @@ estate.property list - + @@ -44,7 +41,7 @@
-
+
@@ -74,11 +71,8 @@ - - + + @@ -92,8 +86,8 @@ - - + + @@ -115,7 +109,7 @@ - + diff --git a/estate/views/res_users_views.xml b/estate/views/res_users_views.xml index 87ba0ab5788..605c5be7d48 100644 --- a/estate/views/res_users_views.xml +++ b/estate/views/res_users_views.xml @@ -1,3 +1,4 @@ + res.users.form.inherit.estate diff --git a/estate_account/__init__.py b/estate_account/__init__.py index 0650744f6bc..d6210b1285d 100644 --- a/estate_account/__init__.py +++ b/estate_account/__init__.py @@ -1 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + from . import models diff --git a/estate_account/models/estate_property.py b/estate_account/models/estate_property.py index 6974ce6012f..412929a656a 100644 --- a/estate_account/models/estate_property.py +++ b/estate_account/models/estate_property.py @@ -1,3 +1,5 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + from odoo import models, Command from odoo.exceptions import UserError, AccessError @@ -6,46 +8,26 @@ class EstateProperty(models.Model): _inherit = "estate.property" def action_set_state_sold(self): - res = super().action_set_state_sold() journal = self.env["account.journal"].sudo().search([("type", "=", "sale")], limit=1) - if not journal: raise UserError("No sales journal found!") - try: self.check_access('write') except AccessError: raise UserError("You do not have sufficient access rights to create an invoice for this property.") - for property in self: - if property.buyer_id: commission = property.selling_price * 0.06 admin_fee = 100.00 - self.env["account.move"].sudo().create( - { - "partner_id": property.buyer_id.id, - "move_type": "out_invoice", - "journal_id": journal.id, - "company_id": property.company_id.id, - "invoice_line_ids": [ - Command.create( - { - "name": "Commission (6%)", - "quantity": 1, - "price_unit": commission, - } - ), - Command.create( - { - "name": "Administrative fees", - "quantity": 1, - "price_unit": admin_fee, - } - ), - ], - } - ) - + self.env["account.move"].sudo().create({ + "partner_id": property.buyer_id.id, + "move_type": "out_invoice", + "journal_id": journal.id, + "company_id": property.company_id.id, + "invoice_line_ids": [ + Command.create({"name": "Commission (6%)", "quantity": 1, "price_unit": commission}), + Command.create({"name": "Administrative fees", "quantity": 1, "price_unit": admin_fee}), + ], + }) return res diff --git a/estate_account/report/estate_property_report_inherit.xml b/estate_account/report/estate_property_report_inherit.xml index 64b41b7a8e1..a0a63b69b48 100644 --- a/estate_account/report/estate_property_report_inherit.xml +++ b/estate_account/report/estate_property_report_inherit.xml @@ -1,3 +1,4 @@ +