[FIX] account: Send & Print only for sales documents
We are currently able to open the send & print for a vendor bill. It doesn't make any sense to ask to a vendor to pay its own invoice. closes odoo/odoo#129793 X-original-commit: b3e8229d16be074a719fa07e3b2d5488ace66492 Signed-off-by: John Laterre (jol) <jol@odoo.com> Signed-off-by: Laurent Smet (las) <las@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -3871,6 +3871,9 @@ class AccountMove(models.Model):
|
||||
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 @@ class AccountMove(models.Model):
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user