summaryrefslogtreecommitdiff
path: root/addons/snailmail/wizard/snailmail_letter_cancel.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/snailmail/wizard/snailmail_letter_cancel.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/snailmail/wizard/snailmail_letter_cancel.py')
-rw-r--r--addons/snailmail/wizard/snailmail_letter_cancel.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/addons/snailmail/wizard/snailmail_letter_cancel.py b/addons/snailmail/wizard/snailmail_letter_cancel.py
new file mode 100644
index 00000000..59d55325
--- /dev/null
+++ b/addons/snailmail/wizard/snailmail_letter_cancel.py
@@ -0,0 +1,26 @@
+
+from odoo import _, api, fields, models
+
+class SnailmailLetterCancel(models.TransientModel):
+ _name = 'snailmail.letter.cancel'
+ _description = 'Dismiss notification for resend by model'
+
+ model = fields.Char(string='Model')
+ help_message = fields.Char(string='Help message', compute='_compute_help_message')
+
+ @api.depends('model')
+ def _compute_help_message(self):
+ for wizard in self:
+ wizard.help_message = _("Are you sure you want to discard %s snailmail delivery failures? You won't be able to re-send these letters later!") % (wizard._context.get('unread_counter'))
+
+ def cancel_resend_action(self):
+ author_id = self.env.user.id
+ for wizard in self:
+ letters = self.env['snailmail.letter'].search([
+ ('state', 'not in', ['sent', 'canceled', 'pending']),
+ ('user_id', '=', author_id),
+ ('model', '=', wizard.model)
+ ])
+ for letter in letters:
+ letter.cancel()
+ return {'type': 'ir.actions.act_window_close'}