30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
# Copyright 2024 Open2Bizz <info@open2bizz.nl>
|
|
# License LGPL-3
|
|
|
|
from odoo import api, fields, models, _
|
|
|
|
import logging
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
class IrActionUrl(models.Model):
|
|
_inherit = "ir.config_parameter"
|
|
|
|
@api.model
|
|
#def init(self):
|
|
def _mailcatcher_url(self):
|
|
parameters = self.env['ir.config_parameter'].search([('key','=', 'web.base.url')])
|
|
if parameters:
|
|
parameter = parameters[0]
|
|
cont_nr = parameter.value.split("//",1)[1] #Haal https:// van string
|
|
cont_nr = cont_nr[0:3] #De eerste 3 karakters is het containernummer
|
|
node = parameter.value.split("staging",1)[1] #Haal alles van string weg t/m staging
|
|
node = node[0:1] #Het eerste karakters is het de stagingarea
|
|
act_url = "https://" + cont_nr + "-mailcatcher.staging" + node + ".open2bizz.com"
|
|
_logger.info('---------- ACT_URL ---------- %s', act_url)
|
|
action_id = self.env['ir.model.data']._xmlid_to_res_id('mailcatcher_menu.action_mailcatcher_url')
|
|
action = self.env['ir.actions.act_url'].browse(action_id)
|
|
if action:
|
|
action.write({'url':act_url})
|
|
|
|
|