diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index b882d6dd3dbca..a88145b25a223 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -4205,6 +4205,13 @@ msgstr "" msgid "Credit Note" msgstr "" +#. module: account +#. odoo-python +#: code:addons/account/models/account_move.py:0 +#, python-format +msgid "You can only send sales documents" +msgstr "" + #. module: account #. odoo-python #: code:addons/account/models/account_move.py:0 diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 10061b7b2234b..13e5fc5c40efd 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3871,6 +3871,9 @@ def action_duplicate(self): def action_send_and_print(self): template = self.env.ref(self._get_mail_template(), raise_if_not_found=False) + if any(not x.is_sale_document(include_receipts=True) for x in self): + raise UserError(_("You can only send sales documents")) + return { 'name': _("Send"), 'type': 'ir.actions.act_window', @@ -3889,21 +3892,8 @@ def action_invoice_sent(self): message loaded by default """ self.ensure_one() - template = self.env.ref(self._get_mail_template(), raise_if_not_found=False) - - report_action = { - 'name': _("Send"), - 'type': 'ir.actions.act_window', - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'account.move.send', - 'target': 'new', - 'context': { - 'active_ids': self.ids, - 'default_mail_template_id': template.id, - }, - } + report_action = self.action_send_and_print() if self.env.is_admin() and not self.env.company.external_report_layout_id and not self.env.context.get('discard_logo_check'): return self.env['ir.actions.report']._action_configure_external_report_layout(report_action)