Skip to content
Snippets Groups Projects
Commit 36a286bc authored by aktr-odoo's avatar aktr-odoo Committed by Arjun Panchal
Browse files

[IMP] l10n_in_edi,l10n_in_edi_ewaybill: before test connection check GST number


Before this commit
==================
Test connection without checking GST number.

After this commit
=================
This commit adds functionality to check whether the GST number is present
or not before testing the connection.

Task id - 3246786

closes odoo/odoo#120100

Related: odoo/enterprise#40522
Signed-off-by: default avatarJosse Colpaert <jco@odoo.com>
parent c44d9441
No related branches found
No related tags found
No related merge requests found
......@@ -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."))
......@@ -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.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment