def debrand_text(text, value, expression): cases = { expression: uuid.uuid4().hex, expression.upper(): uuid.uuid4().hex, expression.lower(): uuid.uuid4().hex, expression.capitalize(): uuid.uuid4().hex, } def init_no_debranding(match): text = match.group() for key in cases: text = re.sub(r'\b{0}\b'.format(key), cases[key], text) return text def post_no_debranding(text): for key in cases: text = text.replace(cases[key], key) return text if isinstance(value, dict): text = safe_execute(text, debrand_documentation, text, value.get('documentation'), expression) text = safe_execute(text, debrand_link, text, value.get('website'), expression) text = re.sub( r'<.*class=".*no_debranding.*".*>.*(\b{0}\b).*<.*>'.format(expression), init_no_debranding, text, flags=re.IGNORECASE) text = re.sub( r'\b(?<!\.){0}(?!\.\S|\s?=|\w|\[)\b'.format(expression), value.get('system_name') if isinstance(value, dict) else value, text, flags=re.IGNORECASE) return post_no_debranding(text)
def read(self, fields=None, load='_classic_read'): result = super(IrActionsActWindow, self).read(fields=fields, load=load) if not fields or 'help' in fields: for values in result: if isinstance(values, dict) and values.get('help'): user_context = dict(self.env.context) value_context = values.get('context', '{}') context = safe_execute({}, safe_eval, value_context, user_context) values['help'] = self.env[ 'muk_branding.debranding'].debrand(values['help']) return result
def safe_debrand(input, value, expression="odoo"): return safe_execute(input, debrand, input, value, expression)
def company_favicon(self, dbname=None, **kw): company = safe_execute(False, int, kw['company']) if kw and kw.get('company') else False return self._get_company_image_response( dbname, 'favicon', ('favicon.ico', 'nofavicon.ico'), 'image/x-icon', company )
def company_logo(self, dbname=None, **kw): company = safe_execute(False, int, kw['company']) if kw and kw.get('company') else False return self._get_company_image_response( dbname, 'logo_web', ('logo.png', 'nologo.png'), 'image/png', company )