Skip to content

Commit dd14df9

Browse files
committed
[IMP] estate: add custom views
1 parent 1d3d53e commit dd14df9

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

estate/models/estate_property.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def _compute_total_area(self):
5454
@api.depends('offer_ids.price')
5555
def _compute_best_price(self):
5656
for record in self:
57-
record.best_price = max(record.offer_ids, key=lambda p: p.price, default=0).price
57+
if len(record.offer_ids)>0:
58+
record.best_price = max(record.offer_ids, key=lambda p: p.price).price
5859

5960
@api.onchange('garden')
6061
def _onchange_garden(self):

estate/models/estate_property_offer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from odoo import models, fields ,api, exceptions
1+
from odoo import models, fields, api, exceptions
22

33

44
class EstatePropertyOffer(models.Model):

estate/models/estate_property_tag.py

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

1010
_tags_uniq = models.Constraint(
1111
'unique(name)',
12-
f"The tag name already exists",
13-
)
12+
"The tag name already exists",
13+
)

estate/models/estate_property_type.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ class EstatePropertyType(models.Model):
66
_description = "Estate properties Types"
77

88
name = fields.Char('Name', required=True, translate=True)
9+
properties_ids = fields.One2many("estate.property", "property_type_id", "Properties")
910

1011
_types_uniq = models.Constraint(
1112
'unique(name)',
12-
f"The type name already exists",
13-
)
13+
"The type name already exists",
14+
)

estate/views/estate_property_type_views.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
<field name="name" placeholder="House" class="mb16" />
1212
</h1>
1313
</div>
14+
<notebook>
15+
<page string="Properties">
16+
<field name="properties_ids">
17+
<list>
18+
<field name="name" string="Title" />
19+
<field name="state" />
20+
<field name="expected_price" />
21+
</list>
22+
</field>
23+
</page>
24+
</notebook>
1425
</sheet>
1526
</form>
1627
</field>
@@ -26,4 +37,4 @@
2637
</p>
2738
</field>
2839
</record>
29-
</odoo>
40+
</odoo>

estate/views/estate_property_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<header>
3030
<button name="action_sold_property" type="object" string="Sold" />
3131
<button name="action_cancel_property" type="object" string="Cancel" />
32+
<field name="state" widget="statusbar"/>
3233
</header>
3334
<sheet>
3435
<div class="oe_title">
@@ -52,7 +53,6 @@
5253
<notebook>
5354
<page string="Description">
5455
<group>
55-
<field name="state" />
5656
<field name="description" />
5757
<field name="bedrooms" />
5858
<field name="living_area" />

0 commit comments

Comments
 (0)