From db9d9e5f462bfe52b3db22258302f0ec18cdf289 Mon Sep 17 00:00:00 2001 From: aizu-odoo Date: Tue, 19 Nov 2024 14:16:04 +0100 Subject: [PATCH 01/12] [ADD] estate: creation of a new real estate module --- estate/__init__.py | 1 + estate/__manifest__.py | 6 ++++++ estate/models/__init__.py | 1 + estate/models/estate_property.py | 21 +++++++++++++++++++++ 4 files changed, 29 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..b2497ce07c1 --- /dev/null +++ b/estate/__manifest__.py @@ -0,0 +1,6 @@ +{ + 'name': "Awesome Estate", + 'depends': ['base'], + 'installable': True, + 'application': 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..b43a2cc4266 --- /dev/null +++ b/estate/models/estate_property.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models + +class EstateProperty(models.Model): + _name = "estate.property" + _description = "Estate Properties" + + 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')], string = 'Garden Orientation') \ No newline at end of file From a2aacd3cb17d3be074b76d8951ebaa870fcb510f Mon Sep 17 00:00:00 2001 From: aizu-odoo Date: Tue, 19 Nov 2024 17:00:39 +0100 Subject: [PATCH 02/12] [IMP] estate: adding access right --- .vscode/launch.json | 21 +++++++++++++++++++++ estate/__manifest__.py | 3 ++- estate/models/estate_property.py | 3 ++- estate/security/ir.model.access.csv | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 estate/security/ir.model.access.csv diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000000..1fe46a3ce25 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Restart Server", + "type": "debugpy", + "request": "launch", + "program": "/home/odoo/odoo_firsttest/odoo18/odoo-bin", + "args": ["--addons-path=/home/odoo/odoo_firsttest/odoo18/addons/,/home/odoo/odoo_firsttest/enterprise/,/home/odoo/odoo_firsttest/tutorials", + "-d", + "rd-demo", + "-u", + "estate" + ], + "console": "integratedTerminal" + } + ] +} \ No newline at end of file diff --git a/estate/__manifest__.py b/estate/__manifest__.py index b2497ce07c1..36d0e05d438 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -2,5 +2,6 @@ 'name': "Awesome Estate", 'depends': ['base'], 'installable': True, - 'application': True + 'application': True, + 'data':['security/ir.model.access.csv'] } \ No newline at end of file diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index b43a2cc4266..d7bd021e9bf 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -18,4 +18,5 @@ class EstateProperty(models.Model): garage = fields.Boolean() garden = fields.Boolean() garden_area = fields.Integer() - garden_orientation = fields.Selection([('north','North'), ('south','South'), ('east', 'East'), ('west', 'West')], string = 'Garden Orientation') \ No newline at end of file + garden_orientation = fields.Selection([('north','North'), ('south','South'), ('east', 'East'), ('west', 'West')], string = 'Garden Orientation') + \ 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..07669bf00e2 --- /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,0,0,0 \ No newline at end of file From 384f7c3b733dad26800031166c87b2d5db70f320 Mon Sep 17 00:00:00 2001 From: aizu-odoo Date: Wed, 20 Nov 2024 09:52:27 +0100 Subject: [PATCH 03/12] [IMP] estate: menus and estate_property fields added --- .vscode/launch.json | 21 ---------------- estate/__init__.py | 2 +- estate/__manifest__.py | 10 +++++--- estate/models/__init__.py | 2 +- estate/models/estate_property.py | 33 ++++++++++++++++++++++---- estate/security/ir.model.access.csv | 2 +- estate/views/estate_menu_views.xml | 10 ++++++++ estate/views/estate_property_views.xml | 12 ++++++++++ 8 files changed, 60 insertions(+), 32 deletions(-) delete mode 100644 .vscode/launch.json create mode 100644 estate/views/estate_menu_views.xml create mode 100644 estate/views/estate_property_views.xml diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 1fe46a3ce25..00000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Restart Server", - "type": "debugpy", - "request": "launch", - "program": "/home/odoo/odoo_firsttest/odoo18/odoo-bin", - "args": ["--addons-path=/home/odoo/odoo_firsttest/odoo18/addons/,/home/odoo/odoo_firsttest/enterprise/,/home/odoo/odoo_firsttest/tutorials", - "-d", - "rd-demo", - "-u", - "estate" - ], - "console": "integratedTerminal" - } - ] -} \ No newline at end of file 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 36d0e05d438..4205ec36d9a 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -1,7 +1,11 @@ { 'name': "Awesome Estate", 'depends': ['base'], - 'installable': True, 'application': True, - 'data':['security/ir.model.access.csv'] -} \ No newline at end of file + 'data':[ + 'security/ir.model.access.csv', + + 'views/estate_property_views.xml', + 'views/estate_menu_views.xml' + ] +} 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 d7bd021e9bf..4b4b9b79e2a 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,22 +1,45 @@ # -*- coding: utf-8 -*- from odoo import fields, models +from dateutil.relativedelta import relativedelta class EstateProperty(models.Model): - _name = "estate.property" + _name = 'estate.property' _description = "Estate Properties" name = fields.Char(required=True) description = fields.Text() postcode = fields.Char() - date_availability = fields.Date() + date_availability = fields.Date(copy=False, default= lambda _self: fields.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'), ('south','South'), ('east', 'East'), ('west', 'West')], string = 'Garden Orientation') + garden_orientation = fields.Selection( + [ + ('north', "North"), + ('south', "South"), + ('east', "East"), + ('west', "West"), + ], + string="Garden Orientation", + ) + + active = fields.Boolean(default=True) + 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 index 07669bf00e2..85de405deb2 100644 --- a/estate/security/ir.model.access.csv +++ b/estate/security/ir.model.access.csv @@ -1,2 +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,0,0,0 \ No newline at end of file +estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1 diff --git a/estate/views/estate_menu_views.xml b/estate/views/estate_menu_views.xml new file mode 100644 index 00000000000..043c489a7f8 --- /dev/null +++ b/estate/views/estate_menu_views.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml new file mode 100644 index 00000000000..f6b32d6b5da --- /dev/null +++ b/estate/views/estate_property_views.xml @@ -0,0 +1,12 @@ + + + + + + Estate Property + estate.property + list,form + + + + From 5cb38b4556870cd50b72c0f8fcb453715d0c66a0 Mon Sep 17 00:00:00 2001 From: aizu-odoo Date: Wed, 20 Nov 2024 11:35:35 +0100 Subject: [PATCH 04/12] [IMP] estate: list,form,search views --- estate/views/estate_property_views.xml | 70 ++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index f6b32d6b5da..449822a00a7 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -2,6 +2,76 @@ + + estate.property.list + estate.property + + + + + + + + + + + + + + + estate.property.form + estate.property + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + estate.property.search + estate.property + + + + + + + + + + + + + + + + Estate Property estate.property From 101b0eef62f8ed2deeb0941ddda69d02ddbbd061 Mon Sep 17 00:00:00 2001 From: aizu-odoo Date: Wed, 20 Nov 2024 16:35:02 +0100 Subject: [PATCH 05/12] [IMP] estate: property types,tags and offers models created and connected --- estate/__manifest__.py | 8 +++-- estate/models/__init__.py | 3 ++ estate/models/estate_property.py | 18 ++++++---- estate/models/estate_property_offer.py | 12 +++++++ estate/models/estate_property_tag.py | 8 +++++ estate/models/estate_property_type.py | 8 +++++ estate/security/ir.model.access.csv | 3 ++ estate/views/estate_menu_views.xml | 9 +++-- estate/views/estate_property_tag_views.xml | 38 +++++++++++++++++++++ estate/views/estate_property_type_views.xml | 38 +++++++++++++++++++++ estate/views/estate_property_views.xml | 24 ++++++++++++- 11 files changed, 156 insertions(+), 13 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_tag_views.xml create mode 100644 estate/views/estate_property_type_views.xml diff --git a/estate/__manifest__.py b/estate/__manifest__.py index 4205ec36d9a..e7639a1a7e9 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -2,10 +2,12 @@ 'name': "Awesome Estate", 'depends': ['base'], 'application': True, - 'data':[ + 'data': [ 'security/ir.model.access.csv', + 'views/estate_property_type_views.xml', + 'views/estate_property_tag_views.xml', 'views/estate_property_views.xml', - 'views/estate_menu_views.xml' - ] + 'views/estate_menu_views.xml', + ] } 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 4b4b9b79e2a..5acc5777437 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- - from odoo import fields, models from dateutil.relativedelta import relativedelta + class EstateProperty(models.Model): _name = 'estate.property' _description = "Estate Properties" @@ -10,7 +9,7 @@ class EstateProperty(models.Model): name = fields.Char(required=True) description = fields.Text() postcode = fields.Char() - date_availability = fields.Date(copy=False, default= lambda _self: fields.Date.today()+relativedelta(months=3)) + date_availability = fields.Date(copy=False, default=lambda _self: fields.Date.today() + relativedelta(months=3)) expected_price = fields.Float(required=True) selling_price = fields.Float(readonly=True, copy=False) bedrooms = fields.Integer(default=2) @@ -37,9 +36,14 @@ class EstateProperty(models.Model): ('offer_accepted', "Offer Accepted"), ('sold', "Sold"), ('cancelled', "Cancelled"), - ], - required=True, - copy=False, + ], + required=True, + copy=False, default='new' ) - \ No newline at end of file + + property_type_id = fields.Many2one('estate.property.type', string="Property Type") + buyer_id = fields.Many2one('res.partner', string="Buyer", copy=False) + salesperson_id = fields.Many2one('res.users', string="Sales Person", default=lambda self: self.env.user) + property_tag_ids = fields.Many2many('estate.property.tag') + property_offer_ids = fields.One2many('estate.property.offer', 'property_id') diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py new file mode 100644 index 00000000000..052934add66 --- /dev/null +++ b/estate/models/estate_property_offer.py @@ -0,0 +1,12 @@ +from odoo import fields, models + + +class EstatePropertyOffer(models.Model): + _name = 'estate.property.offer' + _description = "Property Offer" + + name = fields.Char(required=True) + price = fields.Float() + status = fields.Selection([('accepted', 'Accepted'), ('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..5972a2d6c7b --- /dev/null +++ b/estate/models/estate_property_tag.py @@ -0,0 +1,8 @@ +from odoo import fields, models + + +class EstatePropertyTag(models.Model): + _name = 'estate.property.tag' + _description = "Property Tag" + + name = fields.Char(required=True) diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py new file mode 100644 index 00000000000..3a56a9e478c --- /dev/null +++ b/estate/models/estate_property_type.py @@ -0,0 +1,8 @@ +from odoo import fields, models + + +class EstatePropertyType(models.Model): + _name = 'estate.property.type' + _description = "Property Type" + + name = fields.Char(required=True) diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv index 85de405deb2..78458c1cb61 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 +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 diff --git a/estate/views/estate_menu_views.xml b/estate/views/estate_menu_views.xml index 043c489a7f8..ce1e45b6ed2 100644 --- a/estate/views/estate_menu_views.xml +++ b/estate/views/estate_menu_views.xml @@ -2,9 +2,14 @@ - - + + + + + + + diff --git a/estate/views/estate_property_tag_views.xml b/estate/views/estate_property_tag_views.xml new file mode 100644 index 00000000000..b4d769a8d78 --- /dev/null +++ b/estate/views/estate_property_tag_views.xml @@ -0,0 +1,38 @@ + + + + + + estate.property.tag.list + estate.property.tag + + + + + + + + + estate.property.tag.form + estate.property.tag + +
+ + + + + + + +
+
+
+ + + Property Tags + estate.property.tag + list,form + + +
+
diff --git a/estate/views/estate_property_type_views.xml b/estate/views/estate_property_type_views.xml new file mode 100644 index 00000000000..b2b7d735d1f --- /dev/null +++ b/estate/views/estate_property_type_views.xml @@ -0,0 +1,38 @@ + + + + + + estate.property.type.list + estate.property.type + + + + + + + + + estate.property.type.form + estate.property.type + +
+ + + + + + + +
+
+
+ + + Property Types + estate.property.type + list,form + + +
+
diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 449822a00a7..737d40f9e08 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -8,6 +8,7 @@ + @@ -24,8 +25,13 @@
+

+ +

+ + @@ -47,6 +53,21 @@ + + + + + + + + + + + + + + +
@@ -59,12 +80,13 @@ + - + From ee57b0a95e62777e237445f0333c8cde2cac923a Mon Sep 17 00:00:00 2001 From: aizu-odoo Date: Thu, 21 Nov 2024 13:17:55 +0100 Subject: [PATCH 06/12] [IMP] estate: computed fields and onchanges added --- estate/models/estate_property.py | 25 ++++++++++++++++++++++++- estate/models/estate_property_offer.py | 15 ++++++++++++++- estate/views/estate_property_views.xml | 2 ++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 5acc5777437..e394717444b 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import api,fields, models from dateutil.relativedelta import relativedelta @@ -47,3 +47,26 @@ class EstateProperty(models.Model): salesperson_id = fields.Many2one('res.users', string="Sales Person", default=lambda self: self.env.user) property_tag_ids = fields.Many2many('estate.property.tag') property_offer_ids = fields.One2many('estate.property.offer', 'property_id') + + total_area = fields.Float(compute='_compute_tot_area') + best_price = fields.Float(compute='_compute_best_price') + + @api.depends('living_area', 'garden_area') + def _compute_tot_area(self): + for record in self: + record.total_area = record.living_area + record.garden_area + + @api.depends('property_offer_ids.price') + def _compute_best_price(self): + for record in self: + record.best_price = max(record.property_offer_ids.mapped('price'), default=0) + + + @api.onchange('garden') + def _onchange_garden(self): + if self.garden: + self.garden_area = 10 + self.garden_orientation = 'north' + else: + self.garden_area = False + self.garden_orientation = False diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 052934add66..6959ac1745a 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -1,4 +1,5 @@ -from odoo import fields, models +from odoo import api, fields, models +from dateutil.relativedelta import relativedelta class EstatePropertyOffer(models.Model): @@ -10,3 +11,15 @@ class EstatePropertyOffer(models.Model): status = fields.Selection([('accepted', 'Accepted'), ('refused', 'Refused')], copy=False) 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') + + @api.depends('create_date', 'validity') + def _compute_date_deadline(self): + for record in self: + start_date = record.create_date or fields.Date.today() + record.date_deadline = start_date + relativedelta(days=record.validity) + + def _inverse_date_deadline(self): + for record in self: + record.validity = (record.date_deadline - record.create_date.date()).days diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 737d40f9e08..11a4d90cb9d 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -37,6 +37,7 @@ + @@ -51,6 +52,7 @@ + From 7d30fde3ed96947c0196b97053f1da81275d69dd Mon Sep 17 00:00:00 2001 From: aizu-odoo Date: Thu, 21 Nov 2024 14:47:16 +0100 Subject: [PATCH 07/12] [IMP] estate: property cancel/sold buttons, offer accept/refused buttons --- estate/models/estate_property.py | 21 +++++++++++++++++++-- estate/models/estate_property_offer.py | 12 ++++++++++++ estate/views/estate_property_views.xml | 8 +++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index e394717444b..ecb5304238a 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,4 +1,5 @@ -from odoo import api,fields, models +from odoo import api, fields, models +from odoo.exceptions import UserError from dateutil.relativedelta import relativedelta @@ -61,7 +62,6 @@ def _compute_best_price(self): for record in self: record.best_price = max(record.property_offer_ids.mapped('price'), default=0) - @api.onchange('garden') def _onchange_garden(self): if self.garden: @@ -70,3 +70,20 @@ def _onchange_garden(self): else: self.garden_area = False self.garden_orientation = False + + def action_set_sold(self): + for record in self: + if record.state != 'canceled': + record.state = 'sold' + else: + raise UserError("Sold properties cannot be canceled.") + return True + + def action_set_canceled(self): + for record in self: + if record.state != 'sold': + record.state = 'canceled' + else: + raise UserError("Sold properties cannot be canceled.") + return True + diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 6959ac1745a..0681d1a41f9 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -23,3 +23,15 @@ def _compute_date_deadline(self): def _inverse_date_deadline(self): for record in self: record.validity = (record.date_deadline - record.create_date.date()).days + + def action_accept(self): + for record in self: + record.status = 'accepted' + record.property_id.buyer_id = record.partner_id + record.property_id.selling_price = record.price + return True + + def action_refuse(self): + for record in self: + record.status = 'refused' + return True diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 11a4d90cb9d..5d4a78fda63 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -24,6 +24,10 @@ estate.property
+
+

@@ -60,7 +64,9 @@ - +

diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index e1894a0b26e..c3349d15c01 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -8,8 +8,8 @@ @@ -58,7 +58,7 @@ /> - + @@ -86,8 +86,7 @@ - + /> diff --git a/estate/views/res_users_views.xml b/estate/views/res_users_views.xml new file mode 100644 index 00000000000..da8a85ebaf4 --- /dev/null +++ b/estate/views/res_users_views.xml @@ -0,0 +1,19 @@ + + + + + + res.users.view.form.inherit.estate + res.users + + + + + + + + + + + + From 7c344705efb6737b17d9c5a5f6050af533e6cbdd Mon Sep 17 00:00:00 2001 From: aizu-odoo Date: Mon, 25 Nov 2024 09:58:12 +0100 Subject: [PATCH 11/12] [IMP] estate: invoice creation when property sold --- estate_account/__init__.py | 1 + estate_account/__manifest__.py | 5 +++++ estate_account/models/__init__.py | 1 + estate_account/models/estate_property.py | 26 ++++++++++++++++++++++++ 4 files changed, 33 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..49b8e502e38 --- /dev/null +++ b/estate_account/__manifest__.py @@ -0,0 +1,5 @@ +{ + 'name': "Awesome Estate", + 'depends': ['estate', 'account'], + 'license': 'OEEL-1', +} 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..7f484d35a1c --- /dev/null +++ b/estate_account/models/estate_property.py @@ -0,0 +1,26 @@ +from odoo import models, Command + + +class EstateProperty(models.Model): + _inherit = "estate.property" + + def action_set_sold(self): + for record in self: + invoice_values = { + 'partner_id': record.buyer_id.id, + 'move_type': 'out_invoice', + 'invoice_line_ids': [ + Command.create({ + 'name': "Downpayment", + 'quantity': 1, + 'price_unit': 0.06 * record.selling_price, + }), + Command.create({ + 'name': "Administrative Fees", + 'quantity': 1, + 'price_unit': 100.00, + }) + ] + } + self.env['account.move'].create(invoice_values) + return super(EstateProperty, self).action_set_sold() From 635f4928f8d7ed5b045ca52206f3e7ed4bdd579a Mon Sep 17 00:00:00 2001 From: aizu-odoo Date: Mon, 25 Nov 2024 11:35:07 +0100 Subject: [PATCH 12/12] [IMP] estate: kanban view for properties --- estate/models/estate_property.py | 10 +++---- estate/models/estate_property_offer.py | 6 ++-- estate/security/ir.model.access.csv | 2 +- estate/views/estate_property_views.xml | 37 +++++++++++++++++++++++- estate_account/__init__.py | 2 +- estate_account/models/__init__.py | 2 +- estate_account/models/estate_property.py | 2 +- 7 files changed, 48 insertions(+), 13 deletions(-) diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 4ad527ef018..c9784544f43 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,4 +1,4 @@ -from odoo import api, fields, models, _ +from odoo import api, fields, models from odoo.exceptions import UserError, ValidationError from odoo.tools.float_utils import float_compare, float_is_zero from dateutil.relativedelta import relativedelta @@ -63,7 +63,7 @@ class EstateProperty(models.Model): def _check_selling_price(self): for record in self: if not float_is_zero(record.selling_price, precision_digits=2) and float_compare(record.selling_price, record.expected_price * 0.9, precision_digits=2) <= 0: - raise ValidationError("The selling price cannot be lower than 90 percent of the expected price.") + raise ValidationError(self.env._("The selling price cannot be lower than 90 percent of the expected price.")) @api.depends('living_area', 'garden_area') @@ -81,7 +81,7 @@ def _compute_best_price(self): def _prevent_property_deletion(self): for record in self: if record.state not in ('new', 'cancelled'): - raise UserError(_("Only new or cancelled properties can be deleted.")) + raise UserError(self.env._("Only new or cancelled properties can be deleted.")) @api.onchange('garden') def _onchange_garden(self): @@ -97,7 +97,7 @@ def action_set_sold(self): if record.state != 'cancelled': record.state = 'sold' else: - raise UserError(_("Sold properties cannot be cancelled.")) + raise UserError(self.env._("Sold properties cannot be cancelled.")) return True def action_set_cancelled(self): @@ -105,5 +105,5 @@ def action_set_cancelled(self): if record.state != 'sold': record.state = 'cancelled' else: - raise UserError(_("Sold properties cannot be cancelled.")) + raise UserError(self.env._("Sold properties cannot be cancelled.")) return True diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 88253d9698f..5b076c33b14 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -1,4 +1,4 @@ -from odoo import api, fields, models, _ +from odoo import api, fields, models from odoo.exceptions import UserError from dateutil.relativedelta import relativedelta @@ -32,9 +32,9 @@ def _compute_date_deadline(self): def create(self, vals_list): for vals in vals_list: if self.price < self.env['estate.property'].browse(vals['property_id']).best_price: - raise UserError(_("You cannot put in an offer that is lower than the current best price.")) + raise UserError(self.env_("You cannot put in an offer that is lower than the current best price.")) self.env['estate.property'].browse(vals['property_id']).state = 'offer_received' - return super(EstatePropertyOffer, self).create(vals_list) + return super().create(vals_list) def _inverse_date_deadline(self): for record in self: diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv index c79331f2f1c..78458c1cb61 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_views.xml b/estate/views/estate_property_views.xml index c3349d15c01..de8e5217034 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -100,6 +100,41 @@ + + estate.property.kanban + estate.property + + + + + +
+ + + +
+ Expected Price: + +
+ +
+ Best Price: + +
+
+ Selling Price: + +
+
+ +
+
+
+
+
+
+
+ estate.property.search estate.property @@ -134,7 +169,7 @@ Estate Property estate.property - list,form + list,form,kanban {'search_default_state':True} 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/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 7f484d35a1c..1ab093a0ff2 100644 --- a/estate_account/models/estate_property.py +++ b/estate_account/models/estate_property.py @@ -23,4 +23,4 @@ def action_set_sold(self): ] } self.env['account.move'].create(invoice_values) - return super(EstateProperty, self).action_set_sold() + return super().action_set_sold()