Skip to content

Commit 1d69faf

Browse files
committed
[IMP] estate: Add Inline views - widgets - list order - attributes
1 parent 9d776f7 commit 1d69faf

8 files changed

+66
-15
lines changed

estate/models/estate_property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class EstateProperty(models.Model):
88

99
_name = "estate.property"
1010
_description = "estate properties"
11-
_order = "id"
11+
_order = "id desc"
1212
_sql_constraints = [
1313
('check_expected_price', 'CHECK(expected_price > 0 )', 'expected price must be strictly positive'),
1414
('check_selling_price', 'CHECK(selling_price >= 0 )', 'selling price must be positive'),

estate/models/estate_property_offer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class EstatePropertyOffer(models.Model):
77

88
_name = "estate.property.offer"
99
_description = "estate property offer"
10-
_order = "id"
10+
_order = "price desc"
1111
_sql_constraints = [
1212
('check_offer_price', 'CHECK(price > 0)', 'An offer price must be strictly positive')
1313
]

estate/models/estate_property_tag.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ class EstatePropertyTag(models.Model):
55

66
_name = "estate.property.tag"
77
_description = "estate property tag"
8-
_order = "id"
8+
_order = "name"
99
_sql_constraints = [
1010
('unique_name', 'UNIQUE(name)', 'the tag name must be unique')
1111
]
1212

1313
name = fields.Char("Name", required=True)
14+
color = fields.Integer("Color")

estate/models/estate_property_type.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ class EstatePropertyType(models.Model):
55

66
_name = "estate.property.type"
77
_description = "estate property type"
8-
_order = "id"
8+
_order = "name"
99
_sql_constraints = [
1010
('unique_name', 'UNIQUE(name)', 'the type name must be unique')
1111
]
1212

1313
name = fields.Char("Name", required=True)
14+
sequence = fields.Integer("Sequence", default=10)
15+
property_ids = fields.One2many("estate.property", "property_type_id", string="Properties")

estate/views/estate_property_offer_views.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
<field name="name">estate.property.offer.list</field>
44
<field name="model">estate.property.offer</field>
55
<field name="arch" type="xml">
6-
<list string="Property Offers">
6+
<list string="Property Offers" editable="bottom" decoration-success="status == 'accepted'" decoration-danger="status == 'refused'">
77
<field name="price"/>
88
<field name="partner_id"/>
99
<button name="action_accept" type="object" title="Accept" icon="fa-check"/>
1010
<button name="action_refuse" type="object" title="Refuse" icon="fa-times"/>
11-
<field name="status"/>
1211
</list>
1312
</field>
1413
</record>

estate/views/estate_property_tag_views.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,13 @@
44
<field name="res_model">estate.property.tag</field>
55
<field name="view_mode">list,form</field>
66
</record>
7+
<record id="estate_property_tag_list" model="ir.ui.view">
8+
<field name="name">estate.property.tag.list</field>
9+
<field name="model">estate.property.tag</field>
10+
<field name="arch" type="xml">
11+
<list string="Property Tags" editable="bottom">
12+
<field name="name"/>
13+
</list>
14+
</field>
15+
</record>
716
</odoo>

estate/views/estate_property_type_views.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,40 @@
44
<field name="res_model">estate.property.type</field>
55
<field name="view_mode">list,form</field>
66
</record>
7+
<record id="estate_property_type_form" model="ir.ui.view">
8+
<field name="name">estate.property.type.form</field>
9+
<field name="model">estate.property.type</field>
10+
<field name="arch" type="xml">
11+
<form>
12+
<sheet>
13+
<div class="oe_title">
14+
<h1>
15+
<field name="name"/>
16+
</h1>
17+
</div>
18+
<notebook>
19+
<page string="Properties">
20+
<field name="property_ids">
21+
<list>
22+
<field name="name"/>
23+
<field name="expected_price"/>
24+
<field name="state"/>
25+
</list>
26+
</field>
27+
</page>
28+
</notebook>
29+
</sheet>
30+
</form>
31+
</field>
32+
</record>
33+
<record id="estate_property_type_list" model="ir.ui.view">
34+
<field name="name">estate.property.type.list</field>
35+
<field name="model">estate.property.type</field>
36+
<field name="arch" type="xml">
37+
<list string="Types">
38+
<field name="sequence" widget="handle" />
39+
<field name="name"/>
40+
</list>
41+
</field>
42+
</record>
743
</odoo>

estate/views/estate_property_views.xml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,30 @@
44
<field name="name">Properties</field>
55
<field name="res_model">estate.property</field>
66
<field name="view_mode">list,form</field>
7+
<field name="context">{'search_default_available': True}</field>
78
</record>
89
<record id="estate_property_form" model="ir.ui.view">
910
<field name="name">estate.property.form</field>
1011
<field name="model">estate.property</field>
1112
<field name="arch" type="xml">
1213
<form string="Properties">
1314
<header>
14-
<button name="action_sold" type="object" string="Sold" />
15-
<button name="action_cancel" type="object" string="Cancel"/>
15+
<button name="action_sold" type="object" string="Sold" invisible="state in ('sold','canceled')"/>
16+
<button name="action_cancel" type="object" string="Cancel" invisible="state in ('sold','canceled')"/>
17+
<field name="state" widget="statusbar" statusbar_visible="new,offer_received,offer_accepted,sold"/>
18+
1619
</header>
1720
<sheet>
1821
<div class="oe_title">
1922
<h1>
2023
<field name="name"/>
2124
</h1>
2225
</div>
23-
<field name="tag_ids" widget="many2many_tags"/>
26+
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
2427
<group>
2528
<group>
2629
<field name="state"/>
27-
<field name="property_type_id"/>
30+
<field name="property_type_id" options="{'no_create_edit': true}"/>
2831
<field name="postcode"/>
2932
<field name="date_availability"/>
3033
</group>
@@ -44,8 +47,8 @@
4447
<field name="facades"/>
4548
<field name="garage"/>
4649
<field name="garden"/>
47-
<field name="garden_area"/>
48-
<field name="garden_orientation"/>
50+
<field name="garden_area" invisible="not garden"/>
51+
<field name="garden_orientation" invisible="not garden"/>
4952
<field name="total_area"/>
5053
</group>
5154
</group>
@@ -70,14 +73,14 @@
7073
<field name="name">estate.property.list</field>
7174
<field name="model">estate.property</field>
7275
<field name="arch" type="xml">
73-
<list string="Properties">
76+
<list string="Properties" decoration-success="state in ('offer_received', 'offer_accepted')" decoration-muted="state == 'sold'" decoration-bf="state == 'offer_accepted'">
7477
<field name="name"/>
7578
<field name="postcode"/>
7679
<field name="bedrooms"/>
7780
<field name="living_area"/>
7881
<field name="expected_price"/>
7982
<field name="selling_price"/>
80-
<field name="date_availability"/>
83+
<field name="date_availability" optional="hide"/>
8184
</list>
8285
</field>
8386
</record>
@@ -90,7 +93,8 @@
9093
<field name="postcode"/>
9194
<field name="expected_price"/>
9295
<field name="bedrooms"/>
93-
<field name="living_area"/>
96+
<field name="living_area"
97+
filter_domain="[('living_area', '>=', self)]"/>
9498
<field name="facades"/>
9599
<filter string="Available" name="available" domain="[('state', 'in', ('new', 'offer_received'))]"/>
96100
<group expand="1" string="Group By">

0 commit comments

Comments
 (0)