Skip to content

Commit 46e680e

Browse files
committed
[IMP] estate : add statusbar, helper text and refined sold constrains
- status will not change to sold/cancelled unless an offer is accepted. - helper text added to visibility field. - state field is added at the header of form view.
1 parent 5782473 commit 46e680e

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

estate/models/estate_property.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ def _set_garden_default_values(self):
106106
def action_property_sold(self):
107107
if self.state in ["Sold", "Cancelled"]:
108108
raise UserError(f"Property is already {self.state}")
109+
if float_is_zero(self.selling_price, precision_rounding=0.01):
110+
raise UserError(
111+
"Atleast one offer must be accepted before selling the property"
112+
)
109113
self.state = "Sold"
110114

111115
def action_property_cancelled(self):

estate/models/estate_property_offer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ class EstateOfferModel(models.Model):
1313
)
1414
partner_id = fields.Many2one("res.partner", required=True)
1515
property_id = fields.Many2one("estate.property", required=True)
16-
validity = fields.Integer(default=7)
16+
validity = fields.Integer(
17+
default=7,
18+
help="offer validity period in days; the offer will be automatically refused when this expires.",
19+
)
1720
date_deadline = fields.Date(default=fields.Date.today() + timedelta(days=7))
1821

1922
_sql_constraints = [

estate/models/estate_property_type.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class EstateTypeModel(models.Model):
66
_description = "Real Estate Property Type Model"
77

88
name = fields.Char(required=True)
9+
property_ids = fields.One2many("estate.property", "property_type_id")
910

1011
_sql_constraints = [
1112
(

estate/views/estate_property_type_views.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,25 @@
1111
</p>
1212
</field>
1313
</record>
14+
<record id="action_estate_property_type_form" model="ir.ui.view">
15+
<field name="name">Properties by Types</field>
16+
<field name="model">estate.property.type</field>
17+
<field name="arch" type="xml">
18+
<form>
19+
<sheet>
20+
<notebook>
21+
<page name="properties" string="Properties">
22+
<field name="property_ids">
23+
<list>
24+
<field name="name" string="Title" />
25+
<field name="expected_price" string="Expected Price" />
26+
<field name="state" string="State" />
27+
</list>
28+
</field>
29+
</page>
30+
</notebook>
31+
</sheet>
32+
</form>
33+
</field>
34+
</record>
1435
</odoo>

estate/views/estate_property_views.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<header>
3535
<button name="action_property_sold" type="object" string="Sold"/>
3636
<button name="action_property_cancelled" type="object" string="Cancelled"/>
37+
<field name="state" widget="statusbar" statusbar_visible="New,Offer Received,Offer Accepted,Sold" />
3738
</header>
3839
<sheet>
3940
<div>

0 commit comments

Comments
 (0)