From e54ea974df977f4bb12bbc8722acdd0211cbe3c6 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 10:29:28 +0100 Subject: [PATCH 01/29] [IMP] estate: chapter 2 add real estate module --- estate/__init__.py | 0 estate/__manifest__.py | 4 ++++ 2 files changed, 4 insertions(+) create mode 100644 estate/__init__.py create mode 100644 estate/__manifest__.py diff --git a/estate/__init__.py b/estate/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/estate/__manifest__.py b/estate/__manifest__.py new file mode 100644 index 00000000000..ebdbd187d8b --- /dev/null +++ b/estate/__manifest__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +{ + 'name': "Real Estate" +} From ab68f584a8e4e1900007e532c41869c083d6d194 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 10:40:28 +0100 Subject: [PATCH 02/29] [IMP] estate: chapter 2 add more info to real estate manifest.py --- estate/__manifest__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/estate/__manifest__.py b/estate/__manifest__.py index ebdbd187d8b..c51a88687a8 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -1,4 +1,14 @@ # -*- coding: utf-8 -*- { - 'name': "Real Estate" + 'name': "Real Estate", + 'author': "Odoo", + 'website': "https://www.odoo.com/", + 'category': 'Tutorials', + 'version': '0.1', + 'application': True, + 'installable': True, + 'depends': ['base', 'web'], + 'data': [], + 'assets': {}, + 'license': 'AGPL-3' } From 27ec85ae3ce2f3d5e90e6c1da4d16b28dd7d6d56 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 11:27:22 +0100 Subject: [PATCH 03/29] [IMP] estate: chapter 3 add model information and basic fields --- estate/__init__.py | 1 + estate/models/__init__.py | 1 + estate/models/estate_property.py | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) 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 index e69de29bb2d..9a7e03eded3 100644 --- a/estate/__init__.py +++ b/estate/__init__.py @@ -0,0 +1 @@ +from . import models \ 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..bf45efc2a13 --- /dev/null +++ b/estate/models/estate_property.py @@ -0,0 +1,18 @@ +from odoo import models, fields + +class EstateProperty(models.Model): + _name = "estate.property" + + name = fields.Char(required=True) + description = fields.Text(string="Description") + postcode = fields.Char() + date_availability = fields.Date(string="Date Availability") + 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"),('east', "East"),('south', "South"),('west', "West")]) \ No newline at end of file From be2b9e4cec93c862148639eb6faadc991fdf424d Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 11:46:15 +0100 Subject: [PATCH 04/29] [IMP] estate: chapter 4 add access rights --- estate/__manifest__.py | 4 +++- estate/security/ir.model.access.csv | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 estate/security/ir.model.access.csv diff --git a/estate/__manifest__.py b/estate/__manifest__.py index c51a88687a8..f159fbd5b72 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -8,7 +8,9 @@ 'application': True, 'installable': True, 'depends': ['base', 'web'], - 'data': [], + 'data': [ + 'security/ir.model.access.csv', + ], 'assets': {}, 'license': 'AGPL-3' } diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv new file mode 100644 index 00000000000..ab63520e22b --- /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,base.group_user,1,1,1,1 \ No newline at end of file From d6bc713b827a5125ea384dbe596c783c5ba48240 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 12:01:26 +0100 Subject: [PATCH 05/29] [IMP] estate: chapter 5 add action --- estate/__manifest__.py | 1 + estate/views/estate_property_views.xml | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 estate/views/estate_property_views.xml diff --git a/estate/__manifest__.py b/estate/__manifest__.py index f159fbd5b72..7313483b49f 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -10,6 +10,7 @@ 'depends': ['base', 'web'], 'data': [ 'security/ir.model.access.csv', + 'views/estate_property_views.xml', ], 'assets': {}, 'license': 'AGPL-3' diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml new file mode 100644 index 00000000000..9b506175aa1 --- /dev/null +++ b/estate/views/estate_property_views.xml @@ -0,0 +1,10 @@ + + + + + Properties + estate.property + list,form + + + From cec72adf9ab29687112c7145dd7008ef5757da0e Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 13:25:14 +0100 Subject: [PATCH 06/29] [CLN] estate: code cleanup to make checks green --- estate/__init__.py | 2 +- estate/__manifest__.py | 1 - estate/models/__init__.py | 2 +- estate/models/estate_property.py | 9 ++++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/estate/__init__.py b/estate/__init__.py index 9a7e03eded3..0650744f6bc 100644 --- a/estate/__init__.py +++ b/estate/__init__.py @@ -1 +1 @@ -from . import models \ No newline at end of file +from . import models diff --git a/estate/__manifest__.py b/estate/__manifest__.py index 7313483b49f..a7660291dd6 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- { 'name': "Real Estate", 'author': "Odoo", diff --git a/estate/models/__init__.py b/estate/models/__init__.py index f4c8fd6db6d..5e1963c9d2f 100644 --- a/estate/models/__init__.py +++ b/estate/models/__init__.py @@ -1 +1 @@ -from . import estate_property \ No newline at end of file +from . import estate_property diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index bf45efc2a13..346c304c2f6 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,18 +1,21 @@ from odoo import models, fields + class EstateProperty(models.Model): _name = "estate.property" + _description = "Estate Property Model" name = fields.Char(required=True) description = fields.Text(string="Description") postcode = fields.Char() date_availability = fields.Date(string="Date Availability") - expected_price= fields.Float(required=True) - selling_price= fields.Float() + 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"),('east', "East"),('south', "South"),('west', "West")]) \ No newline at end of file + garden_orientation = fields.Selection([('north', "North"), ('east', "East"), ('south', "South"), ('west', "West")]) + \ No newline at end of file From f6264e127bb19e635332a1d1fbb061c263000754 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 14:00:19 +0100 Subject: [PATCH 07/29] [IMP] estate: chapter 5 add menus, fields, attributes, views --- estate/__manifest__.py | 1 + estate/models/estate_property.py | 17 +++++++++++++---- estate/views/estate_menus.xml | 8 ++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 estate/views/estate_menus.xml diff --git a/estate/__manifest__.py b/estate/__manifest__.py index a7660291dd6..d1696d6ee1f 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -10,6 +10,7 @@ 'data': [ 'security/ir.model.access.csv', 'views/estate_property_views.xml', + 'views/estate_menus.xml', ], 'assets': {}, 'license': 'AGPL-3' diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 346c304c2f6..4e9be108fd6 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,4 +1,6 @@ from odoo import models, fields +from dateutil.relativedelta import relativedelta +import datetime class EstateProperty(models.Model): @@ -8,14 +10,21 @@ class EstateProperty(models.Model): name = fields.Char(required=True) description = fields.Text(string="Description") postcode = fields.Char() - date_availability = fields.Date(string="Date Availability") + date_availability = fields.Date(string="Date Availability", copy=False, default=datetime.date.today()+relativedelta(months=3)) 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() garden_orientation = fields.Selection([('north', "North"), ('east', "East"), ('south', "South"), ('west', "West")]) - \ No newline at end of file + active = fields.Boolean(default=True) + state = fields.Selection( + string="Status", + selection=[('new', "New"), ('offer_received', "Offer Received"), ('offer_accepted', "Offer Accepted"), ('sold', "Sold"), ('cancelled', "Cancelled")], + required=True, + copy=False, + default="new" + ) diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml new file mode 100644 index 00000000000..806043a8d8e --- /dev/null +++ b/estate/views/estate_menus.xml @@ -0,0 +1,8 @@ + + + + + + + + From b1d66fa58ca82e09b10c7882e0c562c7211206d7 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 14:08:14 +0100 Subject: [PATCH 08/29] [LINT] estate: finally installed a linter --- estate/models/estate_property.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 4e9be108fd6..16542e37976 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -10,7 +10,11 @@ class EstateProperty(models.Model): name = fields.Char(required=True) description = fields.Text(string="Description") postcode = fields.Char() - date_availability = fields.Date(string="Date Availability", copy=False, default=datetime.date.today()+relativedelta(months=3)) + date_availability = fields.Date( + string="Date Availability", + copy=False, + default=datetime.date.today() + relativedelta(months=3), + ) expected_price = fields.Float(required=True) selling_price = fields.Float(readonly=True, copy=False) bedrooms = fields.Integer(default=2) @@ -19,12 +23,20 @@ class EstateProperty(models.Model): garage = fields.Boolean() garden = fields.Boolean() garden_area = fields.Integer() - garden_orientation = fields.Selection([('north', "North"), ('east', "East"), ('south', "South"), ('west', "West")]) + garden_orientation = fields.Selection( + [("north", "North"), ("east", "East"), ("south", "South"), ("west", "West")] + ) active = fields.Boolean(default=True) state = fields.Selection( string="Status", - selection=[('new', "New"), ('offer_received', "Offer Received"), ('offer_accepted', "Offer Accepted"), ('sold', "Sold"), ('cancelled', "Cancelled")], - required=True, - copy=False, - default="new" + selection=[ + ("new", "New"), + ("offer_received", "Offer Received"), + ("offer_accepted", "Offer Accepted"), + ("sold", "Sold"), + ("cancelled", "Cancelled"), + ], + required=True, + copy=False, + default="new", ) From 54a04302cebb1a3531dec9ebcb3c6b74298683c9 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 15:16:19 +0100 Subject: [PATCH 09/29] [IMP] estate: chapter 6 add basic views --- estate/models/estate_property.py | 2 +- estate/views/estate_property_views.xml | 77 ++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 16542e37976..aceae634d52 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -11,7 +11,7 @@ class EstateProperty(models.Model): description = fields.Text(string="Description") postcode = fields.Char() date_availability = fields.Date( - string="Date Availability", + string="Available From", copy=False, default=datetime.date.today() + relativedelta(months=3), ) diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 9b506175aa1..d6dfdd5c736 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -7,4 +7,81 @@ list,form + + estate.property.form + estate.property + + + + + + + + + + + + + + + + estate.property.list + estate.property + +
+ + +

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + estate.property.search + estate.property + + + + + + + + + + + + + + From 8086a69679f54a72c064ef19cdd63127581ce54d Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 17:05:34 +0100 Subject: [PATCH 10/29] [IMP] estate: chapter 7 relations between models --- estate/__manifest__.py | 3 ++ estate/models/__init__.py | 3 ++ estate/models/estate_property.py | 10 ++++++ estate/models/estate_property_offer.py | 17 ++++++++++ estate/models/estate_property_tag.py | 7 ++++ estate/models/estate_property_type.py | 7 ++++ estate/security/ir.model.access.csv | 5 ++- estate/views/estate_menus.xml | 4 +++ estate/views/estate_property_offers_views.xml | 32 +++++++++++++++++++ estate/views/estate_property_tags_views.xml | 10 ++++++ estate/views/estate_property_types_views.xml | 10 ++++++ estate/views/estate_property_views.xml | 15 +++++++-- 12 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 estate/models/estate_property_offer.py create mode 100644 estate/models/estate_property_tag.py create mode 100644 estate/models/estate_property_type.py create mode 100644 estate/views/estate_property_offers_views.xml create mode 100644 estate/views/estate_property_tags_views.xml create mode 100644 estate/views/estate_property_types_views.xml diff --git a/estate/__manifest__.py b/estate/__manifest__.py index d1696d6ee1f..d03b5a36c95 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -10,6 +10,9 @@ 'data': [ 'security/ir.model.access.csv', 'views/estate_property_views.xml', + 'views/estate_property_types_views.xml', + 'views/estate_property_tags_views.xml', + 'views/estate_property_offers_views.xml', 'views/estate_menus.xml', ], 'assets': {}, diff --git a/estate/models/__init__.py b/estate/models/__init__.py index 5e1963c9d2f..2f1821a39c1 100644 --- a/estate/models/__init__.py +++ b/estate/models/__init__.py @@ -1 +1,4 @@ from . import estate_property +from . import estate_property_type +from . import estate_property_tag +from . import estate_property_offer diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index aceae634d52..75ecd385839 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -40,3 +40,13 @@ class EstateProperty(models.Model): copy=False, default="new", ) + property_type_id = fields.Many2one("estate.property.type", string="Property Type") + salesman = fields.Many2one( + "res.users", + string="Salesperson", + index=True, + default=lambda self: self.env.user, + ) + buyer = fields.Many2one("res.partner", string="Buyer", copy=False) + tag_ids = fields.Many2many("estate.property.tag", string="Tags") + offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers") diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py new file mode 100644 index 00000000000..261d9f1dfd8 --- /dev/null +++ b/estate/models/estate_property_offer.py @@ -0,0 +1,17 @@ +from odoo import models, fields + +class EstatePropertyTag(models.Model): + _name = "estate.property.offer" + _description = "Property Offer" + + price = fields.Float() + status = fields.Selection( + string="Offer Status", + selection=[ + ("offer_accepted", "Accepted"), + ("offer_refused", "Refused"), + ], + copy=False, + ) + partner_id = fields.Many2one("res.partner", required=True) + property_id = fields.Many2one("estate.property", required=True) diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py new file mode 100644 index 00000000000..02b5f55a394 --- /dev/null +++ b/estate/models/estate_property_tag.py @@ -0,0 +1,7 @@ +from odoo import models, fields + +class EstatePropertyTag(models.Model): + _name = "estate.property.tag" + _description = "Property Tag" + + name = fields.Char('Tags', required=True) diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py new file mode 100644 index 00000000000..fbaa5c486c8 --- /dev/null +++ b/estate/models/estate_property_type.py @@ -0,0 +1,7 @@ +from odoo import models, fields + +class EstatePropertyType(models.Model): + _name = "estate.property.type" + _description = "Property Type" + + name = fields.Char('Property Type', required=True) diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv index ab63520e22b..0db13e578ec 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,base.group_user,1,1,1,1 \ No newline at end of file +estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1 +estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1 +estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,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 806043a8d8e..ad126197546 100644 --- a/estate/views/estate_menus.xml +++ b/estate/views/estate_menus.xml @@ -4,5 +4,9 @@ + + + + diff --git a/estate/views/estate_property_offers_views.xml b/estate/views/estate_property_offers_views.xml new file mode 100644 index 00000000000..f294a37481a --- /dev/null +++ b/estate/views/estate_property_offers_views.xml @@ -0,0 +1,32 @@ + + + + + estate.property.offer.list + estate.property.offer + + + + + + + + + + + estate.property.offer.form + estate.property.offer + +
+ + + + + + + +
+
+
+ +
\ No newline at end of file diff --git a/estate/views/estate_property_tags_views.xml b/estate/views/estate_property_tags_views.xml new file mode 100644 index 00000000000..3323919e55c --- /dev/null +++ b/estate/views/estate_property_tags_views.xml @@ -0,0 +1,10 @@ + + + + + Property Tags + estate.property.tag + list,form + + + \ No newline at end of file diff --git a/estate/views/estate_property_types_views.xml b/estate/views/estate_property_types_views.xml new file mode 100644 index 00000000000..3187f82295b --- /dev/null +++ b/estate/views/estate_property_types_views.xml @@ -0,0 +1,10 @@ + + + + + Property Types + estate.property.type + list,form + + + \ No newline at end of file diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index d6dfdd5c736..cca395fd22e 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -8,7 +8,7 @@ - estate.property.form + estate.property.list estate.property @@ -25,7 +25,7 @@ - estate.property.list + estate.property.form estate.property
@@ -35,9 +35,11 @@ + + @@ -61,6 +63,15 @@ + + + + + + + + + From 5c21aad75d9b9ef0dbb0792194f640be094781de Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Mon, 16 Mar 2026 17:10:07 +0100 Subject: [PATCH 11/29] [LINT] estate: code cleanup --- .vscode/settings.json | 3 +++ estate/models/estate_property_offer.py | 1 + estate/models/estate_property_tag.py | 1 + estate/models/estate_property_type.py | 1 + 4 files changed, 6 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000000..ff5300ef481 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.languageServer": "None" +} \ No newline at end of file diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 261d9f1dfd8..4721360085a 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -1,5 +1,6 @@ from odoo import models, fields + class EstatePropertyTag(models.Model): _name = "estate.property.offer" _description = "Property Offer" diff --git a/estate/models/estate_property_tag.py b/estate/models/estate_property_tag.py index 02b5f55a394..8a241d7f30e 100644 --- a/estate/models/estate_property_tag.py +++ b/estate/models/estate_property_tag.py @@ -1,5 +1,6 @@ from odoo import models, fields + class EstatePropertyTag(models.Model): _name = "estate.property.tag" _description = "Property Tag" diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py index fbaa5c486c8..b943c9908c0 100644 --- a/estate/models/estate_property_type.py +++ b/estate/models/estate_property_type.py @@ -1,5 +1,6 @@ from odoo import models, fields + class EstatePropertyType(models.Model): _name = "estate.property.type" _description = "Property Type" From d802e954321da9743045fae5b8dfbcc9fc897162 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Tue, 17 Mar 2026 11:34:10 +0100 Subject: [PATCH 12/29] [IMP] estate: chapter 8 computed fields and onchanges --- estate/models/estate_property.py | 27 ++++++++++++++++++- estate/models/estate_property_offer.py | 21 ++++++++++++++- estate/views/estate_property_offers_views.xml | 4 +++ estate/views/estate_property_views.xml | 2 ++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 75ecd385839..ae3e5b3cd14 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,4 +1,4 @@ -from odoo import models, fields +from odoo import models, fields, api from dateutil.relativedelta import relativedelta import datetime @@ -50,3 +50,28 @@ class EstateProperty(models.Model): buyer = fields.Many2one("res.partner", string="Buyer", copy=False) tag_ids = fields.Many2many("estate.property.tag", string="Tags") offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers") + total_area = fields.Integer(compute="_compute_total_area") + best_price = fields.Float(compute="_compute_best_price", string = "Best Price") + + # ------------------------------------------------------------------------- + # COMPUTE METHODS + # ------------------------------------------------------------------------- + + @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() + def _compute_best_price(self): + for record in self: + record.best_price = max(record.offer_ids.mapped('price')) if record.offer_ids else 0 + + @api.onchange("garden") + def _onchange_partner_id(self): + if self.garden: + self.garden_area = self.garden_area or 10 + self.garden_orientation = self.garden_orientation or "north" + else: + self.garden_area = 0 + self.garden_orientation = None diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 4721360085a..7a2f5d2cff2 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -1,4 +1,5 @@ -from odoo import models, fields +from odoo import models, fields, api +from datetime import date, timedelta class EstatePropertyTag(models.Model): @@ -16,3 +17,21 @@ class EstatePropertyTag(models.Model): ) partner_id = fields.Many2one("res.partner", required=True) property_id = fields.Many2one("estate.property", required=True) + validity = fields.Integer(default=7) + date_deadline = fields.Date(compute="_compute_date_deadline", inverse="_inverse_date_deadline") + + # ------------------------------------------------------------------------- + # COMPUTE METHODS + # ------------------------------------------------------------------------- + + @api.depends('validity') + def _compute_date_deadline(self): + for record in self: + start_date = record.create_date.date() if record.create_date else date.today() + record.date_deadline = start_date + timedelta(days=record.validity) + + def _inverse_date_deadline(self): + for record in self: + start_date = record.create_date.date() if record.create_date else date.today() + date_diff = record.date_deadline - start_date + record.validity = date_diff.days diff --git a/estate/views/estate_property_offers_views.xml b/estate/views/estate_property_offers_views.xml index f294a37481a..a53c667bfd8 100644 --- a/estate/views/estate_property_offers_views.xml +++ b/estate/views/estate_property_offers_views.xml @@ -8,6 +8,8 @@ + + @@ -22,6 +24,8 @@ + + diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index cca395fd22e..92b8794b666 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -45,6 +45,7 @@ + @@ -61,6 +62,7 @@ + From 3cecc43c73e6be0383ae39c2c1c8cb4ae799d923 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Tue, 17 Mar 2026 11:59:20 +0100 Subject: [PATCH 13/29] [CLN] estate: address PR comments --- .gitignore | 1 + .vscode/settings.json | 3 --- estate/__manifest__.py | 4 +--- estate/models/estate_property.py | 4 ++-- estate/models/estate_property_type.py | 4 ++-- estate/security/ir.model.access.csv | 2 +- estate/views/estate_property_offers_views.xml | 2 +- estate/views/estate_property_tags_views.xml | 2 +- 8 files changed, 9 insertions(+), 13 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index b6e47617de1..c85b28c30fc 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,4 @@ dmypy.json # Pyre type checker .pyre/ +.vscode/ diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index ff5300ef481..00000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.languageServer": "None" -} \ No newline at end of file diff --git a/estate/__manifest__.py b/estate/__manifest__.py index d03b5a36c95..37d39db7c88 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -3,10 +3,9 @@ 'author': "Odoo", 'website': "https://www.odoo.com/", 'category': 'Tutorials', - 'version': '0.1', 'application': True, 'installable': True, - 'depends': ['base', 'web'], + 'depends': ['base'], 'data': [ 'security/ir.model.access.csv', 'views/estate_property_views.xml', @@ -15,6 +14,5 @@ 'views/estate_property_offers_views.xml', 'views/estate_menus.xml', ], - 'assets': {}, 'license': 'AGPL-3' } diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index ae3e5b3cd14..8028d118a85 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -4,8 +4,8 @@ class EstateProperty(models.Model): - _name = "estate.property" - _description = "Estate Property Model" + _name = 'estate.property' + _description = "Estate Property" name = fields.Char(required=True) description = fields.Text(string="Description") diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py index b943c9908c0..f5ba51f298f 100644 --- a/estate/models/estate_property_type.py +++ b/estate/models/estate_property_type.py @@ -2,7 +2,7 @@ class EstatePropertyType(models.Model): - _name = "estate.property.type" + _name = 'estate.property.type' _description = "Property Type" - name = fields.Char('Property Type', required=True) + name = fields.Char("Property Type", required=True) diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv index 0db13e578ec..0c0b62b7fee 100644 --- a/estate/security/ir.model.access.csv +++ b/estate/security/ir.model.access.csv @@ -2,4 +2,4 @@ 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,base.group_user,1,1,1,1 estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1 estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,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 +estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1 diff --git a/estate/views/estate_property_offers_views.xml b/estate/views/estate_property_offers_views.xml index a53c667bfd8..8d5b5d8d1f6 100644 --- a/estate/views/estate_property_offers_views.xml +++ b/estate/views/estate_property_offers_views.xml @@ -33,4 +33,4 @@
- \ No newline at end of file + diff --git a/estate/views/estate_property_tags_views.xml b/estate/views/estate_property_tags_views.xml index 3323919e55c..87f56756b2a 100644 --- a/estate/views/estate_property_tags_views.xml +++ b/estate/views/estate_property_tags_views.xml @@ -7,4 +7,4 @@ list,form - \ No newline at end of file + From 24a782a8c639a3e1f0dd42491d2f6223fdcf71fc Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Tue, 17 Mar 2026 13:36:03 +0100 Subject: [PATCH 14/29] [IMP] estate: chapter 9 ready for some action --- estate/models/estate_property.py | 17 +++++++++++++++++ estate/models/estate_property_offer.py | 16 ++++++++++++++++ estate/views/estate_property_offers_views.xml | 2 ++ estate/views/estate_property_views.xml | 4 ++++ 4 files changed, 39 insertions(+) diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 8028d118a85..f0f5983613c 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,4 +1,5 @@ from odoo import models, fields, api +from odoo.exceptions import UserError from dateutil.relativedelta import relativedelta import datetime @@ -75,3 +76,19 @@ def _onchange_partner_id(self): else: self.garden_area = 0 self.garden_orientation = None + + def action_sold(self): + for record in self: + if record.state == 'cancelled': + raise UserError("Cancelled properties cannot be sold.") + else: + record.state = 'sold' + return True + + def action_cancel(self): + for record in self: + if record.state == 'sold': + raise UserError("Sold properties cannot be cancelled.") + else: + record.state = 'cancelled' + return True diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 7a2f5d2cff2..8ef1398fc3e 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -1,4 +1,5 @@ from odoo import models, fields, api +from odoo.exceptions import UserError from datetime import date, timedelta @@ -35,3 +36,18 @@ def _inverse_date_deadline(self): start_date = record.create_date.date() if record.create_date else date.today() date_diff = record.date_deadline - start_date record.validity = date_diff.days + + def action_accept_offer(self): + for record in self: + if any([offer.status == 'offer_accepted' for offer in record.property_id.offer_ids]): + raise UserError("Another offer has already been accepted.") + else: + record.property_id.buyer = record.partner_id + record.property_id.selling_price = record.price + record.status = 'offer_accepted' + record.property_id.state = 'offer_accepted' + + def action_refuse_offer(self): + for record in self: + record.status = 'offer_refused' + return True diff --git a/estate/views/estate_property_offers_views.xml b/estate/views/estate_property_offers_views.xml index 8d5b5d8d1f6..b61a5d15b1f 100644 --- a/estate/views/estate_property_offers_views.xml +++ b/estate/views/estate_property_offers_views.xml @@ -10,6 +10,8 @@ + @@ -41,6 +44,7 @@ + diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 70254ef5b8f..37da65d9c6e 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -5,20 +5,24 @@ Properties estate.property list,form + {'search_default_available':1} estate.property.list estate.property - + - + @@ -94,7 +98,7 @@ - + From 6420654261784007a75b7ee894b33a4604bb0771 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Wed, 18 Mar 2026 14:35:58 +0100 Subject: [PATCH 18/29] [IMP] estate: chapter 12 inheritance --- estate/__manifest__.py | 1 + estate/models/__init__.py | 1 + estate/models/estate_property.py | 6 ++++++ estate/models/estate_property_offer.py | 16 +++++++++++++++- estate/models/res_users.py | 11 +++++++++++ estate/views/estate_res_users_views.xml | 18 ++++++++++++++++++ 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 estate/models/res_users.py create mode 100644 estate/views/estate_res_users_views.xml diff --git a/estate/__manifest__.py b/estate/__manifest__.py index 39dc4d06614..f237642a67e 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -12,6 +12,7 @@ 'views/estate_property_tags_views.xml', 'views/estate_property_offers_views.xml', 'views/estate_property_types_views.xml', + 'views/estate_res_users_views.xml', 'views/estate_menus.xml', ], 'license': 'AGPL-3' diff --git a/estate/models/__init__.py b/estate/models/__init__.py index 2f1821a39c1..9a2189b6382 100644 --- a/estate/models/__init__.py +++ b/estate/models/__init__.py @@ -2,3 +2,4 @@ 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 index 70c95b6a590..3778aa7149e 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -65,6 +65,12 @@ class EstateProperty(models.Model): "Selling price must be greater or equal to 0", ) + @api.ondelete(at_uninstall=False) + def unlink_if_property_not_new_or_cancelled(self): + for record in self: + if record.state not in ('new', 'cancelled'): + raise UserError("Properties can only be deleted in 'New' or 'Cancelled' state") + # ------------------------------------------------------------------------- # COMPUTE METHODS # ------------------------------------------------------------------------- diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 7fc9d43c94e..b9e8e2a733f 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -1,5 +1,6 @@ from odoo import models, fields, api -from odoo.exceptions import UserError +from odoo.tools.float_utils import float_compare +from odoo.exceptions import UserError, ValidationError from datetime import date, timedelta @@ -32,6 +33,19 @@ class EstatePropertyOffer(models.Model): "Offer price must be greater than 0", ) + @api.model + def create(self, vals_list): + property_id = vals_list[0].get('property_id') + offer_price = vals_list[0].get('price') + property_model = self.env['estate.property'].browse(property_id) + + if float_compare(offer_price, property_model.best_price, precision_digits=2) < 0: + raise ValidationError("New offers cannot have a lower amount than an existing offer") + + property_model.state = 'offer_received' + + return super().create(vals_list) + # ------------------------------------------------------------------------- # COMPUTE METHODS # ------------------------------------------------------------------------- diff --git a/estate/models/res_users.py b/estate/models/res_users.py new file mode 100644 index 00000000000..8236a2a17c5 --- /dev/null +++ b/estate/models/res_users.py @@ -0,0 +1,11 @@ +from odoo import models, fields + + +class ResUsers(models.Model): + _inherit = 'res.users' + + property_ids = fields.One2many( + "estate.property", + "salesman", + domain="['|',('state', '=', 'new'),('state', '=', 'offer_received')]", + ) diff --git a/estate/views/estate_res_users_views.xml b/estate/views/estate_res_users_views.xml new file mode 100644 index 00000000000..bd6bf2a290b --- /dev/null +++ b/estate/views/estate_res_users_views.xml @@ -0,0 +1,18 @@ + + + + + res.users.view.form.inherit.estate + res.users + + extension + + + + + + + + + + From 5a417374325565647d5a7c0f7f47e7d62f78f4f2 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Wed, 18 Mar 2026 15:49:30 +0100 Subject: [PATCH 19/29] [IMP] estate: chapter 13 add invoicing module --- estate_account/__init__.py | 1 + estate_account/__manifest__.py | 11 +++++++++++ estate_account/models/__init__.py | 1 + estate_account/models/estate_property.py | 24 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 estate_account/__init__.py create mode 100644 estate_account/__manifest__.py create mode 100644 estate_account/models/__init__.py create mode 100644 estate_account/models/estate_property.py diff --git a/estate_account/__init__.py b/estate_account/__init__.py new file mode 100644 index 00000000000..9a7e03eded3 --- /dev/null +++ b/estate_account/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/estate_account/__manifest__.py b/estate_account/__manifest__.py new file mode 100644 index 00000000000..734ceb9f860 --- /dev/null +++ b/estate_account/__manifest__.py @@ -0,0 +1,11 @@ +{ + 'name': "Real Estate Account", + 'author': "Odoo", + 'website': "https://www.odoo.com/", + 'category': 'Tutorials', + 'application': True, + 'installable': True, + 'depends': ['base','estate','account'], + 'data': [], + 'license': 'AGPL-3' +} diff --git a/estate_account/models/__init__.py b/estate_account/models/__init__.py new file mode 100644 index 00000000000..f4c8fd6db6d --- /dev/null +++ b/estate_account/models/__init__.py @@ -0,0 +1 @@ +from . import estate_property \ No newline at end of file diff --git a/estate_account/models/estate_property.py b/estate_account/models/estate_property.py new file mode 100644 index 00000000000..ebde05647fb --- /dev/null +++ b/estate_account/models/estate_property.py @@ -0,0 +1,24 @@ +from odoo import models, Command + +class EstateProperty(models.Model): + _inherit = 'estate.property' + + def action_sold(self): + account = self.env['account.move'].create({ + 'partner_id': self.buyer.id, + 'move_type': 'out_invoice', + 'invoice_line_ids': [ + Command.create({ + 'name': f"6% Downpayment for {self.name}", + 'quantity': 1, + 'price_unit': self.selling_price*0.06 + }), + Command.create({ + 'name': "Administrative Fees", + 'quantity': 1, + 'price_unit': 100 + }), + ] + }) + + return super().action_sold() From 1c9f18bee5bea825d7afc1deb210fd92fd197066 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Wed, 18 Mar 2026 16:05:25 +0100 Subject: [PATCH 20/29] [LINT] estate: fix lint issues --- estate_account/__init__.py | 2 +- estate_account/__manifest__.py | 2 +- estate_account/models/__init__.py | 2 +- estate_account/models/estate_property.py | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/estate_account/__init__.py b/estate_account/__init__.py index 9a7e03eded3..0650744f6bc 100644 --- a/estate_account/__init__.py +++ b/estate_account/__init__.py @@ -1 +1 @@ -from . import models \ No newline at end of file +from . import models diff --git a/estate_account/__manifest__.py b/estate_account/__manifest__.py index 734ceb9f860..b16fc028004 100644 --- a/estate_account/__manifest__.py +++ b/estate_account/__manifest__.py @@ -5,7 +5,7 @@ 'category': 'Tutorials', 'application': True, 'installable': True, - 'depends': ['base','estate','account'], + 'depends': ['base', 'estate', 'account'], 'data': [], 'license': 'AGPL-3' } diff --git a/estate_account/models/__init__.py b/estate_account/models/__init__.py index f4c8fd6db6d..5e1963c9d2f 100644 --- a/estate_account/models/__init__.py +++ b/estate_account/models/__init__.py @@ -1 +1 @@ -from . import estate_property \ No newline at end of file +from . import estate_property diff --git a/estate_account/models/estate_property.py b/estate_account/models/estate_property.py index ebde05647fb..1319130a0ca 100644 --- a/estate_account/models/estate_property.py +++ b/estate_account/models/estate_property.py @@ -1,17 +1,18 @@ from odoo import models, Command + class EstateProperty(models.Model): _inherit = 'estate.property' def action_sold(self): - account = self.env['account.move'].create({ + self.env['account.move'].create({ 'partner_id': self.buyer.id, 'move_type': 'out_invoice', 'invoice_line_ids': [ Command.create({ 'name': f"6% Downpayment for {self.name}", 'quantity': 1, - 'price_unit': self.selling_price*0.06 + 'price_unit': self.selling_price * 0.06 }), Command.create({ 'name': "Administrative Fees", From 1f54f257d69d4efc7206a57564edda86e3d0d6e6 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Wed, 18 Mar 2026 16:07:40 +0100 Subject: [PATCH 21/29] [IMP] estate: add check for empty values --- estate/models/estate_property_offer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index b9e8e2a733f..11e123e5c97 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -35,6 +35,9 @@ class EstatePropertyOffer(models.Model): @api.model def create(self, vals_list): + if not vals_list: + return super().create(vals_list) + property_id = vals_list[0].get('property_id') offer_price = vals_list[0].get('price') property_model = self.env['estate.property'].browse(property_id) From 3b337106e368fe5776c933374e089ddab1d244e9 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Wed, 18 Mar 2026 16:34:06 +0100 Subject: [PATCH 22/29] [IMP] estate: chapter 14 add kanban view --- estate/views/estate_property_views.xml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 37da65d9c6e..5fe6298e070 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -4,7 +4,7 @@ Properties estate.property - list,form + list,form,kanban {'search_default_available':1} @@ -106,4 +106,28 @@ + + estate.property.kanban + estate.property + + + + + +
+ +

Expected Price:

+
+

Best Price:

+
+
+

Selling Price:

+
+
+
+
+
+
+
+ From cce31cd92bc9d4561e41d8da6a6fe65fb0485558 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Fri, 20 Mar 2026 09:35:40 +0100 Subject: [PATCH 23/29] [IMP] awesome_owl: add owl components --- awesome_owl/static/src/card/card.js | 17 +++++++++++ awesome_owl/static/src/card/card.xml | 20 +++++++++++++ awesome_owl/static/src/counter/counter.js | 20 +++++++++++++ awesome_owl/static/src/counter/counter.xml | 9 ++++++ awesome_owl/static/src/playground.js | 19 +++++++++++- awesome_owl/static/src/playground.xml | 12 ++++++++ awesome_owl/static/src/todolist/todoitem.js | 20 +++++++++++++ awesome_owl/static/src/todolist/todoitem.xml | 12 ++++++++ awesome_owl/static/src/todolist/todolist.js | 31 ++++++++++++++++++++ awesome_owl/static/src/todolist/todolist.xml | 13 ++++++++ awesome_owl/static/src/utils.js | 8 +++++ awesome_owl/views/templates.xml | 1 + estate/models/estate_property.py | 2 ++ estate/models/res_users.py | 2 +- 14 files changed, 184 insertions(+), 2 deletions(-) create mode 100644 awesome_owl/static/src/card/card.js create mode 100644 awesome_owl/static/src/card/card.xml create mode 100644 awesome_owl/static/src/counter/counter.js create mode 100644 awesome_owl/static/src/counter/counter.xml create mode 100644 awesome_owl/static/src/todolist/todoitem.js create mode 100644 awesome_owl/static/src/todolist/todoitem.xml create mode 100644 awesome_owl/static/src/todolist/todolist.js create mode 100644 awesome_owl/static/src/todolist/todolist.xml create mode 100644 awesome_owl/static/src/utils.js diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js new file mode 100644 index 00000000000..3bf80869353 --- /dev/null +++ b/awesome_owl/static/src/card/card.js @@ -0,0 +1,17 @@ +import { useState, Component } from "@odoo/owl"; + +export class Card extends Component { + static template = "awesome_owl.card"; + static props = { + title: {type: String}, + slots: Object, + }; + + setup() { + this.state = useState({ isVisible: true }); + } + + toggleContent() { + this.state.isVisible = !this.state.isVisible; + } +} diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml new file mode 100644 index 00000000000..2239ccdb143 --- /dev/null +++ b/awesome_owl/static/src/card/card.xml @@ -0,0 +1,20 @@ + + + + +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js new file mode 100644 index 00000000000..8e114226bf2 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.js @@ -0,0 +1,20 @@ +import { useState, Component } from "@odoo/owl"; + +export class Counter extends Component { + static template = "awesome_owl.counter"; + + static props = { + onChange: {type: Function, optional: true} + }; + + setup() { + this.state = useState({ value: 0 }); + } + + increment() { + this.state.value++; + if (this.props.onChange) { + this.props.onChange() + } + } +} diff --git a/awesome_owl/static/src/counter/counter.xml b/awesome_owl/static/src/counter/counter.xml new file mode 100644 index 00000000000..5e0ec2135c0 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.xml @@ -0,0 +1,9 @@ + + + + +

Counter:

+ +
+ +
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 4ac769b0aa5..b8c49d6d905 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,5 +1,22 @@ -import { Component } from "@odoo/owl"; +import { Component, markup, useState } from "@odoo/owl"; +import { Counter } from "./counter/counter"; +import { Card } from "./card/card"; +import { TodoList } from "./todolist/todolist"; + export class Playground extends Component { static template = "awesome_owl.playground"; + static components = { Counter, Card, TodoList }; + static props = [] + + value1 = "
some text 1
"; + value2 = markup("
some text 2 using markup
"); + + setup() { + this.sum = useState({ value: 2 }); + } + + incrementSum() { + this.sum.value++ + } } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4fb905d59f9..1e45abf4fa3 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -5,6 +5,18 @@
hello world
+ + + + default content of card 1 + + + + + + +

Sum

+
diff --git a/awesome_owl/static/src/todolist/todoitem.js b/awesome_owl/static/src/todolist/todoitem.js new file mode 100644 index 00000000000..a7326c8de8c --- /dev/null +++ b/awesome_owl/static/src/todolist/todoitem.js @@ -0,0 +1,20 @@ +import { useState, Component } from "@odoo/owl"; + +export class TodoItem extends Component { + static template = "awesome_owl.todoitem"; + static props = { + todo: { + type: Object, + shape: { + id: {type: Number}, + description: {type: String}, + isCompleted: {type: Boolean} + } + }, + removeTodo: {type: Function, optional: true} + }; + + onRemove() { + this.props.removeTodo(this.props.todo.id) + } +} diff --git a/awesome_owl/static/src/todolist/todoitem.xml b/awesome_owl/static/src/todolist/todoitem.xml new file mode 100644 index 00000000000..a20b530be45 --- /dev/null +++ b/awesome_owl/static/src/todolist/todoitem.xml @@ -0,0 +1,12 @@ + + + + +
+ ID: + Description: + +
+
+ +
diff --git a/awesome_owl/static/src/todolist/todolist.js b/awesome_owl/static/src/todolist/todolist.js new file mode 100644 index 00000000000..c107d29d69f --- /dev/null +++ b/awesome_owl/static/src/todolist/todolist.js @@ -0,0 +1,31 @@ +import { useState, Component } from "@odoo/owl"; +import { TodoItem } from "./todoitem"; +import { useAutoFocus } from "../utils"; + +export class TodoList extends Component { + static template = "awesome_owl.todolist"; + static components = { TodoItem }; + static props = [] + + setup() { + this.todos = useState([]); + this.idCounter = 0 + useAutoFocus("todolist_input"); + } + + addTodo(ev) { + if (ev.keyCode === 13 && ev.target.value) { + this.todos.push({id: this.idCounter, description: ev.target.value, isCompleted: false}) + this.idCounter++ + ev.target.value = '' + } + } + + removeTodo(idToRemove) { + const index = this.todos.findIndex(todo => todo.id === idToRemove); + if (index !== -1) { + this.todos.splice(index, 1); + } + } + +} diff --git a/awesome_owl/static/src/todolist/todolist.xml b/awesome_owl/static/src/todolist/todolist.xml new file mode 100644 index 00000000000..f835bbbee7e --- /dev/null +++ b/awesome_owl/static/src/todolist/todolist.xml @@ -0,0 +1,13 @@ + + + + +
+ + + + +
+
+ +
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js new file mode 100644 index 00000000000..b8c2bb12daa --- /dev/null +++ b/awesome_owl/static/src/utils.js @@ -0,0 +1,8 @@ +import {onMounted, useRef} from "@odoo/owl"; + +export function useAutoFocus(refName) { + const myRef = useRef(refName); + onMounted(() => { + myRef.el.focus(); + }); +} \ No newline at end of file diff --git a/awesome_owl/views/templates.xml b/awesome_owl/views/templates.xml index aa54c1a7241..3df6b44bd5b 100644 --- a/awesome_owl/views/templates.xml +++ b/awesome_owl/views/templates.xml @@ -5,6 +5,7 @@ + diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 3778aa7149e..0edec891473 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -3,6 +3,7 @@ from odoo.tools.float_utils import float_compare, float_is_zero from dateutil.relativedelta import relativedelta import datetime +import ipdb class EstateProperty(models.Model): @@ -82,6 +83,7 @@ def _compute_total_area(self): @api.depends() def _compute_best_price(self): + ipdb.set_trace() for record in self: record.best_price = ( max(record.offer_ids.mapped("price")) if record.offer_ids else 0 diff --git a/estate/models/res_users.py b/estate/models/res_users.py index 8236a2a17c5..4d2ab44e5c2 100644 --- a/estate/models/res_users.py +++ b/estate/models/res_users.py @@ -7,5 +7,5 @@ class ResUsers(models.Model): property_ids = fields.One2many( "estate.property", "salesman", - domain="['|',('state', '=', 'new'),('state', '=', 'offer_received')]", + domain=['|',('state', '=', 'new'),('state', '=', 'offer_received')], ) From 84a165d723bed947b378a7c09d5e87f5894e645f Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Fri, 20 Mar 2026 10:02:13 +0100 Subject: [PATCH 24/29] [CLN] estate: general code clean up --- .gitignore | 1 - estate/models/estate_property.py | 29 +++++++++++++--------- estate/models/estate_property_offer.py | 33 +++++++++++++------------- estate/models/res_users.py | 2 +- estate_account/__manifest__.py | 1 + 5 files changed, 36 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index c85b28c30fc..b6e47617de1 100644 --- a/.gitignore +++ b/.gitignore @@ -127,4 +127,3 @@ dmypy.json # Pyre type checker .pyre/ -.vscode/ diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 0edec891473..6f238cedbe6 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -3,7 +3,6 @@ from odoo.tools.float_utils import float_compare, float_is_zero from dateutil.relativedelta import relativedelta import datetime -import ipdb class EstateProperty(models.Model): @@ -12,12 +11,12 @@ class EstateProperty(models.Model): _order = "id desc" name = fields.Char(required=True) - description = fields.Text(string="Description") + description = fields.Text() postcode = fields.Char() date_availability = fields.Date( string="Available From", copy=False, - default=datetime.date.today() + relativedelta(months=3), + default=lambda self: fields.Date.today() + relativedelta(months=3), ) expected_price = fields.Float(required=True) selling_price = fields.Float(readonly=True, copy=False) @@ -51,9 +50,13 @@ class EstateProperty(models.Model): index=True, default=lambda self: self.env.user, ) - buyer = fields.Many2one("res.partner", string="Buyer", copy=False) - tag_ids = fields.Many2many("estate.property.tag", string="Tags") - offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers") + buyer = fields.Many2one(comodel_name="res.partner", string="Buyer", copy=False) + tag_ids = fields.Many2many(comodel_name="estate.property.tag", string="Tags") + offer_ids = fields.One2many( + comodel_name="estate.property.offer", + inverse_name="property_id", + string="Offers", + ) total_area = fields.Integer(compute="_compute_total_area") best_price = fields.Float(compute="_compute_best_price", string="Best Price") @@ -69,8 +72,10 @@ class EstateProperty(models.Model): @api.ondelete(at_uninstall=False) def unlink_if_property_not_new_or_cancelled(self): for record in self: - if record.state not in ('new', 'cancelled'): - raise UserError("Properties can only be deleted in 'New' or 'Cancelled' state") + if record.state not in ("new", "cancelled"): + raise UserError( + "Properties can only be deleted in 'New' or 'Cancelled' state" + ) # ------------------------------------------------------------------------- # COMPUTE METHODS @@ -83,7 +88,6 @@ def _compute_total_area(self): @api.depends() def _compute_best_price(self): - ipdb.set_trace() for record in self: record.best_price = ( max(record.offer_ids.mapped("price")) if record.offer_ids else 0 @@ -115,10 +119,13 @@ def action_cancel(self): return True @api.constrains("selling_price", "expected_price") - def check_selling_price(self): + def _check_selling_price(self): for record in self: if not float_is_zero(record.selling_price, precision_digits=2): - if float_compare(record.selling_price, record.expected_price * 0.9, 2) < 0: + if ( + float_compare(record.selling_price, record.expected_price * 0.9, 2) + < 0 + ): raise ValidationError( "The selling price cannot be lower than 90% of the expected price." ) diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 11e123e5c97..f44082618c7 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -5,27 +5,27 @@ class EstatePropertyOffer(models.Model): - _name = "estate.property.offer" + _name = 'estate.property.offer' _description = "Property Offer" - _order = "price desc" + _order = 'price desc' price = fields.Float() status = fields.Selection( string="Offer Status", selection=[ - ("offer_accepted", "Accepted"), - ("offer_refused", "Refused"), + ('offer_accepted', "Accepted"), + ('offer_refused', "Refused"), ], copy=False, ) - partner_id = fields.Many2one("res.partner", required=True) - property_id = fields.Many2one("estate.property", required=True) + partner_id = fields.Many2one(comodel_name='res.partner', required=True) + property_id = fields.Many2one(comodel_name='estate.property', required=True) validity = fields.Integer(default=7) date_deadline = fields.Date( - compute="_compute_date_deadline", inverse="_inverse_date_deadline" + compute='_compute_date_deadline', inverse='_inverse_date_deadline' ) property_type_id = fields.Many2one( - "estate.property.type", related="property_id.property_type_id", store=True + comodel_name='estate.property.type', related='property_id.property_type_id', store=True ) _check_offer_price = models.Constraint( @@ -33,7 +33,7 @@ class EstatePropertyOffer(models.Model): "Offer price must be greater than 0", ) - @api.model + @api.model_create_multi def create(self, vals_list): if not vals_list: return super().create(vals_list) @@ -53,7 +53,7 @@ def create(self, vals_list): # COMPUTE METHODS # ------------------------------------------------------------------------- - @api.depends("validity") + @api.depends('validity') def _compute_date_deadline(self): for record in self: start_date = ( @@ -63,26 +63,25 @@ def _compute_date_deadline(self): def _inverse_date_deadline(self): for record in self: - start_date = ( - record.create_date.date() if record.create_date else date.today() - ) + start_date = (record.create_date or fields.Datetime.now()).date() date_diff = record.date_deadline - start_date record.validity = date_diff.days def action_accept_offer(self): for record in self: if any( - offer.status == "offer_accepted" + offer.status == 'offer_accepted' for offer in record.property_id.offer_ids ): raise UserError("Another offer has already been accepted.") else: record.property_id.buyer = record.partner_id record.property_id.selling_price = record.price - record.status = "offer_accepted" - record.property_id.state = "offer_accepted" + record.status = 'offer_accepted' + record.property_id.state = 'offer_accepted' + return True def action_refuse_offer(self): for record in self: - record.status = "offer_refused" + record.status = 'offer_refused' return True diff --git a/estate/models/res_users.py b/estate/models/res_users.py index 4d2ab44e5c2..01d8c77d550 100644 --- a/estate/models/res_users.py +++ b/estate/models/res_users.py @@ -7,5 +7,5 @@ class ResUsers(models.Model): property_ids = fields.One2many( "estate.property", "salesman", - domain=['|',('state', '=', 'new'),('state', '=', 'offer_received')], + domain=['|', ('state', '=', 'new'), ('state', '=', 'offer_received')], ) diff --git a/estate_account/__manifest__.py b/estate_account/__manifest__.py index b16fc028004..76318604d61 100644 --- a/estate_account/__manifest__.py +++ b/estate_account/__manifest__.py @@ -5,6 +5,7 @@ 'category': 'Tutorials', 'application': True, 'installable': True, + 'auto_install': True, 'depends': ['base', 'estate', 'account'], 'data': [], 'license': 'AGPL-3' From 3d9504eccdc4765e4736c8492740487bbb21b107 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Fri, 20 Mar 2026 10:07:23 +0100 Subject: [PATCH 25/29] [CLN] estate: remove unused import --- estate/models/estate_property.py | 1 - 1 file changed, 1 deletion(-) diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 6f238cedbe6..7f75a1a49e3 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -2,7 +2,6 @@ from odoo.exceptions import UserError, ValidationError from odoo.tools.float_utils import float_compare, float_is_zero from dateutil.relativedelta import relativedelta -import datetime class EstateProperty(models.Model): From b70126280c8dfebf89a32141554faf19abd19eea Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Tue, 24 Mar 2026 14:25:14 +0100 Subject: [PATCH 26/29] [IMP] awesome_dashboard: chapter 2 build a dashboard --- awesome_dashboard/__manifest__.py | 3 + awesome_dashboard/static/src/dashboard.js | 53 ++++++++++++++++- awesome_dashboard/static/src/dashboard.xml | 35 ++++++++++- .../configuration_dialog.js | 48 +++++++++++++++ .../configuration_dialog.xml | 18 ++++++ .../dashboard_item/dashboard_item.js | 15 +++++ .../dashboard_item/dashboard_item.xml | 15 +++++ .../static/src/dashboard/dashboard_items.js | 59 +++++++++++++++++++ .../static/src/dashboard/dashboard_loader.js | 12 ++++ .../src/dashboard/number_card/number_card.js | 13 ++++ .../src/dashboard/number_card/number_card.xml | 8 +++ .../src/dashboard/pie_chart/pie_chart.js | 44 ++++++++++++++ .../src/dashboard/pie_chart/pie_chart.xml | 10 ++++ .../pie_chart_card/pie_chart_card.js | 15 +++++ .../pie_chart_card/pie_chart_card.xml | 8 +++ .../src/dashboard/scss/awesome_dashboard.scss | 3 + .../statistics/statistics_service.js | 22 +++++++ 17 files changed, 378 insertions(+), 3 deletions(-) create mode 100644 awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.js create mode 100644 awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.xml create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.js create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.xml create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_items.js create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_loader.js create mode 100644 awesome_dashboard/static/src/dashboard/number_card/number_card.js create mode 100644 awesome_dashboard/static/src/dashboard/number_card/number_card.xml create mode 100644 awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js create mode 100644 awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml create mode 100644 awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js create mode 100644 awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml create mode 100644 awesome_dashboard/static/src/dashboard/scss/awesome_dashboard.scss create mode 100644 awesome_dashboard/static/src/dashboard/statistics/statistics_service.js diff --git a/awesome_dashboard/__manifest__.py b/awesome_dashboard/__manifest__.py index a1cd72893d7..f7c3c507aed 100644 --- a/awesome_dashboard/__manifest__.py +++ b/awesome_dashboard/__manifest__.py @@ -25,6 +25,9 @@ 'web.assets_backend': [ 'awesome_dashboard/static/src/**/*', ], + 'awesome_dashboard.dashboard': [ + 'awesome_dashboard/static/src/dashboard/**/*' + ] }, 'license': 'AGPL-3' } diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index c4fb245621b..10bdfb8ce83 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -1,8 +1,57 @@ -import { Component } from "@odoo/owl"; +import { Component, useState } from "@odoo/owl"; import { registry } from "@web/core/registry"; +import { Layout } from "@web/search/layout"; +import { useService } from "@web/core/utils/hooks"; +import { _t } from "@web/core/l10n/translation"; +import { DashboardItem } from "./dashboard/dashboard_item/dashboard_item" +import { PieChart } from "./dashboard/pie_chart/pie_chart" +import { ConfigurationDialog } from "./dashboard/configuration_dialog/configuration_dialog"; +import { browser } from "@web/core/browser/browser"; + class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; + static components = { Layout, DashboardItem, PieChart }; + + setup() { + this.action = useService("action"); + this.statsService = useService("statisticsService"); + this.state = useState({ + statistics: {}, + includedItemIds: JSON.parse(browser.localStorage.getItem("dashboard.includedItemIds") || "[]") + }); + this.dialog = useService("dialog"); + + this.state.statistics = this.statsService.statistics; + + this.items = registry.category("awesome_dashboard").getAll(); + } + + openCustomersForm() { + this.action.doAction('base.action_partner_form') + } + + doAction() { + console.log("test") + this.action.doAction({ + type: 'ir.actions.act_window', + name: _t('Leads'), + target: 'current', + res_model: 'crm.lead', + views: [[false, "list"], [false, "form"]], + }); + } + + openConfigurationSettings() { + console.log('open settings'); + this.dialog.add(ConfigurationDialog, { + items: this.items, + initialIncludedIds: this.state.includedItemIds, + onSave: (newIds) => { + this.state.includedItemIds = newIds; + } + }) + } } -registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard); +registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index 1a2ac9a2fed..532e20c0bc6 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -2,7 +2,40 @@ - hello dashboard + + + + + + + + + + DashboardItem default size + + + + + DashboardItem size=2 + + +
+ + + + + + + + + + + +
+
+
diff --git a/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.js b/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.js new file mode 100644 index 00000000000..ad2bb35417f --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.js @@ -0,0 +1,48 @@ +import { _t } from "@web/core/l10n/translation"; +import { Component, useState } from "@odoo/owl"; +import { Dialog } from "@web/core/dialog/dialog"; +import { CheckBox } from "@web/core/checkbox/checkbox"; +import { browser } from "@web/core/browser/browser"; + + +export class ConfigurationDialog extends Component { + static template = "awesome_dashboard.ConfigurationDialog"; + static components = { Dialog, CheckBox }; + + static props = { + close: Function, + items: { type: Object }, + initialIncludedIds: { type: Array }, + onSave: { type: Function }, + }; + + setup() { + console.log('here'); + console.log(this.props.items); + + console.log(new Set(this.props.items.map((item) => item.id))); + + this.state = useState({ + includedIds: new Set(this.props.initialIncludedIds), + }); + } + + async _done() { + const finalIds = Array.from(this.state.includedIds); + + browser.localStorage.setItem("dashboard.includedItemIds", JSON.stringify(finalIds)); + + this.props.onSave(finalIds); + this.props.close(); + } + + onChange(itemId) { + if (this.state.includedIds.has(itemId)) { + this.state.includedIds.delete(itemId); + } + else { + this.state.includedIds.add(itemId); + } + } + +} diff --git a/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.xml b/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.xml new file mode 100644 index 00000000000..cbc9702b6b8 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.xml @@ -0,0 +1,18 @@ + + + + + +

+ + + + + + + + +

+
+ +
diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.js b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.js new file mode 100644 index 00000000000..9ff7513a01b --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.js @@ -0,0 +1,15 @@ +import { Component } from "@odoo/owl"; + +export class DashboardItem extends Component { + static template = "awesome_dashboard.DashboardItem"; + + static props = { + size: {type: Number, optional: true }, + slots: Object + }; + + static defaultProps = { + size: 1 + }; + +} diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.xml b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.xml new file mode 100644 index 00000000000..1cee7f73d43 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_item/dashboard_item.xml @@ -0,0 +1,15 @@ + + + + +
+
+ +
+
+ +
+
+
+ +
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..46a679628e7 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_items.js @@ -0,0 +1,59 @@ +/** @odoo-module **/ + +import { NumberCard } from "./number_card/number_card"; +import { PieChartCard } from "./pie_chart_card/pie_chart_card"; +import { registry } from "@web/core/registry"; + + +const items = [ + { + id: "number_new_orders", + description: "new orders", + Component: NumberCard, + props: (data) => ({ + title: "new orders", + value: data.nb_new_orders, + }) + }, + { + id: "average_quantity", + description: "average quantity", + Component: NumberCard, + props: (data) => ({ + title: "average quantity", + value: data.average_quantity, + }) + }, + { + id: "average_time", + description: "average time", + Component: NumberCard, + props: (data) => ({ + title: "average time between new and sent", + value: data.average_time, + }) + }, + { + id: "amount_new_orders", + description: "new orders this month", + Component: NumberCard, + props: (data) => ({ + title: "new orders this month", + value: data.total_amount, + }) + }, + { + id: "pie_chart", + description: "orders by size", + Component: PieChartCard, + size: 2, + props: (data) => ({ + title: "orders by size", + values: data.orders_by_size, + }) + } +] + +items.forEach(item => { + registry.category("awesome_dashboard").add(item.id, item); +}); diff --git a/awesome_dashboard/static/src/dashboard/dashboard_loader.js b/awesome_dashboard/static/src/dashboard/dashboard_loader.js new file mode 100644 index 00000000000..6fa4fcb4fb7 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_loader.js @@ -0,0 +1,12 @@ +import { registry } from "@web/core/registry"; +import { LazyComponent } from "@web/core/assets"; +import { Component, xml } from "@odoo/owl"; + +class DashboardLoader extends Component { + static components = { LazyComponent }; + static template = xml` + + `; +} + +registry.category("actions").add("awesome_dashboard.dashboard", DashboardLoader); \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/number_card/number_card.js b/awesome_dashboard/static/src/dashboard/number_card/number_card.js new file mode 100644 index 00000000000..36706b348d2 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/number_card/number_card.js @@ -0,0 +1,13 @@ +import { Component } from "@odoo/owl"; + +export class NumberCard extends Component { + static template = "awesome_dashboard.NumberCard"; + static props = { + title: { + type: String, + }, + value: { + type: Number, + }, + } +} diff --git a/awesome_dashboard/static/src/dashboard/number_card/number_card.xml b/awesome_dashboard/static/src/dashboard/number_card/number_card.xml new file mode 100644 index 00000000000..0b9910fd95d --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/number_card/number_card.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js new file mode 100644 index 00000000000..a9b3ab674c0 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.js @@ -0,0 +1,44 @@ +import { Component, onWillStart, onMounted, useRef, useEffect } from "@odoo/owl"; +import { loadJS } from "@web/core/assets"; + + +export class PieChart extends Component { + static template = "awesome_dashboard.PieChart"; + static props = { + data: {type: Object} + }; + + setup() { + this.canvasRef = useRef("canvas"); + this.chart = null; + + onWillStart(() => loadJS(["/web/static/lib/Chart/Chart.js"])); + + onMounted(() => { + this.renderChart(); + }); + + useEffect(() => { + if (this.chart) { + this.chart.data.labels = Object.keys(this.props.data); + this.chart.data.datasets[0].data = Object.values(this.props.data); + this.chart.update(); + } + }, + () => [this.props.data]); + } + + renderChart() { + const config = { + type: 'pie', + data: { + labels: Object.keys(this.props.data), + datasets: [{ + data: Object.values(this.props.data), + }] + } + }; + this.chart = new Chart(this.canvasRef.el, config); + } +} + diff --git a/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml new file mode 100644 index 00000000000..bf6cc4dcebd --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/pie_chart/pie_chart.xml @@ -0,0 +1,10 @@ + + + + +
+ +
+
+ +
diff --git a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js new file mode 100644 index 00000000000..3faac175fed --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.js @@ -0,0 +1,15 @@ +import { Component } from "@odoo/owl"; +import { PieChart } from "../pie_chart/pie_chart"; + +export class PieChartCard extends Component { + static template = "awesome_dashboard.PieChartCard"; + static components = { PieChart } + static props = { + title: { + type: String, + }, + values: { + type: Object, + }, + } +} diff --git a/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml new file mode 100644 index 00000000000..6f9844bb743 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/pie_chart_card/pie_chart_card.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/awesome_dashboard/static/src/dashboard/scss/awesome_dashboard.scss b/awesome_dashboard/static/src/dashboard/scss/awesome_dashboard.scss new file mode 100644 index 00000000000..571440dc418 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/scss/awesome_dashboard.scss @@ -0,0 +1,3 @@ +.o_dashboard { + background-color: lightblue; +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/statistics/statistics_service.js b/awesome_dashboard/static/src/dashboard/statistics/statistics_service.js new file mode 100644 index 00000000000..e4fc14e8f2b --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/statistics/statistics_service.js @@ -0,0 +1,22 @@ +import { rpc } from "@web/core/network/rpc"; +import { registry } from "@web/core/registry"; +import { reactive } from "@odoo/owl"; + + +export const statisticsService = { + start() { + const statistics = reactive({}); + + async function fetchStatistics() { + const data = await rpc("/awesome_dashboard/statistics"); + Object.assign(statistics, data); + } + + setInterval(fetchStatistics, 5*60*1000); + fetchStatistics(); + + return {statistics}; + }, +}; + +registry.category("services").add("statisticsService", statisticsService); \ No newline at end of file From 951a86893519ad68796d3ecd84ce15ab5199ed51 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Tue, 24 Mar 2026 14:26:47 +0100 Subject: [PATCH 27/29] [CLN] awesome_dashboard: remove console logs --- awesome_dashboard/static/src/dashboard.js | 2 -- .../dashboard/configuration_dialog/configuration_dialog.js | 5 ----- 2 files changed, 7 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js index 10bdfb8ce83..b54ac2ba086 100644 --- a/awesome_dashboard/static/src/dashboard.js +++ b/awesome_dashboard/static/src/dashboard.js @@ -32,7 +32,6 @@ class AwesomeDashboard extends Component { } doAction() { - console.log("test") this.action.doAction({ type: 'ir.actions.act_window', name: _t('Leads'), @@ -43,7 +42,6 @@ class AwesomeDashboard extends Component { } openConfigurationSettings() { - console.log('open settings'); this.dialog.add(ConfigurationDialog, { items: this.items, initialIncludedIds: this.state.includedItemIds, diff --git a/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.js b/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.js index ad2bb35417f..fa7390a2441 100644 --- a/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.js +++ b/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.js @@ -17,11 +17,6 @@ export class ConfigurationDialog extends Component { }; setup() { - console.log('here'); - console.log(this.props.items); - - console.log(new Set(this.props.items.map((item) => item.id))); - this.state = useState({ includedIds: new Set(this.props.initialIncludedIds), }); From f3ba2e042f472be74f996a4b91316d22360f7697 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Wed, 25 Mar 2026 13:25:54 +0100 Subject: [PATCH 28/29] [IMP] estate, awesome_dashboard: address PR comments --- awesome_dashboard/static/src/dashboard.xml | 2 ++ estate/models/estate_property.py | 10 ++++++---- estate/models/estate_property_offer.py | 4 ++-- estate/security/ir.model.access.csv | 8 ++++---- estate_account/models/estate_property.py | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml index 532e20c0bc6..6bdb864721a 100644 --- a/awesome_dashboard/static/src/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard.xml @@ -6,6 +6,8 @@ + + diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 7f75a1a49e3..beae6974855 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -73,7 +73,7 @@ def unlink_if_property_not_new_or_cancelled(self): for record in self: if record.state not in ("new", "cancelled"): raise UserError( - "Properties can only be deleted in 'New' or 'Cancelled' state" + self.env._("Properties can only be deleted in 'New' or 'Cancelled' state") ) # ------------------------------------------------------------------------- @@ -104,7 +104,7 @@ def _onchange_partner_id(self): def action_sold(self): for record in self: if record.state == "cancelled": - raise UserError("Cancelled properties cannot be sold.") + raise UserError(self.env._("Cancelled properties cannot be sold.")) else: record.state = "sold" return True @@ -112,7 +112,7 @@ def action_sold(self): def action_cancel(self): for record in self: if record.state == "sold": - raise UserError("Sold properties cannot be cancelled.") + raise UserError(self.env._("Sold properties cannot be cancelled.")) else: record.state = "cancelled" return True @@ -126,5 +126,7 @@ def _check_selling_price(self): < 0 ): raise ValidationError( - "The selling price cannot be lower than 90% of the expected price." + self.env._( + "The selling price cannot be lower than 90% of the expected price." + ) ) diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index f44082618c7..825ef55e192 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -43,7 +43,7 @@ def create(self, vals_list): property_model = self.env['estate.property'].browse(property_id) if float_compare(offer_price, property_model.best_price, precision_digits=2) < 0: - raise ValidationError("New offers cannot have a lower amount than an existing offer") + raise ValidationError(self.env._("New offers cannot have a lower amount than an existing offer")) property_model.state = 'offer_received' @@ -73,7 +73,7 @@ def action_accept_offer(self): offer.status == 'offer_accepted' for offer in record.property_id.offer_ids ): - raise UserError("Another offer has already been accepted.") + raise UserError(self.env._("Another offer has already been accepted.")) else: record.property_id.buyer = record.partner_id record.property_id.selling_price = record.price diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv index 0c0b62b7fee..68c221e0dec 100644 --- a/estate/security/ir.model.access.csv +++ b/estate/security/ir.model.access.csv @@ -1,5 +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,base.group_user,1,1,1,1 -estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1 -estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,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 +access_estate_property_user,access_estate_property_user,model_estate_property,base.group_user,1,1,1,1 +access_estate_property_type_user,access_estate_property_type_user,model_estate_property_type,base.group_user,1,1,1,1 +access_estate_property_tag_user,access_estate_property_tag_user,model_estate_property_tag,base.group_user,1,1,1,1 +access_estate_property_offer_user,access_estate_property_offer_user,model_estate_property_offer,base.group_user,1,1,1,1 diff --git a/estate_account/models/estate_property.py b/estate_account/models/estate_property.py index 1319130a0ca..fb95dc01bf8 100644 --- a/estate_account/models/estate_property.py +++ b/estate_account/models/estate_property.py @@ -5,7 +5,7 @@ class EstateProperty(models.Model): _inherit = 'estate.property' def action_sold(self): - self.env['account.move'].create({ + self.env['account.move'].create([{ 'partner_id': self.buyer.id, 'move_type': 'out_invoice', 'invoice_line_ids': [ @@ -20,6 +20,6 @@ def action_sold(self): 'price_unit': 100 }), ] - }) + }]) return super().action_sold() From f692ae1bbde0aee57218a1cdd533a1cc0e233493 Mon Sep 17 00:00:00 2001 From: "Laura (yanla)" Date: Fri, 27 Mar 2026 16:51:52 +0100 Subject: [PATCH 29/29] [IMP] estate: the extras --- estate/__manifest__.py | 6 +++- estate/data/property_data.xml | 35 ++++++++++++++++++++ estate/data/property_offer_data.xml | 24 ++++++++++++++ estate/data/property_type_data.xml | 16 +++++++++ estate/models/estate_property.py | 49 ++++++++++++++-------------- estate/security/estate_security.xml | 34 +++++++++++++++++++ estate/security/ir.model.access.csv | 12 ++++--- estate/tests/__init__.py | 1 + estate/tests/test_estate_property.py | 41 +++++++++++++++++++++++ estate/views/estate_menus.xml | 2 +- 10 files changed, 190 insertions(+), 30 deletions(-) create mode 100644 estate/data/property_data.xml create mode 100644 estate/data/property_offer_data.xml create mode 100644 estate/data/property_type_data.xml create mode 100644 estate/security/estate_security.xml create mode 100644 estate/tests/__init__.py create mode 100644 estate/tests/test_estate_property.py diff --git a/estate/__manifest__.py b/estate/__manifest__.py index f237642a67e..9dee0612213 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -2,11 +2,12 @@ 'name': "Real Estate", 'author': "Odoo", 'website': "https://www.odoo.com/", - 'category': 'Tutorials', + 'category': 'Real Estate/Brokerage', 'application': True, 'installable': True, 'depends': ['base'], 'data': [ + 'security/estate_security.xml', 'security/ir.model.access.csv', 'views/estate_property_views.xml', 'views/estate_property_tags_views.xml', @@ -14,6 +15,9 @@ 'views/estate_property_types_views.xml', 'views/estate_res_users_views.xml', 'views/estate_menus.xml', + 'data/property_type_data.xml', + 'data/property_data.xml', + 'data/property_offer_data.xml' ], 'license': 'AGPL-3' } diff --git a/estate/data/property_data.xml b/estate/data/property_data.xml new file mode 100644 index 00000000000..45e6a05dd37 --- /dev/null +++ b/estate/data/property_data.xml @@ -0,0 +1,35 @@ + + + + Big Villa + + new + A nice and big villa + 12345 + 2020-02-02 + 1600000 + 6 + 100 + 4 + True + True + 100000 + south + + + + Trailer home + + cancelled + Home in a trailer park + 54321 + 1970-01-01 + 100000 + 120000 + 1 + 10 + 4 + False + + + \ No newline at end of file diff --git a/estate/data/property_offer_data.xml b/estate/data/property_offer_data.xml new file mode 100644 index 00000000000..b098200d0ce --- /dev/null +++ b/estate/data/property_offer_data.xml @@ -0,0 +1,24 @@ + + + + + + 10000 + 14 + + + + + + 1500000 + 14 + + + + + + 1500001 + 14 + + + \ No newline at end of file diff --git a/estate/data/property_type_data.xml b/estate/data/property_type_data.xml new file mode 100644 index 00000000000..69d89a613da --- /dev/null +++ b/estate/data/property_type_data.xml @@ -0,0 +1,16 @@ + + + + Residential + + + Commercial + + + Industrial + + + Land + + + \ No newline at end of file diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index beae6974855..cd697b9b285 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -5,7 +5,7 @@ class EstateProperty(models.Model): - _name = "estate.property" + _name = 'estate.property' _description = "Estate Property" _order = "id desc" @@ -26,38 +26,39 @@ class EstateProperty(models.Model): garden = fields.Boolean() garden_area = fields.Integer() garden_orientation = fields.Selection( - [("north", "North"), ("east", "East"), ("south", "South"), ("west", "West")] + [('north', "North"), ('east', "East"), ('south', "South"), ('west', "West")] ) active = fields.Boolean(default=True) state = fields.Selection( string="Status", selection=[ - ("new", "New"), - ("offer_received", "Offer Received"), - ("offer_accepted", "Offer Accepted"), - ("sold", "Sold"), - ("cancelled", "Cancelled"), + ('new', "New"), + ('offer_received', "Offer Received"), + ('offer_accepted', "Offer Accepted"), + ('sold', "Sold"), + ('cancelled', "Cancelled"), ], required=True, copy=False, - default="new", + default='new', ) - property_type_id = fields.Many2one("estate.property.type", string="Property Type") + property_type_id = fields.Many2one('estate.property.type', string="Property Type") salesman = fields.Many2one( - "res.users", + 'res.users', string="Salesperson", index=True, default=lambda self: self.env.user, ) - buyer = fields.Many2one(comodel_name="res.partner", string="Buyer", copy=False) - tag_ids = fields.Many2many(comodel_name="estate.property.tag", string="Tags") + buyer = fields.Many2one(comodel_name='res.partner', string="Buyer", copy=False) + tag_ids = fields.Many2many(comodel_name='estate.property.tag', string="Tags") offer_ids = fields.One2many( - comodel_name="estate.property.offer", - inverse_name="property_id", + comodel_name='estate.property.offer', + inverse_name='property_id', string="Offers", ) total_area = fields.Integer(compute="_compute_total_area") best_price = fields.Float(compute="_compute_best_price", string="Best Price") + company_id = fields.Many2one(comodel_name='res.company', string="Company") _check_expected_price = models.Constraint( "CHECK(expected_price > 0)", @@ -71,7 +72,7 @@ class EstateProperty(models.Model): @api.ondelete(at_uninstall=False) def unlink_if_property_not_new_or_cancelled(self): for record in self: - if record.state not in ("new", "cancelled"): + if record.state not in ('new', 'cancelled'): raise UserError( self.env._("Properties can only be deleted in 'New' or 'Cancelled' state") ) @@ -80,7 +81,7 @@ def unlink_if_property_not_new_or_cancelled(self): # COMPUTE METHODS # ------------------------------------------------------------------------- - @api.depends("living_area", "garden_area") + @api.depends('living_area', 'garden_area') def _compute_total_area(self): for record in self: record.total_area = record.living_area + record.garden_area @@ -89,35 +90,35 @@ def _compute_total_area(self): def _compute_best_price(self): for record in self: record.best_price = ( - max(record.offer_ids.mapped("price")) if record.offer_ids else 0 + max(record.offer_ids.mapped('price')) if record.offer_ids else 0 ) - @api.onchange("garden") + @api.onchange('garden') def _onchange_partner_id(self): if self.garden: self.garden_area = self.garden_area or 10 - self.garden_orientation = self.garden_orientation or "north" + self.garden_orientation = self.garden_orientation or 'north' else: self.garden_area = 0 self.garden_orientation = None def action_sold(self): for record in self: - if record.state == "cancelled": + if record.state == 'cancelled': raise UserError(self.env._("Cancelled properties cannot be sold.")) else: - record.state = "sold" + record.state = 'sold' return True def action_cancel(self): for record in self: - if record.state == "sold": + if record.state == 'sold': raise UserError(self.env._("Sold properties cannot be cancelled.")) else: - record.state = "cancelled" + record.state = 'cancelled' return True - @api.constrains("selling_price", "expected_price") + @api.constrains('selling_price', 'expected_price') def _check_selling_price(self): for record in self: if not float_is_zero(record.selling_price, precision_digits=2): diff --git a/estate/security/estate_security.xml b/estate/security/estate_security.xml new file mode 100644 index 00000000000..792e0ce6616 --- /dev/null +++ b/estate/security/estate_security.xml @@ -0,0 +1,34 @@ + + + + Real Estate + + + + + Agent + + + + + + Manager + + + + + + Agent Property Access + + + ['|', ('salesman', '=', False), ('salesman', '=', user.id)] + + + + Manager Property Access + + + ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + + \ No newline at end of file diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv index 68c221e0dec..6bd6ef363a1 100644 --- a/estate/security/ir.model.access.csv +++ b/estate/security/ir.model.access.csv @@ -1,5 +1,9 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_estate_property_user,access_estate_property_user,model_estate_property,base.group_user,1,1,1,1 -access_estate_property_type_user,access_estate_property_type_user,model_estate_property_type,base.group_user,1,1,1,1 -access_estate_property_tag_user,access_estate_property_tag_user,model_estate_property_tag,base.group_user,1,1,1,1 -access_estate_property_offer_user,access_estate_property_offer_user,model_estate_property_offer,base.group_user,1,1,1,1 +access_estate_property_user,access_estate_property_user,model_estate_property,estate_group_agent,1,1,1,1 +access_estate_property_type_user,access_estate_property_type_user,model_estate_property_type,estate_group_agent,1,0,0,1 +access_estate_property_tag_user,access_estate_property_tag_user,model_estate_property_tag,estate_group_agent,1,0,0,1 +access_estate_property_offer_user,access_estate_property_offer_user,model_estate_property_offer,estate_group_agent,1,1,1,1 +access_estate_property_manager,access_estate_property_manager,model_estate_property,estate_group_manager,1,1,1,1 +access_estate_property_type_manager,access_estate_property_type_manager,model_estate_property_type,estate_group_manager,1,1,1,1 +access_estate_property_tag_manager,access_estate_property_tag_manager,model_estate_property_tag,estate_group_manager,1,1,1,1 +access_estate_property_offer_manager,access_estate_property_offer_manager,model_estate_property_offer,estate_group_manager,1,1,1,1 diff --git a/estate/tests/__init__.py b/estate/tests/__init__.py new file mode 100644 index 00000000000..576617cccff --- /dev/null +++ b/estate/tests/__init__.py @@ -0,0 +1 @@ +from . import test_estate_property diff --git a/estate/tests/test_estate_property.py b/estate/tests/test_estate_property.py new file mode 100644 index 00000000000..275c4f62a88 --- /dev/null +++ b/estate/tests/test_estate_property.py @@ -0,0 +1,41 @@ +from odoo.tests.common import TransactionCase +from odoo.tests import tagged + + +@tagged('post_install', '-at_install') +class TestEstateProperty(TransactionCase): + @classmethod + def setUpClass(cls): + super(TestEstateProperty, cls).setUpClass() + + cls.type_house = cls.env['estate.property.type'].create({'name': 'House'}) + cls.type_apartment = cls.env['estate.property.type'].create({'name': 'Apartment'}) + + cls.tag_urgent = cls.env['estate.property.tag'].create({'name': 'Urgent'}) + + cls.buyer = cls.env['res.partner'].create({'name': 'John Doe'}) + + cls.properties = cls.env['estate.property'].create([ + { + 'name': 'Test House', + 'property_type_id': cls.type_house.id, + 'tag_ids': [(6, 0, [cls.tag_urgent.id])], + 'expected_price': 100000.0, + 'bedrooms': 3, + 'living_area': 150, + 'facades': 4, + 'garden': True, + 'garden_area': 20, + 'garden_orientation': 'north', + } + ]) + + def test_compute_total_area(self): + for property_record in self.properties: + expected_total = property_record.living_area + property_record.garden_area + self.assertEqual( + property_record.total_area, + expected_total, + f"""Total area for {property_record.name} + should be {expected_total} but got {property_record.total_area}""" + ) diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml index ad126197546..d55a56f32cf 100644 --- a/estate/views/estate_menus.xml +++ b/estate/views/estate_menus.xml @@ -4,7 +4,7 @@ - +