Skip to content

Commit a21c051

Browse files
aboo-odooproose
authored andcommitted
[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 768d70e commit a21c051

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

estate/__manifest__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
],
1212
'installable': True,
1313
'application': True,
14-
'auto_install': False
14+
'auto_install': False,
15+
'demo': [
16+
"demo/demo.xml",
17+
],
1518
}

estate/demo/demo.xml

+13
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

+5
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ class EstateProperty(models.Model):
77

88
name = fields.Char("Estate Name", required=True, translate=True)
99
price = fields.Integer("Estate Price", default=0)
10+
11+
def action_cancel(self):
12+
state = self.state
13+
if state != 'cancelled':
14+
self.state = 'cancelled'

0 commit comments

Comments
 (0)