Skip to content

Commit dbd91e6

Browse files
committed
[IMP] estate: added the sprinkles, too much things to write, refer to chapter 11 :)
1 parent a2c715d commit dbd91e6

9 files changed

+98
-21
lines changed

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 = "property data"
10+
_order = "id desc"
1011

1112
name = fields.Char(required=True)
1213
description = fields.Text()

estate/models/estate_property_offer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
class EstatePropertyOffer(models.Model):
99
_name = "estate.property.offer"
1010
_description = "property offer"
11+
_order = "price desc"
1112

1213
price = fields.Float()
1314
status = fields.Selection(
@@ -18,6 +19,7 @@ class EstatePropertyOffer(models.Model):
1819
date_deadline = fields.Date(compute="_compute_date_deadline", inverse="_inverse_date_deadline")
1920
partner_id = fields.Many2one("res.partner", string="partner", required=True)
2021
property_id = fields.Many2one("estate.property", required=True)
22+
property_type_id = fields.Many2one(related="property_id.type_id", store=True)
2123

2224
@api.depends('validity')
2325
def _compute_date_deadline(self):

estate/models/estate_property_tag.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
class EstatePropertyTag(models.Model):
55
_name = "estate.property.tag"
66
_description = "property tags"
7+
_order = "name"
78

89
name = fields.Char(required=True)
10+
color = fields.Integer()
911

1012
_unique_name = models.Constraint(
1113
'unique(name)',
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
from odoo import fields, models
1+
from odoo import api, fields, models
22

33

44
class EstatePropertyType(models.Model):
55
_name = "estate.property.type"
66
_description = "property types"
7+
_order = "name"
78

89
name = fields.Char(required=True)
10+
property_ids = fields.One2many('estate.property', 'type_id', string="property")
11+
sequence = fields.Integer('Sequence', default=1)
12+
offer_ids = fields.One2many('estate.property.offer', 'property_type_id', string="offer")
13+
offer_count = fields.Integer('Number of offers', compute="_compute_number_of_offers")
914

1015
_unique_name = models.Constraint(
1116
'unique(name)',
1217
'A property type must have a unique name.',
1318
)
19+
20+
@api.depends('offer_ids')
21+
def _compute_number_of_offers(self):
22+
for property_type in self:
23+
property_type.offer_count = len(property_type.offer_ids)

estate/views/estate_property_menu_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<menuitem id="estate_property_menu_action" action="estate_property_action"/>
66
</menuitem>
77
<menuitem id="test_first_level_menu2" name="Settings">
8-
<menuitem id="estate_property_menu_action_3" action="estate_property_type_action_2"/>
8+
<menuitem id="estate_property_menu_action_3" action="estate_property_type_action"/>
99
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_action"/>
1010
</menuitem>
1111
</menuitem>

estate/views/estate_property_offer_views.xml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
<?xml version="1.0"?>
22
<odoo>
33
<data>
4+
<record id="estate_property_offer_action" model="ir.actions.act_window">
5+
<field name="name">estate property offer</field>
6+
<field name="res_model">estate.property.offer</field>
7+
<field name="view_mode">list,form</field>
8+
<field name="domain">[('property_type_id', '=', active_id)]</field>
9+
</record>
10+
411
<record id="estate_property_offer_view_list" model="ir.ui.view">
512
<field name="name">estate.property.offer.list</field>
613
<field name="model">estate.property.offer</field>
714
<field name="arch" type="xml">
8-
<list string="Channel">
15+
<list string="Channel" editable="bottom" decoration-success="status in ['Accepted']" decoration-danger="status in ['Refused']">
916
<field name="price"/>
1017
<field name="partner_id"/>
11-
<field name="status"/>
18+
<!-- <field name="status"/> -->
1219
<field name="validity"/>
13-
<button name="action_accept" string="Accept" type="object" icon="fa-check"/>
14-
<button name="action_refuse" string="Refuse" type="object" icon="fa-ban"/>
20+
<button name="action_accept" string="Accept" type="object" icon="fa-check" invisible="status"/>
21+
<button name="action_refuse" string="Refuse" type="object" icon="fa-ban" invisible="status"/>
1522
<field name="date_deadline"/>
23+
<field name="property_type_id"/>
1624
</list>
1725
</field>
1826
</record>

estate/views/estate_property_tag_views.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,15 @@
66
<field name="res_model">estate.property.tag</field>
77
<field name="view_mode">list,form</field>
88
</record>
9+
10+
<record id="estate_property_tag_view_list" model="ir.ui.view">
11+
<field name="name">estate.property.tag.list</field>
12+
<field name="model">estate.property.tag</field>
13+
<field name="arch" type="xml">
14+
<list string="tags" editable="bottom">
15+
<field name="name"/>
16+
</list>
17+
</field>
18+
</record>
919
</data>
1020
</odoo>
Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,53 @@
11
<?xml version="1.0"?>
22
<odoo>
33
<data>
4-
<record id="estate_property_type_action_2" model="ir.actions.act_window">
4+
<record id="estate_property_type_action" model="ir.actions.act_window">
55
<field name="name">estate property type</field>
66
<field name="res_model">estate.property.type</field>
77
<field name="view_mode">list,form</field>
88
</record>
9+
10+
<record id="estate_property_type_view_list" model="ir.ui.view">
11+
<field name="name">estate.property.type.list</field>
12+
<field name="model">estate.property.type</field>
13+
<field name="arch" type="xml">
14+
<list string="types">
15+
<field name="sequence" widget="handle"/>
16+
<field name="name"/>
17+
<field name="offer_count"/>
18+
</list>
19+
</field>
20+
</record>
21+
22+
<record id="estate_property_type_view_form" model="ir.ui.view">
23+
<field name="name">estate.property.type.form</field>
24+
<field name="model">estate.property.type</field>
25+
<field name="arch" type="xml">
26+
<form string="Test">
27+
<header>
28+
<button class="oe_stat_button" name="estate.estate_property_offer_action" string="Offers" type="action"/>
29+
</header>
30+
<sheet>
31+
<group>
32+
<field name="name"/>
33+
</group>
34+
<notebook>
35+
<page string="Properties">
36+
<group>
37+
<field name="property_ids">
38+
<list>
39+
<field name="name"/>
40+
<field name="expected_price"/>
41+
<field name="state"/>
42+
</list>
43+
</field>
44+
</group>
45+
</page>
46+
</notebook>
47+
</sheet>
48+
</form>
49+
</field>
50+
</record>
51+
952
</data>
1053
</odoo>

estate/views/estate_property_views.xml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<field name="name">estate property</field>
66
<field name="res_model">estate.property</field>
77
<field name="view_mode">list,form</field>
8+
<field name="context">{'search_default_state': True}</field>
89
</record>
910

1011
<record id="estate_property_new_view_search" model="ir.ui.view">
@@ -16,7 +17,7 @@
1617
<field name="postcode"/>
1718
<field name="expected_price"/>
1819
<field name="bedrooms"/>
19-
<field name="living_area"/>
20+
<field name="living_area" filter_domain="[('living_area', '>=', self)]"/>
2021
<field name="facades"/>
2122
<field name="type_id"/>
2223
<separator/>
@@ -26,18 +27,18 @@
2627
</field>
2728
</record>
2829

29-
<record id="estate_property_view_tree" model="ir.ui.view">
30+
<record id="estate_property_view_list" model="ir.ui.view">
3031
<field name="name">estate.property.list</field>
3132
<field name="model">estate.property</field>
3233
<field name="arch" type="xml">
33-
<list string="Channel">
34+
<list string="Channel" decoration-success="state in ['Offer Received', 'Offer Accepted']" decoration-bf="state in ['Offer Accepted']" decoration-muted="state in ['Sold']">
3435
<field name="name"/>
3536
<field name="postcode"/>
3637
<field name="bedrooms"/>
3738
<field name="living_area"/>
3839
<field name="expected_price"/>
3940
<field name="selling_price"/>
40-
<field name="date_availability"/>
41+
<field name="date_availability" optional="false"/>
4142
<field name="type_id"/>
4243
<field name="tag_ids"/>
4344
</list>
@@ -49,10 +50,11 @@
4950
<field name="model">estate.property</field>
5051
<field name="arch" type="xml">
5152
<form string="Test">
52-
<header>
53-
<button name="action_sold" type="object" string="Sold"/>
54-
<button name="action_cancel" type="object" string="Cancel"/>
55-
</header>
53+
<header>
54+
<button name="action_sold" type="object" string="Sold" invisible="state in ['Sold', 'Cancelled']"/>
55+
<button name="action_cancel" type="object" string="Cancel" invisible="state in ['Sold', 'Cancelled']"/>
56+
<field name="state" widget="statusbar" statusbar_visible="New, Offer Received, Offer Accepted, Sold" options="{'clickable': 1}"/>
57+
</header>
5658
<sheet>
5759
<h1>
5860
<field name="name"/>
@@ -78,16 +80,15 @@
7880
<field name="facades"/>
7981
<field name="garage"/>
8082
<field name="garden"/>
81-
<field name="garden_area"/>
82-
<field name="garden_orientation"/>
83-
<field name="state"/>
84-
<field name="type_id"/>
85-
<field name="tag_ids" widget="many2many_tags"/>
83+
<field name="garden_area" invisible="not garden"/>
84+
<field name="garden_orientation" invisible="not garden"/>
85+
<field name="type_id" options="{'no_create': true}"/>
86+
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}" />
8687
<field name="total_area"/>
8788
</group>
8889
</page>
8990
<page string="Offers">
90-
<field name="offer_ids"/>
91+
<field name="offer_ids" readonly="state in ['Sold', 'Cancelled', 'Offer Accepted']"/>
9192
</page>
9293
<page string="Other info">
9394
<group>

0 commit comments

Comments
 (0)