Skip to content

Commit 343fdf9

Browse files
committed
[ADD] estate: property relations:-type, tags, offers, buyer, salesperson
1 parent c53de94 commit 343fdf9

12 files changed

+137
-23
lines changed

estate/__manifest__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
'data': [
88
'security/estate_security.xml',
99
'security/ir.model.access.csv',
10+
'views/estate_property_offers_views.xml',
11+
'views/estate_property_tag_views.xml',
12+
'views/estate_property_type_views.xml',
1013
'views/estate_property_views.xml',
1114
'views/estate_menus.xml',
1215
],

estate/models/__init__.py

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

estate/models/estate_property.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
from odoo import fields, models
2-
from datetime import timedelta
32

43

54
class EstateProperty(models.Model):
65
_name = "estate.property"
76
_description = "Estate Property"
87

9-
def _default_availability_date(self):
10-
today_str = fields.Date.context_today(self)
11-
today_date = fields.Date.to_date(today_str)
12-
future_date = today_date + timedelta(days=30)
13-
return future_date.strftime('%Y-%m-%d')
8+
149

1510
name = fields.Char(required=True)
1611
description = fields.Text()
1712
postcode = fields.Char()
18-
date_availaility = fields.Date(copy=False,default=_default_availability_date)
13+
date_availaility = fields.Date(default=(fields.Date.add(fields.Date.today(), days=90)), copy=False)
14+
1915
expected_price = fields.Float(required=True)
2016
selling_price = fields.Float(readonly = True,copy=False)
2117
bedrooms = fields.Integer(default=2)
@@ -34,6 +30,11 @@ def _default_availability_date(self):
3430
('offer_accepted', 'Offer Accepted'),
3531
('sold', 'Sold'),
3632
('cancelled', 'Cancelled'),],required=True, copy=False, default='new')
33+
property_type = fields.Many2one("estate.property.type", string="Property Type")
34+
salesman = fields.Many2one("res.users", default = lambda self: self.env.user)
35+
buyer = fields.Many2one("res.partner", copy=False)
36+
tag_ids = fields.Many2many("estate.property.tag", string="Tags")
37+
offers_ids = fields.One2many("estate.property.offers", "property_id")
3738

3839

3940

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from odoo import fields, models
2+
3+
4+
class EstatePropertyOffer(models.Model):
5+
_name = "estate.property.offers"
6+
_description = "Estate Property Offer"
7+
8+
price = fields.Float()
9+
status = fields.Selection([("Accepted","accepted"),("refused","Refused")], copy=False)
10+
partner_id = fields.Many2one("res.partner", required=True)
11+
property_id = fields.Many2one("estate.property", required=True)
12+

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 fields, models
2+
3+
4+
class EstatePropertyTag(models.Model):
5+
_name = "estate.property.tag"
6+
_description = "Estate Property Tag"
7+
8+
name = fields.Char(required=True)

estate/models/estate_property_type.py

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

estate/security/ir.model.access.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
22
access_estate_property_user,estate.property user,model_estate_property,estate.estate_group_user,1,0,0,0
33
access_estate_property_admin,estate.property admin,model_estate_property,estate.estate_group_manager,1,1,1,1
4+
access_estate_property_type_admin,estate.property.type admin,model_estate_property_type,estate.estate_group_manager,1,1,1,1
5+
access_estate_property_tag_admin,estate.property.tag admin,model_estate_property_tag,estate.estate_group_manager,1,1,1,1
6+
access_estate_property_offers_admin,estate.property.offers admin,model_estate_property_offers,estate.estate_group_manager,1,1,1,1

estate/views/estate_menus.xml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<odoo>
3-
<menuitem id="estate_menu_root" name="Real Estate">
4-
<menuitem id="estate_first_level_menu" name="Advertisements">
5-
<menuitem id="estate_property_menu_action" action="estate_property_action"/>
6-
</menuitem>
3+
<menuitem id="estate_menu_root" name="Real Estate">
4+
<menuitem id="estate_first_level_menu" name="Advertisements">
5+
<menuitem id="estate_property_menu_action" action="estate_property_action" />
76
</menuitem>
8-
</odoo>
7+
8+
<menuitem id="estate_setting" name="Setting">
9+
<menuitem id="estate_setting_menu_action" action="estate_property_type_action" />
10+
<menuitem id="estate_setting_tag_action" action="estate_property_tag_action" />
11+
</menuitem>
12+
</menuitem>
13+
14+
15+
</odoo>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<record id="estate_property_offers_action" model="ir.actions.act_window">
4+
<field name="name">Property Offers</field>
5+
<field name="res_model">estate.property.offers</field>
6+
<field name="view_mode">list,form</field>
7+
</record>
8+
9+
<record id="estate_property_offers_list_view" model="ir.ui.view">
10+
<field name="name">estate.property.offers.list</field>
11+
<field name="model">estate.property.offers</field>
12+
<field name="arch" type="xml">
13+
<list>
14+
<field name="partner_id"/>
15+
<field name="price"/>
16+
<field name="status"/>
17+
</list>
18+
</field>
19+
</record>
20+
21+
<record id="estate_property_offers_form_view" model="ir.ui.view">
22+
<field name="name">estate.property.offers.form</field>
23+
<field name="model">estate.property.offers</field>
24+
<field name="arch" type="xml">
25+
<form>
26+
<group>
27+
<field name="partner_id"/>
28+
<field name="price"/>
29+
<field name="status"/>
30+
</group>
31+
</form>
32+
</field>
33+
</record>
34+
</odoo>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<record id="estate_property_tag_action" model="ir.actions.act_window">
4+
<field name="name">Property Tag</field>
5+
<field name="res_model">estate.property.tag</field>
6+
<field name="view_mode">list,form</field>
7+
</record>
8+
</odoo>

0 commit comments

Comments
 (0)