Skip to content

Commit 9274f4d

Browse files
committed
[ADD] estate: added kanban view
1 parent 6e2c809 commit 9274f4d

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

estate/models/estate_property_offer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def reject_offer(self):
5252

5353
@api.model
5454
def create(self, vals_list):
55-
if vals_list[0].get('price') < min(self.env['estate.property'].browse(vals_list[0].get('property_id')).offer_ids.mapped('price')):
55+
if len(self.env['estate.property'].browse(vals_list[0].get('property_id')).offer_ids.mapped('price')) and vals_list[0].get('price') < min(self.env['estate.property'].browse(vals_list[0].get('property_id')).offer_ids.mapped('price')):
5656
raise(UserError("Can not have an offer that is less the minimum offer"))
5757
self.env['estate.property'].browse(vals_list[0]['property_id']).state = 'offer received'
5858
return super().create(vals_list)

estate/views/estate_property_views.xml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<record id="estate_property_model_action" model="ir.actions.act_window">
44
<field name="name">Properties</field>
55
<field name="res_model">estate.property</field>
6-
<field name="view_mode">list,form</field>
6+
<field name="view_mode">list,form,kanban</field>
77
<field name="context">{'search_default_available': True, 'search_default_current': True}</field>
88
</record>
99

@@ -89,7 +89,7 @@
8989
</page>
9090
<page string="Offers">
9191
<group>
92-
<field name="offer_ids" readonly="state in ('sold', 'offer received', 'cancelled')"/>
92+
<field name="offer_ids" readonly="state in ('sold', 'offer accepted', 'cancelled')"/>
9393
</group>
9494
</page>
9595
<page name="notes" string="Notes">
@@ -107,5 +107,34 @@
107107
</field>
108108
</record>
109109

110+
<record id="estate_property_view_kanban" model="ir.ui.view">
111+
<field name="name">estate.properties.kanban.view</field>
112+
<field name="model">estate.property</field>
113+
<field name="arch" type="xml">
114+
<kanban default_group_by="property_type_id" records_draggable="0">
115+
<field name="state"/>
116+
<templates>
117+
<t t-name="card">
118+
<div>
119+
<field name="name"/>
120+
<div>Expected Price:
121+
<field name="expected_price"/>
122+
</div>
123+
<div t-if="record.state.raw_value == 'offer received'">
124+
Best Price:
125+
<field name="best_offer"/>
126+
</div>
127+
<div t-if="record.state.raw_value == 'offer accepted'">
128+
Selling Price:
129+
<field name="selling_price"/>
130+
</div>
131+
<field name="tag_ids" string="Property Tags" widget="many2many_tags"
132+
options="{'color_field': 'color'}"/>
133+
</div>
134+
</t>
135+
</templates>
136+
</kanban>
137+
</field>
138+
</record>
110139

111140
</odoo>

0 commit comments

Comments
 (0)