diff --git a/addons/l10n_mx/i18n/l10n_mx.pot b/addons/l10n_mx/i18n/l10n_mx.pot index be0c22ec7adb6ea40715230adf8657c328fd12b8..e67ffa553db63981f3d4843712e1451393649ea5 100644 --- a/addons/l10n_mx/i18n/l10n_mx.pot +++ b/addons/l10n_mx/i18n/l10n_mx.pot @@ -127,6 +127,12 @@ msgstr "" msgid "Nature" msgstr "" +#. module: l10n_mx +#: code:addons/l10n_mx/models/account_move.py:0 +#, python-format +msgid "Only invoices can be printed." +msgstr "" + #. module: l10n_mx #: model:ir.model.fields,help:l10n_mx.field_account_setup_bank_manual_config__l10n_mx_edi_clabe #: model:ir.model.fields,help:l10n_mx.field_res_partner_bank__l10n_mx_edi_clabe diff --git a/addons/l10n_mx/models/__init__.py b/addons/l10n_mx/models/__init__.py index e92febf41350fd8291ef341f94e92c98338e02c9..a65020a80f372c6b12c1ea4f51080d59b18230f5 100644 --- a/addons/l10n_mx/models/__init__.py +++ b/addons/l10n_mx/models/__init__.py @@ -6,3 +6,4 @@ from . import account from . import res_bank from . import res_config_settings from . import chart_template +from . import account_move diff --git a/addons/l10n_mx/models/account_move.py b/addons/l10n_mx/models/account_move.py new file mode 100644 index 0000000000000000000000000000000000000000..3ce6f505e387dfac32aedee2072b54a6adf76234 --- /dev/null +++ b/addons/l10n_mx/models/account_move.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from odoo import models, _ +from odoo.exceptions import UserError + + +class AccountMove(models.Model): + _inherit = 'account.move' + + def _get_report_base_filename(self): + self.ensure_one() + if (self.company_id.country_id and self.company_id.country_id.code) == 'MX': + if not self.is_invoice(include_receipts=True): + raise UserError(_("Only invoices can be printed.")) + return self._get_move_display_name() + return super()._get_report_base_filename()