summaryrefslogtreecommitdiff
path: root/addons/coupon/models/mail_compose_message.py
diff options
context:
space:
mode:
authorJoseph Caburnay <jcb@odoo.com>2019-10-10 11:45:35 +0000
committerPierre Masereel <pim@odoo.com>2020-05-08 14:27:29 +0000
commitafad149eb8a542b39e9508a458d7aeb43aeb60ed (patch)
tree80b405cfb2d6050e848120a071ce2ed22c712932 /addons/coupon/models/mail_compose_message.py
parentef05ca2812c3407dddd20921604661726c859d74 (diff)
[REF] *_sale_coupon: create coupon module
This refactoring extracts parts of `sale_coupon` module to create a more generic module called `coupon`. This new module can be extended in different sales modules to implement functionalities specific to modules that extend it.
Diffstat (limited to 'addons/coupon/models/mail_compose_message.py')
-rw-r--r--addons/coupon/models/mail_compose_message.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/addons/coupon/models/mail_compose_message.py b/addons/coupon/models/mail_compose_message.py
new file mode 100644
index 00000000000..a819777a75f
--- /dev/null
+++ b/addons/coupon/models/mail_compose_message.py
@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import models
+
+
+class MailComposeMessage(models.TransientModel):
+ _inherit = 'mail.compose.message'
+
+ def send_mail(self, **kwargs):
+ for wizard in self:
+ if self._context.get('mark_coupon_as_sent') and wizard.model == 'coupon.coupon' and wizard.partner_ids:
+ # Mark coupon as sent in sudo, as helpdesk users don't have the right to write on coupons
+ self.env[wizard.model].sudo().browse(wizard.res_id).state = 'sent'
+ return super().send_mail(**kwargs)