Skip to content

Commit ab1280b

Browse files
committed
[IMP] estate: enable UI interaction trough menus, display property data in list view and create/edit property data in form view
The model was created and access rights provided but there was no interaction with the model. This is implemented through xml as its is mre convinient for complex data. There is one menu to acces the list view of the properties and a form views is displayed whend creating or editing a property. Some fields have now a default value, some are read-only, some are requiered and some cannot be copied when duplicated. The fields active and state were added for properties display in the list view by default and for it to have a different state depending on the stage respectively.
1 parent 7bcf43b commit ab1280b

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

estate/__manifest__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
'installable': True,
77
'application': True,
88
'data': [
9+
'views/estate_property_views.xml',
10+
'views/estate_menus.xml',
11+
912
'security/ir.model.access.csv',
1013
]
1114
}

estate/models/estate_property.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
from odoo import fields, models
2+
from datetime import timedelta
3+
4+
def default_availability_date(recordset):
5+
return fields.Datetime.today() + timedelta(days=90)
26

37
class EstateProperty(models.Model):
48
_name = "estate.property"
59
_description = "Real Estate Advertisement module"
610

7-
name = fields.Char('Name', required=True, translate=True)
11+
name = fields.Char('Name', required=True)
812
description = fields.Text('Description')
9-
postcode = fields.Char('Poscode', default='1000')
10-
date_availability = fields.Date('Date availability')
13+
postcode = fields.Char('Postcode')
14+
date_availability = fields.Date('Date availability', copy=False, default=default_availability_date)
1115
expected_price = fields.Float('Expected price', required=True)
12-
selling_price = fields.Float('Selling price')
13-
bedrooms = fields.Integer('Bedrooms')
16+
selling_price = fields.Float('Selling price', readonly=True, copy=False)
17+
bedrooms = fields.Integer('Bedrooms', default=2)
1418
living_area = fields.Integer('Living Area')
1519
facades = fields.Integer('Facades')
1620
garage = fields.Boolean('Garage')
@@ -21,4 +25,12 @@ class EstateProperty(models.Model):
2125
('south', 'South'),
2226
('east', 'East'),
2327
('west', 'West')
24-
], string='Garden orientation')
28+
], string='Garden orientation')
29+
active = fields.Boolean('Active' ,default=True)
30+
state = fields.Selection(selection=[
31+
('new', 'New'),
32+
('offer_received', 'Offer Received'),
33+
('offer_accepted', 'Offer Accepted'),
34+
('sold', 'Sold'),
35+
('cancelled', 'Cancelled')
36+
], string="State", default='new', required=True, copy=False)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2-
access_real_estate_platform,estate.property,model_estate_property,base.group_user,1,1,1,1
2+
access_real_estate_platform,estate_property,model_estate_property,base.group_user,1,1,1,1

estate/views/estate_menus.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<menuitem id="estate_menu_root" name="Real Estate">
4+
<menuitem id="estate_advertisements" name="Advertisements">
5+
<menuitem id="estate_property_menu_action" action="estate_property_action"/>
6+
</menuitem>
7+
</menuitem>
8+
</odoo>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<record id="estate_property_action" model="ir.actions.act_window">
4+
<field name="name">Properties</field>
5+
<field name="res_model">estate.property</field>
6+
<field name="view_mode">list,form</field>
7+
</record>
8+
</odoo>

0 commit comments

Comments
 (0)