Skip to content

Commit 951556d

Browse files
committed
[IMP] cancel to cancel and reimport
1 parent b998ff8 commit 951556d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

spp_area_base/models/area_import.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,30 @@ def _compute_get_total_rows(self):
118118

119119
def cancel_import(self):
120120
"""
121-
The function cancels the import by updating the state of the record to "Cancelled".
121+
Cancel the import and create a new import record to start fresh.
122+
Redirects to the newly created record.
122123
"""
123124
for rec in self:
124125
rec.update({"state": self.CANCELLED})
125126

127+
# Create a new area import record
128+
new_record = self.env["spp.area.import"].create(
129+
{
130+
"name": _("New Area Import"),
131+
"state": self.NEW,
132+
}
133+
)
134+
135+
# Return action to open the new record in form view
136+
return {
137+
"type": "ir.actions.act_window",
138+
"res_model": "spp.area.import",
139+
"res_id": new_record.id,
140+
"view_mode": "form",
141+
"target": "current",
142+
"context": self.env.context,
143+
}
144+
126145
def reset_to_uploaded(self):
127146
"""
128147
The function resets the state of a record to "Uploaded".

spp_area_base/views/area_import_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<button
3434
name="cancel_import"
3535
type="object"
36-
string="Cancel"
36+
string="Cancel and Re-import"
3737
class="btn-danger"
3838
invisible="state not in ('Uploaded', 'Imported', 'Validated')"
3939
/>

0 commit comments

Comments
 (0)