diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index ce099bd0ea481e69cfce81ab446f29122ef55d18..846701b2b161b81412ef837d59c1245f57d2db65 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -579,6 +579,13 @@ class AccountInvoice(models.Model): 'context': ctx, } + @api.multi + @api.returns('self', lambda value: value.id) + def message_post(self, **kwargs): + if self.env.context.get('mark_invoice_as_sent'): + self.filtered(lambda inv: not inv.sent).write({'sent': True}) + return super(AccountInvoice, self.with_context(mail_post_autofollow=True)).message_post(**kwargs) + @api.multi def compute_taxes(self): """Function used in other module to compute the taxes on a fresh invoice created (onchanges did not applied)""" @@ -1797,18 +1804,3 @@ class AccountPaymentTermLine(models.Model): def _onchange_option(self): if self.option in ('last_day_current_month', 'last_day_following_month'): self.days = 0 - - -class MailComposeMessage(models.TransientModel): - _inherit = 'mail.compose.message' - - @api.multi - def send_mail(self, auto_commit=False): - context = self._context - if context.get('default_model') == 'account.invoice' and \ - context.get('default_res_id') and context.get('mark_invoice_as_sent'): - invoice = self.env['account.invoice'].browse(context['default_res_id']) - if not invoice.sent: - invoice.sent = True - self = self.with_context(mail_post_autofollow=True) - return super(MailComposeMessage, self).send_mail(auto_commit=auto_commit) diff --git a/addons/l10n_ch/models/__init__.py b/addons/l10n_ch/models/__init__.py index acb15c35730c424b58d63f713d1e33bd986883d8..cf7550fd3684270a53b7db8752dc4f91766e34f8 100644 --- a/addons/l10n_ch/models/__init__.py +++ b/addons/l10n_ch/models/__init__.py @@ -3,7 +3,6 @@ from . import res_config_settings from . import account_invoice -from . import mail_compose_message from . import mail_template from . import res_bank from . import res_company diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py index bcb9935e0a9eaa4fb3a8bfbbf8e88945ee86e5e3..8912b763db7aff55d84a4b8939fee39cdba87ecc 100644 --- a/addons/l10n_ch/models/account_invoice.py +++ b/addons/l10n_ch/models/account_invoice.py @@ -166,3 +166,10 @@ class AccountInvoice(models.Model): rslt['context']['l10n_ch_mark_isr_as_sent'] = True return rslt + + @api.multi + @api.returns('self', lambda value: value.id) + def message_post(self, **kwargs): + if self.env.context.get('l10n_ch_mark_isr_as_sent'): + self.filtered(lambda inv: not inv.l10n_ch_isr_sent).write({'l10n_ch_isr_sent': True}) + return super(AccountInvoice, self.with_context(mail_post_autofollow=True)).message_post(**kwargs) diff --git a/addons/l10n_ch/models/mail_compose_message.py b/addons/l10n_ch/models/mail_compose_message.py deleted file mode 100644 index 652571492a78c6847b24e47ae2760ef1fa618a41..0000000000000000000000000000000000000000 --- a/addons/l10n_ch/models/mail_compose_message.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, fields, models, _ - - -class MailComposer(models.TransientModel): - _inherit = 'mail.compose.message' - - @api.multi - def send_mail(self, auto_commit=False): - """ Method overriden to mark ISR as sent once a mail containing - it in attachment has been sent. - """ - context = self._context - if context.get('default_model') == 'account.invoice' and \ - context.get('default_res_id') and \ - context.get('l10n_ch_mark_isr_as_sent', False): - - invoice = self.env['account.invoice'].browse(context['default_res_id']) - invoice = invoice.with_context(mail_post_autofollow=True) - invoice.l10n_ch_isr_sent = True - invoice.message_post(body=_("ISR sent")) - - return super(MailComposer, self).send_mail(auto_commit=auto_commit) \ No newline at end of file diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index bb9f8d2346a1e532636c4946db9219ddc716870e..10c3f0f77820cf2184d61b53fc27ddf39fa6efbe 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -307,7 +307,8 @@ class PurchaseOrder(models.Model): 'default_template_id': template_id, 'default_composition_mode': 'comment', 'custom_layout': "purchase.mail_template_data_notification_email_purchase_order", - 'force_email': True + 'force_email': True, + 'mark_rfq_as_sent': True, }) return { 'name': _('Compose Email'), @@ -321,6 +322,13 @@ class PurchaseOrder(models.Model): 'context': ctx, } + @api.multi + @api.returns('self', lambda value: value.id) + def message_post(self, **kwargs): + if self.env.context.get('mark_rfq_as_sent'): + self.filtered(lambda o: o.state == 'draft').write({'state': 'sent'}) + return super(PurchaseOrder, self.with_context(mail_post_autofollow=True)).message_post(**kwargs) + @api.multi def print_quotation(self): return self.env.ref('purchase.report_purchase_quotation').report_action(self) @@ -1083,16 +1091,3 @@ class ProductCategory(models.Model): 'account.account', string="Price Difference Account", company_dependent=True, help="This account will be used to value price difference between purchase price and accounting cost.") - - -class MailComposeMessage(models.TransientModel): - _inherit = 'mail.compose.message' - - @api.multi - def send_mail(self, auto_commit=False): - if self._context.get('default_model') == 'purchase.order' and self._context.get('default_res_id'): - if not self.filtered('subtype_id.internal'): - order = self.env['purchase.order'].browse([self._context['default_res_id']]) - if order.state == 'draft': - order.state = 'sent' - return super(MailComposeMessage, self.with_context(mail_post_autofollow=True)).send_mail(auto_commit=auto_commit) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index b98d3ee31a70ddabf0adc78de002d9d2d60e0b5f..071c62375a8f75369fe869559936a140a72dbb38 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -496,6 +496,13 @@ class SaleOrder(models.Model): 'context': ctx, } + @api.multi + @api.returns('self', lambda value: value.id) + def message_post(self, **kwargs): + if self.env.context.get('mark_so_as_sent'): + self.filtered(lambda o: o.state == 'draft').write({'state': 'sent'}) + return super(SaleOrder, self.with_context(mail_post_autofollow=True)).message_post(**kwargs) + @api.multi def force_quotation_send(self): for order in self: diff --git a/addons/sale/wizard/__init__.py b/addons/sale/wizard/__init__.py index 5d8b76139cb320e13d02a74d5ed258ee144b0067..46b1c608a3d69672c78bcef562c0e9c6c23c3eb7 100644 --- a/addons/sale/wizard/__init__.py +++ b/addons/sale/wizard/__init__.py @@ -2,4 +2,3 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import sale_make_invoice_advance -from . import mail_compose_message \ No newline at end of file diff --git a/addons/sale/wizard/mail_compose_message.py b/addons/sale/wizard/mail_compose_message.py deleted file mode 100644 index 73d81116d50b898de430ddb8a884d0108bf71b9d..0000000000000000000000000000000000000000 --- a/addons/sale/wizard/mail_compose_message.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, models - - -class MailComposeMessage(models.TransientModel): - _inherit = 'mail.compose.message' - - @api.multi - def send_mail(self, auto_commit=False): - if self._context.get('default_model') == 'sale.order' and self._context.get('default_res_id') and self._context.get('mark_so_as_sent'): - order = self.env['sale.order'].browse([self._context['default_res_id']]) - if order.state == 'draft': - order.state = 'sent' - self = self.with_context(mail_post_autofollow=True) - return super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)