Skip to content

Commit a7fc97b

Browse files
committed
[IMP] Estate: Partially completed chapter 7
Created new model called estate_property_type.py. Added actions and menus. Implemented list, form and search views in estate_property_types.xml
1 parent 5b1412b commit a7fc97b

9 files changed

Lines changed: 97 additions & 31 deletions

File tree

awesome_gallery/models/ir_action.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
class ActWindowView(models.Model):
66
_inherit = 'ir.actions.act_window.view'
77

8-
9-
view_mode = fields.Selection(selection_add=[
8+
view_mode = fields.Selection(selection_add=[
109
('gallery', "Awesome Gallery")
1110
], ondelete={'gallery': 'cascade'})

estate/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'data': [
99
'security/ir.model.access.csv',
1010
'views/estate_property_views.xml',
11+
'views/estate_property_types_views.xml',
1112
'views/estate_property_menus.xml',
1213
],
1314
'installable': True,

estate/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import estate_property
2+
from . import estate_property_types

estate/models/estate_property.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
class EstateProperty(models.Model):
5-
_name = "estate.property"
5+
_name = 'estate.property'
66
_description = "Real Estate Property"
77

88
name = fields.Char(required=True)
@@ -23,7 +23,20 @@ class EstateProperty(models.Model):
2323
selection=[
2424
('north', "North"), ('south', "South"), ('east', "East"), ('west', "West")],
2525
help="Direction the garden faces"
26-
26+
)
27+
property_type_id = fields.Many2one(
28+
'estate.property.type',
29+
string='Property Type'
30+
)
31+
buyer_id = fields.Many2one(
32+
'res.partner',
33+
string='Buyer',
34+
copy=False
35+
)
36+
salesperson_id = fields.Many2one(
37+
'res.users',
38+
string='Salesperson',
39+
default=lambda self: self.env.user
2740
)
2841
state = fields.Selection(
2942
selection=[
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from odoo import fields, models
2+
3+
4+
class EstatePropertyType(models.Model):
5+
_name = 'estate.property.type'
6+
_description = "Property Type"
7+
8+
name = fields.Char(string="Name", required=True)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
2-
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
2+
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
3+
access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<odoo>
2-
<menuitem id="estate_menu_root" name="Real Estate"/>
3-
<menuitem id="estate_first_level_menu" name="Advertisements" parent="estate_menu_root"/>
4-
<menuitem id="estate_property_menu_action"
5-
action="estate_property_action"
6-
parent="estate_first_level_menu"/>
2+
<menuitem id="estate_menu_root" name="Real Estate"/>
3+
<menuitem id="estate_first_level_menu" name="Advertisements" parent="estate_menu_root"/>
4+
<menuitem id="estate_property_menu_action"
5+
action="estate_property_action"
6+
parent="estate_first_level_menu"/>
7+
8+
<menuitem id="estate_second_level_menu" name="Settings" parent="estate_menu_root"/>
9+
<menuitem id="estate_property_type_menu_action"
10+
action="estate_property_type_action"
11+
parent="estate_second_level_menu"/>
712
</odoo>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<odoo>
2+
<record id="estate_property_type_action" model="ir.actions.act_window">
3+
<field name="name">Property Types</field>
4+
<field name="res_model">estate.property.type</field>
5+
<field name="view_mode">list,form</field>
6+
</record>
7+
8+
<record id="estate_property_type_list_view" model="ir.ui.view">
9+
<field name="name">estate.property.type.list</field>
10+
<field name="model">estate.property.type</field>
11+
<field name="arch" type="xml">
12+
<list>
13+
<field name="name"/>
14+
</list>
15+
</field>
16+
</record>
17+
18+
<record id="estate_property_type_form_view" model="ir.ui.view">
19+
<field name="name">estate.property.type.form</field>
20+
<field name="model">estate.property.type</field>
21+
<field name="arch" type="xml">
22+
<form>
23+
<sheet>
24+
<div class="oe_title">
25+
<h1>
26+
<field name="name"/>
27+
</h1>
28+
</div>
29+
</sheet>
30+
</form>
31+
</field>
32+
</record>
33+
</odoo>

estate/views/estate_property_views.xml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
</div>
3636
<group>
3737
<group>
38+
<field name="property_type_id"/>
3839
<field name="postcode"/>
3940
<field name="date_availability"/>
4041
</group>
@@ -55,32 +56,36 @@
5556
<field name="garden_area"/>
5657
<field name="garden_orientation"/>
5758
</group>
58-
</page> </notebook>
59+
</page>
60+
<page string="Other Info">
61+
<group>
62+
<field name="salesperson_id"/>
63+
<field name="buyer_id"/>
64+
</group>
65+
</page>
66+
</notebook>
5967
</sheet>
6068
</form>
6169
</field>
6270
</record>
6371

6472
<record id="estate_property_view_search" model="ir.ui.view">
65-
<field name="name">estate.property.search</field>
66-
<field name="model">estate.property</field>
67-
<field name="arch" type="xml">
68-
<search>
69-
<field name="name" string="Title"/>
70-
<field name="postcode"/>
71-
<field name="expected_price"/>
72-
<field name="bedrooms"/>
73-
<field name="living_area" string="Living Area (sqm)"/>
74-
<field name="facades"/>
75-
76-
<separator/>
77-
78-
<filter string="Available" name="available" domain="[('date_availability','&lt;=', context_today())]"/>
79-
80-
<group>
73+
<field name="name">estate.property.search</field>
74+
<field name="model">estate.property</field>
75+
<field name="arch" type="xml">
76+
<search>
77+
<field name="name" string="Title"/>
78+
<field name="postcode"/>
79+
<field name="expected_price"/>
80+
<field name="bedrooms"/>
81+
<field name="living_area" string="Living Area (sqm)"/>
82+
<field name="facades"/>
83+
<separator/>
84+
<filter string="Available" name="available" domain="[('date_availability','&lt;=', context_today())]"/>
85+
<group>
8186
<filter string="Postcode" name="postcode" context="{'group_by':'postcode'}"/>
82-
</group>
83-
</search>
84-
</field>
85-
</record>
87+
</group>
88+
</search>
89+
</field>
90+
</record>
8691
</odoo>

0 commit comments

Comments
 (0)