fix(form-compile): AutoTitle=false по умолчанию при заданном Title формы

Когда у формы задан Title (через defn.title или properties.title), эмитим
AutoTitle=false если пользователь явно его не указал. Иначе платформа
добавляет суффикс синонима и получается двойной заголовок (Номенклатура:
Номенклатура). В выгрузках ERP так делает ~95% форм с form-level Title.

Снапшоты form-compile/form-compile-from-object обновлены под новое поведение.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-05-02 17:22:48 +03:00
parent e216db5734
commit 36cd63d8bb
24 changed files with 47 additions and 9 deletions
@@ -1,4 +1,4 @@
# form-compile v1.11 — Compile 1C managed form from JSON or object metadata
# form-compile v1.12 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$JsonPath,
@@ -2805,17 +2805,26 @@ if ($formTitle) {
}
# 12b. Properties (skip 'title' — handled above as multilingual)
# When form-level Title is set, default autoTitle=false (≈95% of ERP forms do this;
# otherwise platform appends synonym → "Title: Synonym" double-titles).
$propsClone = New-Object PSObject
$hasAutoTitle = $false
if ($def.properties) {
foreach ($p in $def.properties.PSObject.Properties) {
if ($p.Name -eq "autoTitle") { $hasAutoTitle = $true }
}
}
if ($formTitle -and -not $hasAutoTitle) {
$propsClone | Add-Member -NotePropertyName "autoTitle" -NotePropertyValue $false
}
if ($def.properties) {
$propsClone = New-Object PSObject
foreach ($p in $def.properties.PSObject.Properties) {
if ($p.Name -ne "title") {
$propsClone | Add-Member -NotePropertyName $p.Name -NotePropertyValue $p.Value
}
}
Emit-Properties -props $propsClone -indent "`t"
} else {
Emit-Properties -props $null -indent "`t"
}
Emit-Properties -props $propsClone -indent "`t"
# 12c. CommandSet (excluded commands)
if ($def.excludedCommands -and $def.excludedCommands.Count -gt 0) {
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# form-compile v1.11 — Compile 1C managed form from JSON or object metadata
# form-compile v1.12 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import copy
@@ -2681,9 +2681,16 @@ def main():
emit_mltext(lines, '\t', 'Title', str(form_title))
# Properties (skip 'title' — handled above)
if defn.get('properties'):
props_clone = {k: v for k, v in defn['properties'].items() if k != 'title'}
emit_properties(lines, props_clone, '\t')
# When form-level Title is set, default autoTitle=false (≈95% of ERP forms do this;
# otherwise platform appends synonym → "Title: Synonym" double-titles).
props_src = defn.get('properties') or {}
props_clone = OrderedDict()
if form_title and 'autoTitle' not in props_src:
props_clone['autoTitle'] = False
for k, v in props_src.items():
if k != 'title':
props_clone[k] = v
emit_properties(lines, props_clone, '\t')
# CommandSet (excluded commands)
if defn.get('excludedCommands') and len(defn['excludedCommands']) > 0:
@@ -6,6 +6,7 @@
<v8:content>Денежные средства</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<Table name="Список" id="1">
@@ -6,6 +6,7 @@
<v8:content>Валюты</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<UsualGroup name="ГруппаШапка" id="1">
@@ -6,6 +6,7 @@
<v8:content>Валюты</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<Table name="Список" id="1">
@@ -6,6 +6,7 @@
<v8:content>Виды номенклатуры</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<UsualGroup name="ГруппаШапка" id="1">
@@ -6,6 +6,7 @@
<v8:content>Хозрасчетный</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<UsualGroup name="ГруппаШапка" id="1">
@@ -6,6 +6,7 @@
<v8:content>Хозрасчетный</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<Table name="Список" id="1">
@@ -6,6 +6,7 @@
<v8:content>Акт выполненных внутренних работ</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<Table name="Список" id="1">
@@ -6,6 +6,7 @@
<v8:content>Обмен данными</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<UsualGroup name="ГруппаШапка" id="1">
@@ -6,6 +6,7 @@
<v8:content>Цены номенклатуры</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<Table name="Список" id="1">
@@ -6,6 +6,7 @@
<v8:content>Адреса магазинов</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<WindowOpeningMode>LockOwnerWindow</WindowOpeningMode>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
@@ -6,6 +6,7 @@
<v8:content>Курсы валют</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<WindowOpeningMode>LockOwnerWindow</WindowOpeningMode>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
@@ -6,6 +6,7 @@
<v8:content>Разные типы</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<InputField name="Строка" id="1">
@@ -6,6 +6,7 @@
<v8:content>Бригады</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1">
<ChildItems>
<Button name="ИзменитьВыделенные" id="1">
@@ -6,6 +6,7 @@
<v8:content>Товар</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<InputField name="Наименование" id="1">
@@ -6,6 +6,7 @@
<v8:content>Форма с командами</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1">
<Autofill>false</Autofill>
</AutoCommandBar>
@@ -6,6 +6,7 @@
<v8:content>Товары</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<Table name="Список" id="1">
@@ -6,6 +6,7 @@
<v8:content>События</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<Events>
<Event name="OnCreateAtServer">ПриСозданииНаСервере</Event>
@@ -6,6 +6,7 @@
<v8:content>Группы</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1">
<Autofill>false</Autofill>
</AutoCommandBar>
@@ -6,6 +6,7 @@
<v8:content>Поля ввода</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<InputField name="ОбычноеПоле" id="1">
@@ -6,5 +6,6 @@
<v8:content>Минимальная форма</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
</Form>
@@ -6,6 +6,7 @@
<v8:content>Тест синонимов</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1">
<ChildItems>
<Button name="Кн1" id="1">
@@ -6,6 +6,7 @@
<v8:content>Просмотр данных</v8:content>
</v8:item>
</Title>
<AutoTitle>false</AutoTitle>
<AutoCommandBar name="ФормаКоманднаяПанель" id="-1"/>
<ChildItems>
<Table name="Данные" id="1">