Skip to content

Commit 6567d13

Browse files
committed
[ADD] estate: Added the sprinkles
1 parent e8020f0 commit 6567d13

9 files changed

+79
-18
lines changed

.idea/workspace.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

estate/models/estate_property.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
class EstateProperty(models.Model):
88
_name = 'estate.property'
99
_description = 'Create real estate properties and keep track of status'
10+
_order = 'id desc'
1011

1112
name = fields.Char(string="Name", required=True)
1213
description = fields.Text(string="Description")

estate/models/estate_property_offer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
class EstatePropertyOffer(models.Model):
88
_name = 'estate.property.offer'
99
_description = 'Model representing the offers from partners to a specific property'
10+
_order = 'price desc'
1011

1112
price = fields.Float(string="Price")
1213
status = fields.Selection(
@@ -22,6 +23,7 @@ class EstatePropertyOffer(models.Model):
2223
validity = fields.Integer(string="Validity", default=7)
2324
date_deadline = fields.Date(compute='_compute_date_deadline', inverse='_inverse_date_deadline', string="Date Deadline")
2425
create_date = fields.Date(default=lambda self: fields.Datetime.now())
26+
property_type_id = fields.Many2one(related="property_id.property_type_id")
2527

2628
_sql_constraints = [
2729
('check_offer_price', 'CHECK(price > 0)',

estate/models/estate_property_tag.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from odoo import fields, models
22

33

4-
class EstatePropertyType(models.Model):
4+
class EstatePropertyTag(models.Model):
55
_name = 'estate.property.tag'
66
_description = 'Model representing the tags of each estate property'
7+
_order = 'name'
78

89
name = fields.Char(string="Name", required=True)
10+
color = fields.Integer(string="Color")
911

1012
_sql_constraints = [
1113
('check_unique_name', 'UNIQUE(name)', "This tag name already exists."),

estate/models/estate_property_type.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
from odoo import fields, models
1+
from odoo import api, fields, models
2+
from odoo.fields import One2many
23

34

45
class EstatePropertyType(models.Model):
56
_name = 'estate.property.types'
67
_description = 'Model representing the different types of properties'
8+
_order = 'name'
79

810
name = fields.Char(string="Name", required=True)
11+
property_ids = fields.One2many('estate.property', 'property_type_id')
12+
sequence = fields.Integer(string='Sequence')
13+
offer_ids = One2many('estate.property.offer', 'property_type_id')
14+
offer_count = fields.Integer(compute="_compute_offer_count", string="Offer Count")
915

1016
_sql_constraints = [
1117
('check_unique_name', 'UNIQUE(name)', "This property type already exists."),
1218
]
19+
20+
@api.depends('offer_ids')
21+
def _compute_offer_count(self):
22+
for record in self:
23+
record.offer_count = len(record.offer_ids)

estate/views/estate_property_offer_views.xml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
<?xml version="1.0"?>
22
<odoo>
3+
<record id="estate_property_offer_action" model="ir.actions.act_window">
4+
<field name="name">Property Type Offers</field>
5+
<field name="res_model">estate.property.offer</field>
6+
<field name="view_mode">list,form</field>
7+
<field name="domain">[('property_type_id', '=', active_id)]</field>
8+
</record>
9+
310
<record id="property_offer_view_list" model="ir.ui.view">
411
<field name="name">List View</field>
512
<field name="model">estate.property.offer</field>
613
<field name="arch" type="xml">
7-
<list string="Properties">
14+
<list string="Properties" editable="bottom"
15+
decoration-success="status in ['accepted']"
16+
decoration-danger="status in ['refused']"
17+
>
818
<field name="price"/>
919
<field name="partner_id"/>
1020
<field name="validity"/>
1121
<field name="date_deadline"/>
12-
<button name="action_confirm" string="Confirm" type="object" icon="fa-check"/>
13-
<button name="action_refuse" string="Refuse" type="object" icon="fa-times"/>
14-
<field name="status"/>
22+
<button name="action_confirm" string="Confirm" type="object" icon="fa-check" invisible="status in ['accepted', 'refused']"/>
23+
<button name="action_refuse" string="Refuse" type="object" icon="fa-times" invisible="status in ['accepted', 'refused']"/>
1524
</list>
1625
</field>
1726
</record>

estate/views/estate_property_tag_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<field name="name">List View</field>
1111
<field name="model">estate.property.tag</field>
1212
<field name="arch" type="xml">
13-
<list string="Properties">
13+
<list string="Properties" editable="bottom">
1414
<field name="name"/>
1515
</list>
1616
</field>

estate/views/estate_property_types_views.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<field name="model">estate.property.types</field>
1212
<field name="arch" type="xml">
1313
<list string="Properties">
14+
<field name="sequence" widget="handle"/>
1415
<field name="name"/>
1516
</list>
1617
</field>
@@ -22,9 +23,30 @@
2223
<field name="arch" type="xml">
2324
<form string="View Form">
2425
<sheet>
26+
<div name="button_box" position="inside">
27+
<button type="action"
28+
icon="fa-money"
29+
string="Offers"
30+
name="%(estate.estate_property_offer_action)d">
31+
<field name="offer_count" string="Offers" widget="statinfo"/>
32+
</button>
33+
</div>
2534
<group>
2635
<h1><field name="name"/></h1>
2736
</group>
37+
<notebook>
38+
<page string="Properties">
39+
<group>
40+
<field name="property_ids">
41+
<list>
42+
<field name="name"/>
43+
<field name="expected_price"/>
44+
<field name="state"/>
45+
</list>
46+
</field>
47+
</group>
48+
</page>
49+
</notebook>
2850
</sheet>
2951
</form>
3052
</field>

estate/views/estate_property_views.xml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
<field name="name">Properties</field>
55
<field name="res_model">estate.property</field>
66
<field name="view_mode">list,form</field>
7+
<field name="context">{'search_default_state': True}</field>
78
</record>
89

910
<record id="estate_property_view_list" model="ir.ui.view">
1011
<field name="name">List View</field>
1112
<field name="model">estate.property</field>
1213
<field name="arch" type="xml">
13-
<list string="Properties">
14+
<list string="Properties"
15+
decoration-success="state in ['offer_received', 'offer_accepted']"
16+
decoration-bf="state in ['offer_accepted']"
17+
decoration-muted="state in ['sold']"
18+
>
1419
<field name="name"/>
1520
<field name="tag_ids" widget="many2many_tags"/>
1621
<field name="property_type_id"/>
@@ -19,7 +24,7 @@
1924
<field name="living_area"/>
2025
<field name="expected_price"/>
2126
<field name="selling_price"/>
22-
<field name="date_availability"/>
27+
<field name="date_availability" optional="true"/>
2328
</list>
2429
</field>
2530
</record>
@@ -35,7 +40,9 @@
3540
<field name="postcode"/>
3641
<field name="expected_price"/>
3742
<field name="bedrooms"/>
38-
<field name="living_area"/>
43+
<field name="living_area"
44+
filter_domain="[('living_area', '>=', self)]"
45+
/>
3946
<field name="facades"/>
4047
<filter string="Available"
4148
name="state"
@@ -58,19 +65,19 @@
5865
<field name="arch" type="xml">
5966
<form string="View Form">
6067
<header>
61-
<button name="action_sold" type="object" string="SOLD"/>
62-
<button name="action_cancel" type="object" string="CANCEL"/>
68+
<button name="action_sold" type="object" string="SOLD" invisible="state in ['sold', 'cancelled']"/>
69+
<button name="action_cancel" type="object" string="CANCEL" invisible="state in ['sold', 'cancelled']"/>
70+
<field name="state" readonly="state in ['sold', 'cancelled']" widget="statusbar"/>
6371
</header>
6472
<sheet>
6573
<group>
6674
<h1><field name="name"/></h1>
6775
</group>
6876
<group>
69-
<field name="tag_ids" widget="many2many_tags"/>
77+
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
7078
</group>
7179
<group>
72-
<field name="state" readonly="state in ['sold', 'cancelled']"/>
73-
<field name="property_type_id"/>
80+
<field name="property_type_id" options="{'no_create': true}"/>
7481
<field name="postcode"/>
7582
<field name="expected_price"/>
7683
<field name="best_price"/>
@@ -86,14 +93,14 @@
8693
<field name="facades"/>
8794
<field name="garage"/>
8895
<field name="garden"/>
89-
<field name="garden_area"/>
90-
<field name="garden_orientation"/>
96+
<field name="garden_area" invisible="not garden"/>
97+
<field name="garden_orientation" invisible="not garden"/>
9198
<field name="total_area"/>
9299
</group>
93100
</page>
94101
<page string="Offers">
95102
<group>
96-
<field name="offer_ids"/>
103+
<field name="offer_ids" readonly="state in ['offer_accepted', 'sold', 'cancelled']"/>
97104
</group>
98105
</page>
99106
<page string="Other Info">

0 commit comments

Comments
 (0)