oca-ocb-l10n_asia-pacific/odoo-bringout-oca-ocb-l10n_in/l10n_in/models/iap_account.py
Ernad Husremovic 7f43bbbfcc 19.0 vanilla
2026-03-09 09:31:21 +01:00

30 lines
1.2 KiB
Python

from odoo import api, models
from odoo.addons.iap import jsonrpc
DEFAULT_IAP_ENDPOINT = "https://l10n-in-edi.api.odoo.com"
DEFAULT_IAP_TEST_ENDPOINT = "https://l10n-in-edi-demo.api.odoo.com"
IAP_SERVICE_NAME = 'l10n_in_edi'
TEST_GST_NUMBER = '24FANCY1234AAZA'
class IapAccount(models.Model):
_inherit = 'iap.account'
@api.model
def _l10n_in_connect_to_server(self, is_production, params, url_path, config_parameter, timeout=25):
IrConfigParam = self.env['ir.config_parameter'].sudo()
user_token = self.get(IAP_SERVICE_NAME)
params.update({
"dbuuid": IrConfigParam.get_param("database.uuid"),
"account_token": user_token.sudo().account_token,
})
gsp_provider = IrConfigParam.get_param("l10n_in.gsp_provider")
if gsp_provider:
params.update({"gsp_provider": gsp_provider})
if params.get('gstin') == TEST_GST_NUMBER:
default_endpoint = DEFAULT_IAP_TEST_ENDPOINT
else:
default_endpoint = DEFAULT_IAP_ENDPOINT if is_production else DEFAULT_IAP_TEST_ENDPOINT
endpoint = IrConfigParam.get_param(config_parameter, default_endpoint)
url = "%s%s" % (endpoint, url_path)
return jsonrpc(url, params=params, timeout=timeout)