[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#120201 X-original-commit: 36a286bca461ce0eaa93b25c303ec121291c281b Related: odoo/enterprise#40575 Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
@@ -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.")
|
||||
|
||||
Reference in New Issue
Block a user