Skip to content

Commit 6b0b9b8

Browse files
committed
[IMP] estate: complete ch-6
1 parent 363b4bf commit 6b0b9b8

3 files changed

Lines changed: 41 additions & 6 deletions

File tree

estate/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from . import estate_property
1+
from . import estate_property

estate/models/estate_property.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
from odoo import fields, models
22

3+
34
class EstateProperty(models.Model):
45
_name = "estate.property"
56
_description = "Real-estate property"
67

78
name = fields.Char(required=True)
89
description = fields.Text()
910
postcode = fields.Char()
10-
date_availability = fields.Date(copy=False, default=fields.Date.add(fields.Date.today(), months=3))
11+
date_availability = fields.Date(
12+
copy=False, default=fields.Date.add(fields.Date.today(), months=3)
13+
)
1114
expected_price = fields.Float(required=True)
1215
selling_price = fields.Float(readonly=True, copy=False)
1316
bedrooms = fields.Integer(default=2)
@@ -19,10 +22,23 @@ class EstateProperty(models.Model):
1922
active = fields.Boolean(default=True)
2023
state = fields.Selection(
2124
required=True,
22-
default='New',
25+
default="New",
2326
copy=False,
24-
selection=[('New', 'new'), ('Offer Received', 'offer received'), ('Offer Accepted', 'offer accepted'), ('Sold', 'sold'), ('Cancelled', 'cancelled')])
27+
selection=[
28+
("New", "new"),
29+
("Offer Received", "offer received"),
30+
("Offer Accepted", "offer accepted"),
31+
("Sold", "sold"),
32+
("Cancelled", "cancelled"),
33+
],
34+
)
2535
garden_orientation = fields.Selection(
26-
string='Type',
27-
selection=[('North', 'north'), ('South', 'south'), ('East', 'east'), ('West', 'west')])
36+
string="Type",
37+
selection=[
38+
("North", "north"),
39+
("South", "south"),
40+
("East", "east"),
41+
("West", "west"),
42+
],
43+
)
2844

estate/views/estate_property_views.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@
6161
</field>
6262
</record>
6363

64+
<record id="view_estate_property_search" model="ir.ui.view">
65+
<field name="name">estate.property.search</field>
66+
<field name="model">estate.property</field>
67+
<field name="arch" type="xml">
68+
<search string="property">
69+
<field name="name" string="property" />
70+
<field name="postcode"/>
71+
<field name="expected_price"/>
72+
<field name="bedrooms"/>
73+
<field name="living_area"/>
74+
<field name="facades"/>
75+
<separator/>
76+
<filter string="Available" name="active" domain="[('state', 'in', ['New','Offer Accepted'])]"/>
77+
<filter string="postcode" name="postcode" context="{'group_by':'postcode'}"/>
78+
79+
</search>
80+
</field>
81+
</record>
82+
6483
<record id="estate_property_model_action" model="ir.actions.act_window">
6584
<field name="name">Test action</field>
6685
<field name="res_model">estate.property</field>

0 commit comments

Comments
 (0)