Skip to content

Commit 0da9346

Browse files
committed
iuhiufaiufoue
1 parent e1c39cf commit 0da9346

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

estate/models/estate_property.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,9 @@ def _check_selling_price_margin(self):
107107
min_acceptable_price = record.expected_price * 0.9
108108
if float_compare(record.selling_price, min_acceptable_price, precision_digits=2) < 0:
109109
raise ValidationError("The selling price cannot be lower than 90% of the expected price.")
110+
111+
@api.depends(at_uninstall=False)
112+
def check_delete(self):
113+
for record in self:
114+
if record.state not in ['new', 'cancelled']:
115+
raise UserError("YOU CANNOT DELETE A PROPERTY THAT IS NOT NEW OR CANCELLED")

estate/models/estate_property_type.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from odoo import fields, models
1+
from odoo import api, fields, models
22

33
class estate_property_type(models.Model):
44
_name = "estate.property.type"
@@ -10,6 +10,13 @@ class estate_property_type(models.Model):
1010
('unique_type_name', 'UNIQUE(name)', 'The name should be unique')
1111
]
1212

13-
_order = "sequence, name"
13+
_order = "name"
1414

1515
property_id = fields.One2many("estate.property", "property_type_id")
16+
offer_id = fields.One2many("estate.property.offer", "property_id")
17+
offer_counts = fields.Integer(compute="_compute_offer_counts")
18+
19+
@api.depends("offer_id")
20+
def _compute_offer_counts(self):
21+
for record in self:
22+
record.offer_counts = len(record.offer_id)

estate/views/estate_property_type_views.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
<field name="arch" type="xml">
66
<form string="Estate Property Type">
77
<sheet>
8+
<header>
9+
<button type="action"
10+
name="%(estate_property_offer_view)d"
11+
class="oe_stat_button"
12+
icon="fa-money">
13+
<div><field name="offer_counts" /> Offers </div>
14+
</button>
15+
</header>
16+
<group>
17+
<field name="name" />
18+
</group>
819
<notebook>
920
<page string="Properties">
1021
<field name="property_id">

0 commit comments

Comments
 (0)