Skip to content

Commit d604277

Browse files
author
karygauss03
committed
[IMP] Estate: Adding Estate Relationships with Offers, types and tags.
In this commit, I added the needed relationships between types, tags and offers using Many2one, Many2many and One2many. I also added the needed views, forms and actions (only for tags and types). I added a new notebook page within the estate property view model to display and edit the list of offers. This commit is related to the 7th chapter of Server Framework 101 in Odoo's documentation.
1 parent 830ba91 commit d604277

12 files changed

+212
-13
lines changed

estate/__manifest__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
],
1212
'data': [
1313
'security/ir.model.access.csv',
14+
'views/estate_property_tag_views.xml',
15+
'views/estate_property_offer_views.xml',
16+
'views/estate_property_type_views.xml',
1417
'views/estate_property_views.xml',
1518
'views/estate_menus.xml'
1619
],

estate/models/__init__.py

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

estate/models/estate_property.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from dateutil.relativedelta import relativedelta
33

44

5-
class EstateModel(models.Model):
6-
_name = "estate_property"
5+
class EstateProperty(models.Model):
6+
_name = "estate.property"
77
_description = "Real Estate"
88

99
name = fields.Char('Name', required=True)
@@ -32,3 +32,8 @@ class EstateModel(models.Model):
3232
help="Garden orientation selection"
3333
)
3434
active = fields.Boolean('Is Active', default=True)
35+
property_type_id = fields.Many2one('estate.property.type', string='Property Type')
36+
buyer_id = fields.Many2one('res.partner', 'Buyer', copy=False)
37+
salesperson_id = fields.Many2one('res.users', 'Salesperson', index=True, default=lambda self: self.env.user)
38+
tag_ids = fields.Many2many('estate.property.tag', string='Tags')
39+
offer_ids = fields.One2many('estate.property.offer', 'property_id', string='Offers')
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from odoo import models, fields
2+
3+
4+
class EstatePropertyOffer(models.Model):
5+
_name = "estate.property.offer"
6+
_description = "Estate Property Offer"
7+
8+
price = fields.Float(string="Price")
9+
status = fields.Selection(
10+
string="Status",
11+
selection=[('accepted', 'Accepted'), ('refused', 'Refused')],
12+
copy=False
13+
)
14+
partner_id = fields.Many2one('res.partner', required=True, string="Partner")
15+
property_id = fields.Many2one('estate.property', required=True, string="Property")

estate/models/estate_property_tag.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from odoo import models, fields
2+
3+
4+
class EstatePropertyTag(models.Model):
5+
_name = 'estate.property.tag'
6+
_description = 'Estate Property Tags'
7+
8+
name = fields.Char(string='Name', required=True)

estate/models/estate_property_type.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from odoo import models, fields
2+
3+
4+
class EstatePropertyType(models.Model):
5+
_name = "estate.property.type"
6+
_description = "Estate Property Type"
7+
8+
name = fields.Char(string="Property Type", required=True)

estate/security/ir.model.access.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +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
3+
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_menus.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<odoo>
33
<menuitem id="estate_property_menu_root" name="Estate">
44
<menuitem id="estate_property_first_level_menu" name="Estates">
5-
<menuitem id="estate_property_menu_action" action="model_estate_property_action"/>
5+
<menuitem id="estate_property_menu_action" action="estate_property_action"/>
6+
<menuitem id="estate_property_type_menu_action" action="estate_property_type_action"/>
7+
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_action"/>
68
</menuitem>
79
</menuitem>
810
</odoo>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<record id="estate_property_offer_view_search" model="ir.ui.view">
4+
<field name="name">estate.property.offer.search</field>
5+
<field name="model">estate.property.offer</field>
6+
<field name="arch" type="xml">
7+
<search string="Property offer Search">
8+
<field name="partner_id" string="Partner"/>
9+
<field name="property_id" string="Property"/>
10+
<field name="price" string="Price"/>
11+
<separator/>
12+
<group expand="1" string="Group By">
13+
<filter name="status" string="Status" context="{'group_by':'status'}"/>
14+
</group>
15+
</search>
16+
</field>
17+
</record>
18+
19+
<record id="estate_property_offer_view_form" model="ir.ui.view">
20+
<field name="name">estate.property.offer.form</field>
21+
<field name="model">estate.property.offer</field>
22+
<field name="arch" type="xml">
23+
<form string="Property tag Form">
24+
<sheet>
25+
<group>
26+
<field name="price" string="Price"/>
27+
<field name="status" string="Status"/>
28+
<field name="partner_id" string="Partner"/>
29+
<field name="property_id" string="Property"/>
30+
</group>
31+
</sheet>
32+
</form>
33+
</field>
34+
</record>
35+
36+
<record id="estate_property_offer_view_list" model="ir.ui.view">
37+
<field name="name">estate.property.offer.list</field>
38+
<field name="model">estate.property.offer</field>
39+
<field name="arch" type="xml">
40+
<list string="Tags">
41+
<field name="price" string="Price"/>
42+
<field name="status" string="Status"/>
43+
<field name="partner_id" string="Partner"/>
44+
<field name="property_id" string="Property"/>
45+
</list>
46+
</field>
47+
</record>
48+
</odoo>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<record id="estate_property_tag_view_search" model="ir.ui.view">
4+
<field name="name">estate.property.tag.search</field>
5+
<field name="model">estate.property.tag</field>
6+
<field name="arch" type="xml">
7+
<search string="Property tags Search">
8+
<field name="name" string="Tag Name"/>
9+
</search>
10+
</field>
11+
</record>
12+
13+
<record id="estate_property_tag_view_form" model="ir.ui.view">
14+
<field name="name">estate.property.tag.form</field>
15+
<field name="model">estate.property.tag</field>
16+
<field name="arch" type="xml">
17+
<form string="Property tag Form">
18+
<sheet>
19+
<group>
20+
<field name="name" string="Name"/>
21+
</group>
22+
</sheet>
23+
</form>
24+
</field>
25+
</record>
26+
27+
<record id="estate_property_tag_view_list" model="ir.ui.view">
28+
<field name="name">estate.property.tag.list</field>
29+
<field name="model">estate.property.tag</field>
30+
<field name="arch" type="xml">
31+
<list string="Tags">
32+
<field name="name" string="Name"/>
33+
</list>
34+
</field>
35+
</record>
36+
37+
<record id="estate_property_tag_action" model="ir.actions.act_window">
38+
<field name="name">Property tag Action</field>
39+
<field name="res_model">estate.property.tag</field>
40+
<field name="view_mode">list,form</field>
41+
</record>
42+
</odoo>

0 commit comments

Comments
 (0)