From 68a0e8da3fa9f531aec90de039952839008b2578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Vanmeerhaeghe=20=28stva=29?= Date: Tue, 19 Nov 2024 10:24:59 +0100 Subject: [PATCH] [ADD] estate: new module created - New model 'property' created - Security: give read, write, create and unlink permissions to the group base.group_user. - Basic list, form views added --- estate/__init__.py | 1 + estate/__manifest__.py | 14 +++++ estate/models/__init__.py | 2 + estate/models/property.py | 32 +++++++++++ estate/security/ir.model.access.csv | 2 + estate/views/estate_property_views.xml | 75 ++++++++++++++++++++++++++ 6 files changed, 126 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/property.py create mode 100644 estate/security/ir.model.access.csv create mode 100644 estate/views/estate_property_views.xml diff --git a/estate/__init__.py b/estate/__init__.py new file mode 100644 index 0000000000..9a7e03eded --- /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 0000000000..cd81ed2e1a --- /dev/null +++ b/estate/__manifest__.py @@ -0,0 +1,14 @@ +{ + 'name': 'Estate', + 'version': '0.1', + 'depends': ['base'], + 'summary': 'Estate module', + 'category': 'Tutorials/Estate', + 'application': True, + 'installable': True, + 'license': 'AGPL-3', + 'data': [ + 'security/ir.model.access.csv', + 'views/estate_property_views.xml', + ] +} diff --git a/estate/models/__init__.py b/estate/models/__init__.py new file mode 100644 index 0000000000..f34ed233d3 --- /dev/null +++ b/estate/models/__init__.py @@ -0,0 +1,2 @@ +from . import property + diff --git a/estate/models/property.py b/estate/models/property.py new file mode 100644 index 0000000000..0590a74fad --- /dev/null +++ b/estate/models/property.py @@ -0,0 +1,32 @@ +from dateutil.relativedelta import relativedelta +from odoo import fields, models + + +def _default_date_availability(): + return fields.Date.today() + relativedelta(months=3) + + +class EstateProperty(models.Model): + _name = 'estate.property' + _description = "Estate Property" + name = fields.Char(required=True) + description = fields.Text() + postcode = fields.Char() + date_availability = fields.Date(copy=False, + default=_default_date_availability, + string='Available from') + expected_price = fields.Float(required=True) + selling_price = fields.Float(readonly=True, copy=False) + bedrooms = fields.Integer(default=2) + living_area = fields.Integer(string='Living area (sqm)') + facades = fields.Integer() + garage = fields.Boolean() + garden = fields.Boolean() + garden_area = fields.Integer(string='Garden area (sqm)') + garden_orientation = fields.Selection( + selection=[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')]) + active: bool = fields.Boolean(default=True) + state = fields.Selection(copy=False, default='New', required=True, + selection=[('New', 'New'), ('Offer Received', 'Offer Received'), + ('Offer Accepted', 'Offer Accepted'), ('Sold', 'Sold'), + ('Cancelled', 'Cancelled')]) diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv new file mode 100644 index 0000000000..66c9b12ce6 --- /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" +"access_estate_property","access_estate_property","model_estate_property","base.group_user",1,1,1,1 \ No newline at end of file diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml new file mode 100644 index 0000000000..2101c0d756 --- /dev/null +++ b/estate/views/estate_property_views.xml @@ -0,0 +1,75 @@ + + + + Properties + estate.property + list,form + + + + + + + + + + estate.property.list + estate.property + + + + + + + + + + + + + + + estate.property.form + estate.property + + +
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ +