Skip to content

Commit 489b815

Browse files
committed
[IMP] estate: Add a server action for better UX
Problem --------- Users may want to cancel several houses and flats at once, currently this is not possible; they have to do it one by one. Objective --------- Add a way to cancel several estates in one go. Solution --------- Add a server action in the demo data so that it is available for new users. Old users can create the same server action on their database. task-123456
1 parent d55d464 commit 489b815

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

estate/__manifest__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@
99
'views/estate_property_views.xml',
1010
'views/estate_menus.xml',
1111
],
12-
'license': 'LGPL-3',
12+
'license': "LGPL-3",
13+
# data files containing optionally loaded demonstration data
14+
'demo': [
15+
"demo/demo.xml",
16+
],
1317
}

estate/demo/demo.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<data>
4+
<record id="model_estate_property_action_cancel" model="ir.actions.server">
5+
<field name="name">Mass cancel</field>
6+
<field name="model_id" ref="estate.model_estate_property"/>
7+
<field name="binding_model_id" ref="estate.model_estate_property"/>
8+
<field name="binding_view_types">list</field>
9+
<field name="state">code</field>
10+
<field name="code">action = records.action_cancel()</field>
11+
</record>
12+
</data>
13+
</odoo>

estate/models/estate_property.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ class EstateProperty(models.Model):
2727
string='State',
2828
selection=[('new', 'New'), ('offer_received', 'Offer Received'), ('offer_accepted', 'Offer Accepted'), ('sold', 'Sold'), ('cancelled', "Cancelled")]
2929
)
30+
31+
def action_cancel(self):
32+
state = self.state
33+
if state != 'cancelled':
34+
self.state = 'cancelled'

0 commit comments

Comments
 (0)