From 387a77ee32cbe312385ba4ddd3cd80789131a070 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 19 Dec 2016 14:40:21 +0100 Subject: [PATCH] [FIX] purchase: remove useless and broken override There was several issues with this method: - the workflow is incorrectly called (`purchase.signal_workflow(...)` instead) - the workflow no longer exists (`purchase.state = 'sent'` instead) - the code is only triggered when sending an actual mail and not a notification - the code is never executed as the change is already changed The last point is due to the override of `send_mail` in mail.compose.message. The state is changed before `_postprocess_sent_message` is called (if called at all). Similar change of state is already done for sale.order. This commit replaces and closes #14760 --- addons/purchase/models/__init__.py | 1 - addons/purchase/models/mail_mail.py | 18 ------------------ 2 files changed, 19 deletions(-) delete mode 100644 addons/purchase/models/mail_mail.py diff --git a/addons/purchase/models/__init__.py b/addons/purchase/models/__init__.py index e90a45dff29..dead81bb8fb 100644 --- a/addons/purchase/models/__init__.py +++ b/addons/purchase/models/__init__.py @@ -2,7 +2,6 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import account_invoice -import mail_mail import purchase import res_company import res_config diff --git a/addons/purchase/models/mail_mail.py b/addons/purchase/models/mail_mail.py deleted file mode 100644 index 433ff1d66a5..00000000000 --- a/addons/purchase/models/mail_mail.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class MailMail(models.Model): - _name = 'mail.mail' - _inherit = 'mail.mail' - - @api.multi - def _postprocess_sent_message(self, mail_sent=True): - for mail in self: - if mail_sent and mail.model == 'purchase.order': - purchase_order = self.env['purchase.order'].browse(mail.res_id) - if purchase_order.state == 'draft': - self.env['purchase.order'].signal_workflow([mail.res_id], 'send_rfq') - return super(MailMail, self)._postprocess_sent_message(mail_sent=mail_sent)