Skip to content

Commit 4d02f7e

Browse files
committed
[IMP] estate: Added wizard.
Task related to wizards are completed.
1 parent 63f21b7 commit 4d02f7e

8 files changed

+116
-37
lines changed

estate/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from . import models
1+
from . import models
2+
from . import wizard

estate/__manifest__.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"data": [
1212
"security/security.xml",
1313
"security/ir.model.access.csv",
14+
"wizard/estate_property_offer_wizard_views.xml",
1415
"views/estate_property_views.xml",
1516
"views/estate_property_offer_views.xml",
1617
"views/estate_property_type_views.xml",

estate/models/estate_property.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,16 @@ def _check_state_on_delete(self):
152152
raise UserError(
153153
"You cannot delete a property unless it is in 'New' or 'Cancelled' state."
154154
)
155-
155+
156+
# def action_helper_message(self):
157+
# # Logic to determine when to show the helper
158+
# if not self.search([]):
159+
# return {
160+
# 'type': 'ir.actions.client',
161+
# 'tag': 'display_notification',
162+
# 'params': {
163+
# 'title': 'No Properties Found',
164+
# 'message': 'Click the button to create your first property.',
165+
# 'type': 'warning',
166+
# }
167+
# }

estate/security/ir.model.access.csv

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ access_real_estate_agent,access_real_estate_agent,model_estate_property,estate_g
88
access_type_read_only,access_type_read_only,model_estate_property_type,estate_group_user,1,0,0,0
99
access_tag_read_only,access_tag_read_only,model_estate_property_tag,estate_group_user,1,0,0,0
1010
access_property_tag_manager,Property Tag - Manager,model_estate_property_tag,estate_group_manager,1,1,1,1
11-
access_property_type_manager,Property Type - Manager,model_estate_property_type,estate_group_manager,1,1,1,1
11+
access_property_type_manager,Property Type - Manager,model_estate_property_type,estate_group_manager,1,1,1,1
12+
access_estate_property_offer_wizard,model_estate_property,model_estate_property_offer_wizard,base.group_user,1,1,1,1

estate/views/estate_property_views.xml

+31-34
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,20 @@
2020
</b>
2121
<div>Expected Price: <field name="expected_price" />
2222
</div>
23-
<div t-if="record.state.raw_value == 'offer_received'"> Best Price: <field
24-
name="best_price" />
23+
<div t-if="record.state.raw_value == 'offer_received'"> Best Price: <field name="best_price" />
2524
</div>
26-
<div t-if="record.state.raw_value == 'offer_accepted'"> Selling Price: <field
27-
name="selling_price" />
25+
<div t-if="record.state.raw_value == 'offer_accepted'"> Selling Price: <field name="selling_price" />
2826
</div>
2927
<field name="tag_ids" widget="many2many_tags" />
3028
</div>
3129

3230
</t>
31+
<!-- <div class="o_kanban_view_content">
32+
<p>No properties available. Start by creating one!</p>
33+
<button type="action" class="btn btn-primary" name="%(estate_property_action)d">
34+
Create Property
35+
</button>
36+
</div> -->
3337
</templates>
3438
</kanban>
3539
</field>
@@ -39,9 +43,11 @@
3943
<field name="name">estate.property.list</field>
4044
<field name="model">estate.property</field>
4145
<field name="arch" type="xml">
42-
<list string="Properties" decoration-success="offer_received"
43-
decoration-info="offer_accepted"
44-
decoration-muted="state == 'sold'">
46+
<list string="Properties" decoration-success="offer_received" decoration-info="offer_accepted" decoration-muted="state == 'sold'">
47+
48+
<header>
49+
<button name="%(action_add_offer_wizard)d" type="action" string="Add Offer" />
50+
</header>
4551
<field name="name" string="Title"/>
4652
<field name="state"/>
4753
<field name="property_type_id" options="{'no_create': True, 'no_edit': True}" required="1" />
@@ -55,24 +61,22 @@
5561
</list>
5662
</field>
5763
</record>
58-
<record id="estate_property_view_form" model="ir.ui.view">
64+
<record id="estate_property_view_form" model="ir.ui.view">
5965
<field name="name">estate.property.form</field>
6066
<field name="model">estate.property</field>
6167
<field name="arch" type="xml">
6268
<form string="Property">
6369
<header>
64-
<button name="action_cancel" type="object" string="Cancel"
65-
class="btn btn-secondary" invisible="state != 'sold'"/>
66-
<button name="action_sold" type="object" string="Sold"
67-
class="btn btn-primary" invisible="state in('sold', 'cancelled')"/>
68-
<field name="state" widget="statusbar" options="{'clickable': False}" />
69-
</header>
70+
<button name="action_cancel" type="object" string="Cancel" class="btn btn-secondary" invisible="state != 'sold'"/>
71+
<button name="action_sold" type="object" string="Sold" class="btn btn-primary" invisible="state in('sold', 'cancelled')"/>
72+
<field name="state" widget="statusbar" options="{'clickable': False}" />
73+
</header>
7074
<sheet>
71-
<h1>
75+
<h1>
7276
<field name="name" />
73-
<field name="state" invisible="1"/>
77+
<field name="state" invisible="1"/>
7478
</h1>
75-
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}" />
79+
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}" />
7680
<group>
7781
<group>
7882
<field name="property_type_id" options="{'no_create': True, 'no_edit': True}" required="1" />
@@ -82,7 +86,7 @@
8286
<group>
8387
<field name="postcode"/>
8488
<field name="date_availability" string="Available From"/>
85-
<field name="best_offers" string="Best Offers"/>
89+
<field name="best_offers" string="Best Offers"/>
8690
</group>
8791
</group>
8892
<notebook>
@@ -93,10 +97,10 @@
9397
<field name="living_area" string="Living Area(sqm)"/>
9498
<field name="facades" string="Facades"/>
9599
<field name="garage" string="Garage"/>
96-
<field name="garden" string="Garden" widget="boolean_toggle"/>
97-
<field name="garden_area" string="Garden Area(sqm)" invisible="not garden"/>
100+
<field name="garden" string="Garden" widget="boolean_toggle"/>
101+
<field name="garden_area" string="Garden Area(sqm)" invisible="not garden"/>
98102
<field name="garden_orientation" string="Garden Orientation" invisible="not garden"/>
99-
<field name="total_area" string="Total Area(sqm)"/>
103+
<field name="total_area" string="Total Area(sqm)"/>
100104
</group>
101105
</page>
102106
<page string="Other info">
@@ -112,39 +116,32 @@
112116
<field name="partner_id"></field>
113117
<field name="validity"></field>
114118
<field name="date_deadline"></field>
115-
<button name="action_offer_accepted" type="object"
116-
icon="fa-check" string="Accept Offer"
117-
invisible="state != 'new'" />
118-
<button name="action_offer_refused" type="object"
119-
icon="fa-times" string="Refuse Offer"
120-
invisible="state != 'new'" />
119+
<button name="action_offer_accepted" type="object" icon="fa-check" string="Accept Offer" invisible="state != 'new'" />
120+
<button name="action_offer_refused" type="object" icon="fa-times" string="Refuse Offer" invisible="state != 'new'" />
121121
<field name="status"></field>
122122
</list>
123123
</field>
124124
</page>
125-
125+
126126
<page>
127127
<field name="description"/>
128128
</page>
129129
</notebook>
130130
</sheet>
131131
</form>
132132
</field>
133-
</record>
133+
</record>
134134
<record id="estate_property_view_search" model="ir.ui.view">
135135
<field name="name">estate.property.search</field>
136136
<field name="model">estate.property</field>
137137
<field name="arch" type="xml">
138138
<search string="Search Properties">
139139
<field name="name"/>
140140
<field name="postcode"/>
141-
<filter name="available" string="Available" domain="[('state', '=', 'new')]" context="{'default_selected': True}"/>
141+
<filter name="available" string="Available" domain="[('state', '=', 'new')]" context="{'default_selected': True}"/>
142142
<group expand="1" string="Group By">
143143
<filter name="group_by_postcode" string="Postcode" context="{'group_by': 'postcode'}"/>
144-
<filter name="filter_living_area"
145-
string="Living Area"
146-
domain="[('living_area', '>=', self)]"
147-
context="{'group_by': 'living_area'}"/>
144+
<filter name="filter_living_area" string="Living Area" domain="[('living_area', '>=', self)]" context="{'group_by': 'living_area'}"/>
148145
</group>
149146
</search>
150147
</field>

estate/wizard/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import estate_property_offer_wizard
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from odoo import models, fields
2+
3+
4+
class EstatePropertyOfferWizard(models.TransientModel):
5+
_name = "estate.property.offer.wizard"
6+
_description = "wizard to add multiple offers"
7+
8+
price = fields.Float(required=True)
9+
partner_id = fields.Many2one("res.partner")
10+
validity = fields.Integer(default=7)
11+
12+
def action_add_offers(self):
13+
property_ids = self.env.context.get("active_ids", [])
14+
15+
offer_vals_list = []
16+
for property_id in property_ids:
17+
offer_vals = {
18+
"property_id": property_id,
19+
"price": self.price,
20+
"partner_id": self.partner_id.id,
21+
"validity": self.validity,
22+
}
23+
offer_vals_list.append(offer_vals)
24+
25+
26+
if len(offer_vals_list) > 0:
27+
self.env["estate.property.offer"].create(offer_vals_list)
28+
29+
return {"type": "ir.actions.act_window_close"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<data>
4+
<record id="view_add_offer_wizard" model="ir.ui.view">
5+
<field name="name">add.offer.wizard.form</field>
6+
<field name="model">estate.property.offer.wizard</field>
7+
<field name="arch" type="xml">
8+
<form string="Add Offer">
9+
<sheet>
10+
<group>
11+
<field name="price" />
12+
<field name="partner_id" />
13+
<field name="validity" />
14+
</group>
15+
</sheet>
16+
<footer>
17+
<button string="Confirm" name="action_add_offers" type="object"
18+
class="btn-primary" default_focus="1" />
19+
<button string="Cancel" class="btn-secondary" special="cancel" />
20+
</footer>
21+
</form>
22+
</field>
23+
</record>
24+
25+
26+
<record id="action_add_offer_wizard" model="ir.actions.act_window">
27+
<field name="name">Add Offer</field>
28+
<field name="res_model">estate.property.offer.wizard</field>
29+
<field name="view_mode">form</field>
30+
<field name="view_id" ref="view_add_offer_wizard" />
31+
<field name="context">{'default_property_ids': active_ids}</field>
32+
<field name="target">new</field>
33+
</record>
34+
</data>
35+
</odoo>
36+
37+

0 commit comments

Comments
 (0)