ITSA Workflow

This commit is contained in:
AzureAD\SylvainDUVERNAY
2026-05-30 15:33:23 +02:00
parent 093be8ebdb
commit 0d05e3b22d
2 changed files with 22 additions and 3 deletions

View File

@@ -15,6 +15,8 @@ from trytond.transaction import Transaction
DOCUMENTATION_ROOT = Path(__file__).with_name('process_documentation')
MARKDOWN_LINK = re.compile(r'(!?)\[([^\]]*)\]\(([^)]+)\)')
HTML_IMAGE_SOURCE = re.compile(
r'(<img\b[^>]*\bsrc=)(["\'])([^"\']+)(\2)', re.IGNORECASE)
class ProcessDocumentation(ModelSingleton, ModelSQL, ModelView):
@@ -50,13 +52,30 @@ def _html_file_content(filename):
common_path = os.path.commonpath([str(root), str(path)])
if path != root and common_path == str(root):
if path.exists() and path.is_file() and path.suffix.lower() == '.html':
document = path.read_text(encoding='utf-8')
document = _inline_html_assets(document, _relative_name(path))
return IFRAME_TEMPLATE % {
'document': html.escape(path.read_text(encoding='utf-8'),
quote=True),
'document': html.escape(document, quote=True),
}
return _html_error('Documentation page not found: %s' % filename)
def _inline_html_assets(document, current_file):
def replace(match):
prefix, quote, source, suffix = match.groups()
resolved = _resolve_link(current_file, source)
if resolved.startswith(('http://', 'https://', 'data:', 'mailto:')):
return match.group(0)
data_uri = _asset_data_uri(resolved)
if not data_uri:
return match.group(0)
return '%s%s%s%s' % (prefix, quote, html.escape(data_uri, quote=True),
suffix)
return HTML_IMAGE_SOURCE.sub(replace, document)
def _html_error(message):
document = HTML_TEMPLATE % {
'content': '<p>%s</p>' % html.escape(message),

View File

@@ -382,7 +382,7 @@
<li>Contract lines: product, quantity, unit, tolerance, price formula, Mtm.</li>
</ul>
<div class="screenshot-placeholder">
<img src="../assets/purchase_contract_header.png" alt="Purchase contract header">
<img src="assets/purchase_contract_header.png" alt="Purchase contract header">
</div>
</div>
</td>