Skip to content

Commit 6904337

Browse files
committed
[ADD] real_estate: add data through csv and xml in list and form view
first i add data with csv file in module and after that with xml file code i add data that display on frontend in list view and form view both also disable selling price so anyone cannot change it
1 parent f90b30b commit 6904337

File tree

5 files changed

+113
-4
lines changed

5 files changed

+113
-4
lines changed

real_estate/__manifest__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@
99
],
1010
'application': True,
1111
'installable': True,
12+
'license':'LGPL-3',
13+
'data': [
14+
'data/ir.model.access.csv',
15+
'data/estate_property_views.xml',
16+
'data/estate_menus.xml',
17+
],
1218
}

real_estate/data/estate_menus.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<menuitem id="menu_real_estate_root" name="Real Estate"/>
4+
<menuitem id="menu_real_estate_properties" name="Properties" parent="menu_real_estate_root"/>
5+
<menuitem id="menu_estate_property_action" action="action_estate_property" parent="menu_real_estate_properties"/>
6+
</odoo>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<record id="view_estate_property_list" model="ir.ui.view">
4+
<field name="name">estate.property.list</field>
5+
<field name="model">estate.property</field>
6+
<field name="arch" type="xml">
7+
<list string="Properties">
8+
<field name="name"/>
9+
<field name="postcode"/>
10+
<field name="state"/>
11+
<field name="expected_price"/>
12+
<field name="selling_price"/>
13+
<field name="bedrooms"/>
14+
<field name="availability_date"/>
15+
<field name="active"/>
16+
</list>
17+
</field>
18+
</record>
19+
20+
<record id="view_estate_property_form" model="ir.ui.view">
21+
<field name="name">estate.property.form</field>
22+
<field name="model">estate.property</field>
23+
<field name="arch" type="xml">
24+
<form string="Estate Property">
25+
<sheet>
26+
<h1>
27+
<field name="name"/>
28+
</h1>
29+
<group>
30+
<group>
31+
<field name="postcode"/>
32+
<field name="availability_date"/>
33+
</group>
34+
<group>
35+
<field name="expected_price"/>
36+
<field name="selling_price" readonly="1"/>
37+
</group>
38+
</group>
39+
40+
<notebook>
41+
<page string="Description">
42+
<group>
43+
<field name="description"/>
44+
<field name="bedrooms"/>
45+
<field name="living_area"/>
46+
<field name="facades"/>
47+
<field name="garage"/>
48+
<field name="garden"/>
49+
<field name="garden_area"/>
50+
<field name="garden_orientation"/>
51+
</group>
52+
</page>
53+
</notebook>
54+
</sheet>
55+
</form>
56+
</field>
57+
</record>
58+
59+
<record id="view_estate_property_search" model="ir.ui.view">
60+
<field name="name">estate.property.search</field>
61+
<field name="model">estate.property</field>
62+
<field name="arch" type="xml">
63+
<search string="Search Properties">
64+
<field name="name"/>
65+
<field name="postcode"/>
66+
<separator/>
67+
<filter name="filter_available" string="Available" domain="[ '|', ('state', '=', 'new'), ('state', '=', 'offer_received') ]"/>
68+
<group expand="1" string="Group By">
69+
<filter name="group_by_postcode" string="Postcode" context="{'group_by': 'postcode'}"/>
70+
</group>
71+
</search>
72+
</field>
73+
</record>
74+
75+
76+
<record id="action_estate_property" model="ir.actions.act_window">
77+
<field name="name">Real estate action</field>
78+
<field name="res_model">estate.property</field>
79+
<field name="view_mode">list,form</field>
80+
</record>
81+
</odoo>

real_estate/data/ir.model.access.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
2+
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1

real_estate/models/estate_property.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
from datetime import date, timedelta
12
from odoo import fields, models
23

34

45
class EstateProperty(models.Model):
56
_name = "estate.property"
67
_description = "Real Estate Property"
78

8-
name = fields.Char(string="Title", required=True)
9+
name = fields.Char(default="Unknown", required=True)
910
description = fields.Text(string="Description")
1011
postcode = fields.Char(string="Postcode")
11-
date_availability = fields.Date(string="Available From")
12+
availability_date = fields.Date(default=lambda self: date.today() + timedelta(days=90), copy=False)
1213
expected_price = fields.Float(string="Expected Price",required=True)
13-
selling_price = fields.Float(string="Selling Price")
14-
bedrooms = fields.Integer(string="Bedrooms")
14+
selling_price = fields.Float(readonly=True, copy=False)
15+
bedrooms = fields.Integer(default=2)
1516
living_area = fields.Integer(string="Living Area")
1617
facades = fields.Integer(string="Facades")
1718
garage = fields.Boolean(string="Garage")
@@ -26,3 +27,16 @@ class EstateProperty(models.Model):
2627
],
2728
string="Garden Orientation"
2829
)
30+
active = fields.Boolean(default=False)
31+
state = fields.Selection(
32+
selection=[
33+
('new', 'New'),
34+
('offer_received', 'Offer Received'),
35+
('offer_accepted', 'Offer Accepted'),
36+
('sold', 'Sold'),
37+
('cancelled', 'Cancelled'),
38+
],
39+
required=True,
40+
copy=False,
41+
default='new'
42+
)

0 commit comments

Comments
 (0)