Skip to content

Commit 68e69b0

Browse files
committed
[IMP] Estate: Completed Chapter-7
Implemented Many2many and One2many relations. Added estate.property.tag model with Many2many relation to estate.property Added offer_ids One2many field to display offers on property form Created corresponding views, menus, actions and access to above models and files
1 parent a7fc97b commit 68e69b0

11 files changed

Lines changed: 86 additions & 15 deletions

estate/__manifest__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
'security/ir.model.access.csv',
1010
'views/estate_property_views.xml',
1111
'views/estate_property_types_views.xml',
12+
'views/estate_property_tags_views.xml',
13+
'views/estate_property_offer_views.xml',
1214
'views/estate_property_menus.xml',
1315
],
1416
'installable': True,

estate/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
from . import estate_property
22
from . import estate_property_types
3+
from . import estate_property_tags
4+
from . import estate_property_offer

estate/models/estate_property.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,10 @@ class EstateProperty(models.Model):
2424
('north', "North"), ('south', "South"), ('east', "East"), ('west', "West")],
2525
help="Direction the garden faces"
2626
)
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
40-
)
27+
tag_ids = fields.Many2many('estate.property.tag', string="Tags")
28+
property_type_id = fields.Many2one('estate.property.type', string="Property Type")
29+
buyer_id = fields.Many2one('res.partner', string="Buyer", copy=False)
30+
salesperson_id = fields.Many2one('res.users', string="Salesperson", default=lambda self: self.env.user)
4131
state = fields.Selection(
4232
selection=[
4333
('new', "New"),
@@ -51,3 +41,4 @@ class EstateProperty(models.Model):
5141
copy=False,
5242
default="new",
5343
)
44+
offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from odoo import fields, models
2+
3+
4+
class EstatepropertyOffer(models.Model):
5+
_name = 'estate.property.offer'
6+
_description = "Property Offers"
7+
8+
price = fields.Float()
9+
status = fields.Selection(
10+
selection=[
11+
('accepted', "Accepted"),
12+
('refused', "Refused"),
13+
],
14+
copy=False
15+
)
16+
partner_id = fields.Many2one("res.partner", required=True)
17+
property_id = fields.Many2one("estate.property", required=True)
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 EstatePropertyTags(models.Model):
5+
_name = 'estate.property.tag'
6+
_description = "Property Tags"
7+
8+
name = fields.Char(required=True)

estate/models/estate_property_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ class EstatePropertyType(models.Model):
55
_name = 'estate.property.type'
66
_description = "Property Type"
77

8-
name = fields.Char(string="Name", required=True)
8+
name = fields.Char(required=True)
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
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
33
access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1
4+
access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1
5+
access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1

estate/views/estate_property_menus.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@
99
<menuitem id="estate_property_type_menu_action"
1010
action="estate_property_type_action"
1111
parent="estate_second_level_menu"/>
12+
13+
<menuitem id="estate_property_tag_menu_action"
14+
action="estate_property_tag_action"
15+
parent="estate_second_level_menu"/>
1216
</odoo>
17+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<odoo>
2+
<record id="estate_property_offer_list_view" model="ir.ui.view">
3+
<field name="name">estate.property.offer.list</field>
4+
<field name="model">estate.property.offer</field>
5+
<field name="arch" type="xml">
6+
<list>
7+
<field name="price"/>
8+
<field name="partner_id"/>
9+
<field name="status"/>
10+
</list>
11+
</field>
12+
</record>
13+
14+
<record id="estate_property_offer_form_view" model="ir.ui.view">
15+
<field name="name">estate.property.offer.form</field>
16+
<field name="model">estate.property.offer</field>
17+
<field name="arch" type="xml">
18+
<form>
19+
<group>
20+
<field name="price"/>
21+
<field name="partner_id"/>
22+
<field name="status"/>
23+
</group>
24+
</form>
25+
</field>
26+
</record>
27+
</odoo>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<odoo>
2+
<record id="estate_property_tag_action" model="ir.actions.act_window">
3+
<field name="name">Property Tags</field>
4+
<field name="res_model">estate.property.tag</field>
5+
<field name="view_mode">list,form</field>
6+
</record>
7+
</odoo>

0 commit comments

Comments
 (0)