Skip to content

Commit 185c842

Browse files
[ADD] real_estate: Added Property Tags and Property Offer Models
- Introduce estate.property.tag model to manage property tags. - Introduce estate.property.offer model to manage offers related to properties. - Implement list and form views for property tags. - Implement list and form views for property offers. Chapter #7
1 parent f575f20 commit 185c842

11 files changed

Lines changed: 170 additions & 21 deletions

estate/__manifest__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
'security/ir.model.access.csv',
1212
'views/estate_property_views.xml',
1313
'views/estate_property_type_views.xml',
14+
'views/estate_property_tags_views.xml',
15+
'views/estate_property_offer_views.xml',
1416
'views/estate_menus.xml'
1517
],
1618
'license': 'LGPL-3', # Default License

estate/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from . import estate_property, estate_property_type
1+
from . import estate_property, estate_property_type, estate_property_tag, estate_property_offer

estate/models/estate_property.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class EstateProperty(models.Model):
3030
)
3131
garage = fields.Boolean(string="Garage")
3232
living_area = fields.Float(string="Living Area (sqm)")
33-
name = fields.Char(string="Title", required=True,)
33+
name = fields.Char(string="Title", required=True)
34+
offer_ids = fields.One2many(
35+
'estate.property.offer', 'property_id', string='Offers')
3436
postcode = fields.Char(string="Postcode")
3537
property_type_id = fields.Many2one(
3638
'estate.property.type', string="Property Type")
@@ -48,7 +50,6 @@ class EstateProperty(models.Model):
4850
default='new')
4951
tag_ids = fields.Many2many(
5052
'estate.property.tag',
51-
5253
string="Tags"
5354
)
5455

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from odoo import fields, models
2+
3+
4+
class EstatePropertyOffer(models.Model):
5+
6+
_name = 'estate.property.offer'
7+
_description = "A model where offer for the properties are stored"
8+
9+
price = fields.Float(required=True)
10+
status = fields.Selection(selection=[('accepted', "Accepted"),
11+
('refused', "Refused")],
12+
required=True)
13+
partner_id = fields.Many2one('res.partner', required=True)
14+
property_id = fields.Many2one(
15+
'estate.property', required=True)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from odoo import fields, models
2+
3+
4+
class EstatePropertyTag(models.Model):
5+
6+
_name = "estate.property.tag"
7+
_description = "Tags for properties"
8+
9+
name = fields.Char(string="Tags")
10+
color = fields.Integer(string="Color")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
22
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
33
estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1
4+
estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1
5+
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1

estate/views/estate_menus.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<?xml version="1.0"?>
22
<odoo>
33

4-
<menuitem id="real_estate_root" name="Real Estate" web_icon="estate,static/description/Real_Estate_Logo.jpg" />
4+
<menuitem id="real_estate_root" name="Real Estate" web_icon="estate,static/description/Real_Estate_Logo.jpg"/>
55

66
<menuitem id="real_estate_properties_menu" name="Advertisements" parent="real_estate_root"/>
7-
<menuitem id="real_estate_properties_settings_menu" name="Settings" parent="real_estate_root" />
7+
<menuitem id="real_estate_properties_settings_menu" name="Settings" parent="real_estate_root"/>
8+
9+
<menuitem id="real_estate_menu_action" name="All Properties " parent="real_estate_properties_menu"
10+
action="test_property_action"/>
11+
<menuitem id="real_estate_property_type_action" name="Property Types" parent="real_estate_properties_settings_menu"
12+
action="test_property_type_action"/>
13+
<menuitem id="real_estate_property_tags_action" name="Property Tags" parent="real_estate_properties_settings_menu"
14+
action="test_property_tags_action"/>
815

9-
<menuitem id="real_estate_menu_action" name="All Properties " parent="real_estate_properties_menu" action="test_property_action"/>
10-
<menuitem id="real_estate_property_type_action" name="Property Types" parent="real_estate_properties_settings_menu" action="test_property_type_action"/>
1116

1217
</odoo>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
4+
5+
<!--_________________________________________ WINDOW ACTION _________________________________________-->
6+
7+
<record id="test_property_offer_action" model="ir.actions.act_window">
8+
<field name="name">Property Offers</field>
9+
<field name="res_model">estate.property.offer</field>
10+
<field name="view_mode">list,form</field>
11+
</record>
12+
13+
14+
<!--_________________________________________ LIST VIEW _________________________________________-->
15+
<record id="estate_property_offer_view_list" model="ir.ui.view">
16+
<field name="name">estate.property.offer.list</field>
17+
<field name="model">estate.property.offer</field>
18+
19+
<field name="arch" type="xml">
20+
<list string="">
21+
<field name="price"/>
22+
<field name="partner_id"/>
23+
<field name="status"/>
24+
</list>
25+
</field>
26+
</record>
27+
<!--_________________________________________ FORM VIEW _________________________________________-->
28+
29+
<record id="estate_property_tags_view_form" model="ir.ui.view">
30+
<field name="name">estate.property.offer.form</field>
31+
<field name="model">estate.property.offer</field>
32+
<field name="arch" type="xml">
33+
<form string="">
34+
<sheet>
35+
<group>
36+
<field name="price" widget=""/>
37+
<field name="partner_id" widget="many2one_avatar_user"/>
38+
<field name="status" widget="radio"/>
39+
</group>
40+
</sheet>
41+
</form>
42+
</field>
43+
</record>
44+
45+
</odoo>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
4+
5+
<!--_________________________________________ WINDOW ACTION _________________________________________-->
6+
7+
<record id="test_property_tags_action" model="ir.actions.act_window">
8+
<field name="name">Property Types</field>
9+
<field name="res_model">estate.property.tag</field>
10+
<field name="view_mode">list,form</field>
11+
</record>
12+
13+
<!--_________________________________________ LIST ACTION _________________________________________-->
14+
15+
16+
<record id="estate_property_tags_view_list" model="ir.ui.view">
17+
<field name="name">estate.property.tag.list</field>
18+
<field name="model">estate.property.tag</field>
19+
20+
<field name="arch" type="xml">
21+
<list string="">
22+
23+
24+
<field name="name" default_focus="1" class="oe_inline"/>
25+
26+
<field name="color" widget="color_picker"/>
27+
28+
29+
</list>
30+
</field>
31+
32+
</record>
33+
34+
35+
<!--_________________________________________ FORM VIEW _________________________________________-->
36+
37+
<record id="estate_property_tags_view_form" model="ir.ui.view">
38+
<field name="name">estate.property.tag.form</field>
39+
<field name="model">estate.property.tag</field>
40+
41+
<field name="arch" type="xml">
42+
<form string="">
43+
<sheet>
44+
<div class="oe_title ">
45+
<label for="name"/>
46+
<h1>
47+
<field name="name" default_focus="1" class="oe_inline"/>
48+
</h1>
49+
<h4>
50+
<field name="color" widget="color_picker"/>
51+
</h4>
52+
</div>
53+
</sheet>
54+
</form>
55+
</field>
56+
57+
</record>
58+
59+
60+
</odoo>

estate/views/estate_property_type_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<field name="model">estate.property.type</field>
1313

1414
<field name="arch" type="xml">
15-
<form >
15+
<form>
1616
<sheet>
1717
<div class="oe_title oe_inline text-center">
1818
<label for="name"/>

0 commit comments

Comments
 (0)