diff --git a/addons/l10n_in_edi/models/res_config_settings.py b/addons/l10n_in_edi/models/res_config_settings.py index 566e6fb25e1..3525f1120c8 100644 --- a/addons/l10n_in_edi/models/res_config_settings.py +++ b/addons/l10n_in_edi/models/res_config_settings.py @@ -2,7 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import models, fields, _ -from odoo.exceptions import UserError +from odoo.exceptions import UserError, RedirectWarning class ResConfigSettings(models.TransientModel): @@ -16,7 +16,19 @@ class ResConfigSettings(models.TransientModel): readonly=False ) + def l10n_in_check_gst_number(self): + if not self.company_id.vat: + action = { + "view_mode": "form", + "res_model": "res.company", + "type": "ir.actions.act_window", + "res_id" : self.company_id.id, + "views": [[self.env.ref("base.view_company_form").id, "form"]], + } + raise RedirectWarning(_("Please enter a GST number in company."), action, _('Go to Company')) + def l10n_in_edi_test(self): + self.l10n_in_check_gst_number() self.env["account.edi.format"]._l10n_in_edi_authenticate(self.company_id) if not self.company_id.sudo()._l10n_in_edi_token_is_valid(): raise UserError(_("Incorrect username or password, or the GST number on company does not match.")) diff --git a/addons/l10n_in_edi_ewaybill/models/res_config_settings.py b/addons/l10n_in_edi_ewaybill/models/res_config_settings.py index 1eacd3b94dd..fe251c4f427 100755 --- a/addons/l10n_in_edi_ewaybill/models/res_config_settings.py +++ b/addons/l10n_in_edi_ewaybill/models/res_config_settings.py @@ -15,6 +15,7 @@ class ResConfigSettings(models.TransientModel): related="company_id.l10n_in_edi_ewaybill_password", readonly=False) def l10n_in_edi_ewaybill_test(self): + self.l10n_in_check_gst_number() response = self.env["account.edi.format"]._l10n_in_edi_ewaybill_authenticate(self.company_id) if response.get("error") or not self.company_id.sudo()._l10n_in_edi_ewaybill_token_is_valid(): error_message = _("Incorrect username or password, or the GST number on company does not match.")