Skip to content

Commit 577573a

Browse files
committed
[IMP] estate : adding new foreign fields for tags, types and offers to property model
1 parent d749764 commit 577573a

12 files changed

+140
-9
lines changed

estate/__manifest__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
'depends': ['base'],
99
'data': [
1010
'security/ir.model.access.csv',
11+
'views/estate_property_offer_view.xml',
1112
'views/estate_property_view.xml',
12-
'views/estate_menus.xml'
13+
'views/estate_property_type_view.xml',
14+
'views/estate_property_tag_view.xml',
15+
'views/estate_menus.xml',
1316
],
1417
'application': True,
1518
'author': "Odoo",

estate/models/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
from . import estate
1+
from . import (
2+
estate_property,
3+
estate_property_offer,
4+
estate_property_tag,
5+
estate_property_type,
6+
)
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ class EstateProperty(models.Model):
2323
garden_area = fields.Integer()
2424
garden_orientation = fields.Selection(
2525
string="Orientation",
26-
selection=[
27-
("north", "N"),
28-
("south", "S"),
29-
("east", "E"),
30-
("west", "W"),
31-
],
26+
selection=[("north", "N"), ("south", "S"), ("east", "E"), ("west", "W")],
3227
help="Orientation of the garden",
3328
)
3429
last_seen = fields.Datetime("Last Seen", default=fields.Datetime.now)
@@ -44,3 +39,22 @@ class EstateProperty(models.Model):
4439
],
4540
default="new",
4641
)
42+
43+
property_type_id = fields.Many2one(
44+
'estate.property.type', string='Property Type', ondelete='restrict'
45+
)
46+
47+
salesperson_id = fields.Many2one(
48+
'res.partner',
49+
string='Salesman',
50+
ondelete='restrict',
51+
default=lambda self: self.env.user.partner_id,
52+
)
53+
54+
buyer_id = fields.Many2one(
55+
'res.users', string='Buyer', ondelete='restrict', copy=False
56+
)
57+
58+
property_tags_ids = fields.Many2many("estate.property.tag", string="Tags")
59+
60+
offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers")
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from odoo import fields, models
2+
3+
4+
class EstatePropertyOffer(models.Model):
5+
_name = "estate.property.offer"
6+
_description = "Estate property offer"
7+
8+
price = fields.Float("Expected Price")
9+
status = fields.Selection(
10+
string="Status", selection=[("yes", "Accepted"), ("no", "Refused")], copy=False
11+
)
12+
13+
partner_id = fields.Many2one(
14+
'res.partner',
15+
string='Salesman',
16+
ondelete='restrict',
17+
default=lambda self: self.env.user.partner_id,
18+
required=True,
19+
)
20+
21+
property_id = fields.Many2one(
22+
'estate.property', string='Property', ondelete='restrict', required=True
23+
)
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('Property Tag', 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 EstatePropertyType(models.Model):
5+
_name = "estate.property.type"
6+
_description = "Estate property type"
7+
8+
name = fields.Char('Property Type', required=True)
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,access_estate_property,model_estate_property,base.group_system,1,1,1,1
3+
access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_system,1,1,1,1
4+
access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_system,1,1,1,1
5+
access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_system,1,1,1,1
36
view_estate_property,view_estate_property,model_estate_property,base.group_user,1,0,0,0

estate/views/estate_menus.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
<menuitem id="advertisement_menu" name="Advertisment">
55
<menuitem id="property_menu_action" action="estate_property_action"/>
66
</menuitem>
7+
<menuitem id="settings_menu" name="Settings">
8+
<menuitem id="property_types_menu_action" action="estate_property_types_action"/>
9+
<menuitem id="property_tags_menu_action" action="estate_property_tags_action"/>
10+
</menuitem>
711
</menuitem>
812
</odoo>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
4+
<record id="estate_property_offer_view_form" model="ir.ui.view">
5+
<field name="name">estate.property.offer.form</field>
6+
<field name="model">estate.property.offer</field>
7+
<field name="arch" type="xml">
8+
<form string="Estate Property Offer Form">
9+
<sheet>
10+
<div>
11+
<group>
12+
<field name="price"/>
13+
<field name="partner_id"/>
14+
<field name="status"/>
15+
</group>
16+
</div>
17+
</sheet>
18+
</form>
19+
</field>
20+
</record>
21+
22+
<record id="estate_property_offer_view_tree" model="ir.ui.view">
23+
<field name="name">estate.property.offer.list</field>
24+
<field name="model">estate.property.offer</field>
25+
<field name="arch" type="xml">
26+
<list string="Channel">
27+
<field name="price"/>
28+
<field name="partner_id"/>
29+
<field name="status"/>
30+
</list>
31+
</field>
32+
</record>
33+
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"?>
2+
<odoo>
3+
<record id="estate_property_tags_action" model="ir.actions.act_window">
4+
<field name="name">Property Tags</field>
5+
<field name="res_model">estate.property.tag</field>
6+
<field name="view_mode">list</field>
7+
</record>
8+
</odoo>

0 commit comments

Comments
 (0)