Skip to content

Commit c0e98b3

Browse files
[CLN] estate: cleaned the code
1 parent af4d82b commit c0e98b3

File tree

10 files changed

+101
-32
lines changed

10 files changed

+101
-32
lines changed

.idea/workspace.xml

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

estate/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'views/estate_property_offer_views.xml',
1212
'views/estate_property_type_views.xml',
1313
'views/estate_property_tag_views.xml',
14-
'views/user_with_properties_views.xml',
14+
'views/res_users_views.xml',
1515
'views/estate_menus.xml'
1616
],
1717
'application': True,

estate/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from . import estate_property_type
33
from . import estate_property_tag
44
from . import estate_property_offer
5-
from . import user_with_properties
5+
from . import res_users

estate/models/estate_property.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,22 @@ def _compute_best_price(self):
7676

7777
@api.onchange('garden')
7878
def _onchange_garden(self):
79-
if self.garden:
80-
self.garden_area = 10
81-
self.garden_orientation = "north"
82-
else:
83-
self.garden_area = False
84-
self.garden_orientation = ""
79+
self.garden_area = 10 if self.garden else 0
80+
self.garden_orientation = 'north' if self.garden else ''
8581

8682
@api.ondelete(at_uninstall=False)
8783
def _unlink_if_new_or_cancelled_state(self):
88-
if any(not (property.state == 'new' or property.state == 'cancelled') for property in self):
84+
if any(not (prop.state == 'new' or prop.state == 'cancelled') for prop in self):
8985
raise UserError("You can only delete new or cancelled properties")
9086

91-
def action_mark_sold(self):
87+
def action_sold(self):
9288
for prop in self:
9389
if prop.state == "cancelled":
9490
raise UserError("You cannot sell a cancelled property")
9591
prop.state = "sold"
9692
return True
9793

98-
def action_mark_cancel(self):
94+
def action_cancel(self):
9995
for prop in self:
10096
if prop.state == "sold":
10197
raise UserError("You cannot cancel a sold property")

estate/models/user_with_properties.py renamed to estate/models/res_users.py

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

33

4-
class UserWithProperties(models.Model):
4+
class ResUsers(models.Model):
55
_inherit = 'res.users'
66
_description = 'user with properties model'
77

estate/views/estate_menus.xml

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,45 @@
11
<?xml version="1.0"?>
22
<odoo>
3-
<menuitem id="estate_property_root_menu" name="Real Estate">
4-
<menuitem id="estate_property_advertisements" name="Advertisements" sequence="1">
5-
<menuitem id="estate_property_menu" name="Properties" action="estate_property_action"/>
6-
</menuitem>
7-
<menuitem id="estate_property_settings" name="Settings" sequence="2">
8-
<menuitem id="estate_property_type_menu" name="Property Types" action="estate_property_type_action"
9-
sequence="1"/>
10-
<menuitem id="estate_property_tag_menu" name="Property Tags" action="estate_property_tag_action"
11-
sequence="2"/>
12-
</menuitem>
13-
</menuitem>
3+
<menuitem
4+
id="estate_property_menu_root"
5+
name="Real Estate"
6+
/>
7+
8+
<menuitem
9+
id="estate_property_menu_advertisements"
10+
name="Advertisements"
11+
parent="estate_property_menu_root"
12+
sequence="1"
13+
/>
14+
15+
<menuitem
16+
id="estate_property_menu_properties"
17+
name="Properties"
18+
parent="estate_property_menu_advertisements"
19+
action="estate_property_action"
20+
sequence="1"
21+
/>
22+
23+
<menuitem
24+
id="estate_property_menu_settings"
25+
name="Settings"
26+
parent="estate_property_menu_root"
27+
sequence="2"
28+
/>
29+
30+
<menuitem
31+
id="estate_property_menu_property_type"
32+
name="Property Types"
33+
parent="estate_property_menu_settings"
34+
action="estate_property_type_action"
35+
sequence="1"
36+
/>
37+
38+
<menuitem
39+
id="estate_property_menu_property_tag"
40+
name="Property Tags"
41+
parent="estate_property_menu_settings"
42+
action="estate_property_tag_action"
43+
sequence="2"
44+
/>
1445
</odoo>

estate/views/estate_property_type_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<form string="Property types">
88
<header>
99
<button type="action" name="%(estate_property_offer_action)d" string="Offers"
10-
class="oe_stat_button" icon="fa-star"></button>
10+
class="oe_stat_button" icon="fa-star"/>
1111
</header>
1212
<sheet>
1313
<div>

estate/views/estate_property_views.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<field name="arch" type="xml">
2727
<form string="Properties">
2828
<header>
29-
<button name="action_mark_sold" type="object" string="SOLD"
29+
<button name="action_sold" type="object" string="SOLD"
3030
invisible="state == 'sold' or state == 'cancelled'"/>
31-
<button name="action_mark_cancel" type="object" string="CANCEL"
31+
<button name="action_cancel" type="object" string="CANCEL"
3232
invisible="state == 'sold' or state == 'cancelled'"/>
3333
<field name="state" widget="statusbar" statusbar_visible="new,offer_received,offer_accepted,sold"/>
3434
</header>
@@ -113,7 +113,11 @@
113113
<templates>
114114
<t t-name="card">
115115
<div>
116-
<field name="name"/>
116+
<div>
117+
<h1>
118+
<field name="name"/>
119+
</h1>
120+
</div>
117121
<div>Expected Price:
118122
<field name="expected_price"/>
119123
</div>
@@ -125,7 +129,10 @@
125129
Selling Price:
126130
<field name="selling_price"/>
127131
</div>
128-
<field name="property_tag_ids" string="Property Tags" widget="many2many_tags" options="{'color_field': 'color'}"/>
132+
<div>
133+
<field name="property_tag_ids" string="Property Tags" widget="many2many_tags"
134+
options="{'color_field': 'color'}"/>
135+
</div>
129136
</div>
130137
</t>
131138
</templates>

estate/views/user_with_properties_views.xml renamed to estate/views/res_users_views.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<odoo>
2-
<record id="user_with_properties_view_list" model="ir.ui.view">
3-
<field name="name">user.with.properties.list</field>
2+
<record id="view_users_form" model="ir.ui.view">
3+
<field name="name">res.users.view.form.inherit.estate</field>
44
<field name="model">res.users</field>
55
<field name="inherit_id" ref="base.view_users_form"/>
66
<field name="arch" type="xml">

estate_account/models/estate_property.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
class EstateProperty(models.Model):
55
_inherit = "estate.property"
66

7-
def action_mark_sold(self):
7+
def action_sold(self):
8+
super().action_sold()
89
for prop in self:
910
self.env['account.move'].sudo().create(
1011
{
@@ -24,4 +25,3 @@ def action_mark_sold(self):
2425
]
2526
}
2627
)
27-
return super().action_mark_sold()

0 commit comments

Comments
 (0)