Skip to content

Commit 3733b88

Browse files
committed
[IMP] estate: fixed state button layout.
added onchange on offer_ids if len(offer_ids) is zero then will change state to 'new'. fixed state button layout was in header first shifted to context menu. added sold button disabled when there is no offer accepted and if offer is accepted then will show in highlight color.
1 parent 38cc6e5 commit 3733b88

File tree

4 files changed

+33
-18
lines changed

4 files changed

+33
-18
lines changed

estate/models/estate_property.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class EstateProperty(models.Model):
4747
copy=False,
4848
default="new",
4949
)
50-
property_type_id = fields.Many2one("estate.property.type", string="Property Type")
50+
property_type_id = fields.Many2one("estate.property.type", string="Property Type", required=True)
5151
customer = fields.Many2one("res.partner", string="Customer", copy=False)
5252
salesperson = fields.Many2one(
5353
"res.users", string="Salesperson", default=lambda self: self.env.user
@@ -86,6 +86,11 @@ def _onchange_garden(self):
8686
else:
8787
self.garden_area = 0
8888
self.garden_orientation = None
89+
90+
@api.onchange("offer_ids")
91+
def _onchange_offer_ids(self):
92+
if len(self.offer_ids) == 0:
93+
self.state = "new"
8994

9095
def action_sold_property(self):
9196
for record in self:

estate/views/estate_property_type_views.xml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@
1616
<field name="model">estate.property.type</field>
1717
<field name="arch" type="xml">
1818
<form name="Property Type List">
19-
<header>
20-
<div class="oe_stat_button">
21-
<button type="action" name="%(estate.action_estate_property_offer)d" icon="fa-list">
22-
Offers:
23-
<field name="offer_count"/>
19+
<sheet>
20+
<div class="oe_button_box" name="button_box">
21+
<button class="oe_stat_button"
22+
type="action"
23+
name="%(estate.action_estate_property_offer)d"
24+
icon="fa-bars"
25+
invisible="offer_count == 0">
26+
<div class="o_stat_info">
27+
<span class="o_stat_value">
28+
<field name="offer_count"/>
29+
</span>
30+
<span class="o_stat_text">
31+
Offers
32+
</span>
33+
</div>
2434
</button>
2535
</div>
26-
</header>
27-
<sheet>
2836
<h1>
2937
<field name="name"/>
3038
</h1>

estate/views/estate_property_views.xml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,29 @@
1818
<field name="arch" type="xml">
1919
<form string="Property">
2020
<header>
21-
<button name="action_sold_property" type="object" string="Sold" invisible="state in ('sold','cancelled')"/>
22-
<button name="action_cancel_offer" type="object" string="Cancel" invisible="state in ('sold','cancelled')"/>
21+
<button name="action_sold_property" type="object" string="Sold" class="oe_highlight" invisible="state in ('sold','cancelled','new','offer_received')"/>
22+
<button name="action_sold_property" type="object" string="Sold" class="disabled" invisible="state in ('sold','cancelled','offer_accepted')"/>
23+
<button name="action_cancel_offer" type="object" string="Cancel" invisible="state in ('sold','cancelled')"
24+
confirm="Are you sure to Cancel this Property? You cannot revert this back."/>
2325
<field name="state" widget="statusbar"/>
24-
</header>
26+
</header>
2527
<sheet>
26-
<h1>
28+
<h1>
2729
<field name="name" string="Title"/>
2830
</h1>
2931
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
3032
<hr/>
3133
<group>
3234
<group>
3335
<field name="postcode"/>
34-
<field name="date_avaliability" string="Avaliable From"/>
35-
</group>
36-
<group>
37-
<field name="property_type_id" options="{'no_create': true}"/>
3836
<field name="expected_price"/>
3937
<field name="selling_price"/>
4038
<field name="best_price" string="Best Offer"/>
4139
</group>
40+
<group>
41+
<field name="property_type_id" options="{'no_create': true}"/>
42+
<field name="date_avaliability" string="Avaliable From"/>
43+
</group>
4244
</group>
4345
<notebook>
4446
<page string="Description">
@@ -49,6 +51,8 @@
4951
<field name="living_area" string="Living Area(sqm)"/>
5052
<field name="facades"/>
5153
<field name="garage"/>
54+
</group>
55+
<group>
5256
<field name="garden"/>
5357
<field name="garden_area" string="Garden Area(sqm)" invisible="not garden"/>
5458
<field name="garden_orientation" invisible="not garden"/>

estate_account/models/estate_property.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ class EstatePropertyInherit(models.Model):
88

99
def action_sold_property(self):
1010
for record in self:
11-
if record.selling_price == 0:
12-
raise UserError("Cannot sell Property without any accepted offer")
1311
self.env["account.move"].create(
1412
{
1513
"partner_id": record.customer.id,

0 commit comments

Comments
 (0)