diff --git a/jey_erp/custom_fields.py b/jey_erp/custom_fields.py index e34fb40..d1fa816 100644 --- a/jey_erp/custom_fields.py +++ b/jey_erp/custom_fields.py @@ -113,20 +113,11 @@ def create_custom_fields(): reqd=0 ), - # Agricultural Validity Section - dict( - fieldname='agricultural_validity_section', - label='Tax Validity Period', - fieldtype='Section Break', - insert_after='agricultural_tax_article', - collapsible=1, - depends_on='eval:doc.agricultural_tax_article' - ), - + # Agricultural Validity HTML (прямо под tax article, БЕЗ секции) dict( fieldname='agricultural_validity_html', fieldtype='HTML', - insert_after='agricultural_validity_section', + insert_after='agricultural_tax_article', depends_on='eval:doc.agricultural_tax_article' ), @@ -195,20 +186,11 @@ def create_custom_fields(): reqd=0 ), - # Industrial Validity Section - dict( - fieldname='industrial_validity_section', - label='Tax Validity Period', - fieldtype='Section Break', - insert_after='industrial_tax_article', - collapsible=1, - depends_on='eval:doc.industrial_tax_article' - ), - + # Industrial Validity HTML (прямо под tax article, БЕЗ секции) dict( fieldname='industrial_validity_html', fieldtype='HTML', - insert_after='industrial_validity_section', + insert_after='industrial_tax_article', depends_on='eval:doc.industrial_tax_article' ), @@ -232,20 +214,11 @@ def create_custom_fields(): reqd=0 ), - # Tax Exempt Validity Section - dict( - fieldname='tax_exempt_validity_section', - label='Tax Validity Period', - fieldtype='Section Break', - insert_after='tax_exempt_tax_article', - collapsible=1, - depends_on='eval:doc.tax_exempt_tax_article' - ), - + # Tax Exempt Validity HTML (прямо под tax article, БЕЗ секции) dict( fieldname='tax_exempt_validity_html', fieldtype='HTML', - insert_after='tax_exempt_validity_section', + insert_after='tax_exempt_tax_article', depends_on='eval:doc.tax_exempt_tax_article' ), diff --git a/jey_erp/public/js/asset.js b/jey_erp/public/js/asset.js index d8d8125..12e39ad 100644 --- a/jey_erp/public/js/asset.js +++ b/jey_erp/public/js/asset.js @@ -1,3 +1,5 @@ +// asset.js - ПОЛНЫЙ КОД (JS остается без изменений, так как он уже работает правильно) + frappe.ui.form.on('Asset', { refresh: function(frm) { setup_asset_fields(frm); @@ -233,13 +235,15 @@ function render_tax_validity_fields(frm, type) { } // Создаем контейнер с нужными классами Frappe - const $container = $('
').appendTo($wrapper); + const $container = $('
').appendTo($wrapper); const $row = $('
').appendTo($container); - // Создаем 3 колонки для полей - const $col1 = $('
').appendTo($row); - const $col2 = $('
').appendTo($row); - const $col3 = $('
').appendTo($row); + // Создаем 2 колонки для полей (Date From и Date To) + const $col1 = $('
').appendTo($row); + const $col2 = $('
').appendTo($row); + + // ВАЖНО: Блокируем dirty во время загрузки + frm[`_loading_validity_${type}`] = true; // Проверяем, есть ли уже сохраненные данные в памяти (приоритет) let initial_date_from = tax_article.date_from; @@ -267,9 +271,9 @@ function render_tax_validity_fields(frm, type) { }); date_from_field.set_value(initial_date_from); - // Создаем Duration поле (скрытое и read only) + // Создаем скрытое Duration поле (для хранения данных) const duration_field = frappe.ui.form.make_control({ - parent: $col2, + parent: $('
').appendTo($wrapper), df: { fieldtype: 'Int', label: __('Duration (Years)'), @@ -283,7 +287,7 @@ function render_tax_validity_fields(frm, type) { // Создаем Date To поле (read only) const date_to_field = frappe.ui.form.make_control({ - parent: $col3, + parent: $col2, df: { fieldtype: 'Date', label: __('Date To'), @@ -295,8 +299,8 @@ function render_tax_validity_fields(frm, type) { date_to_field.set_value(initial_date_to); // Добавляем информационное сообщение - $('
') - .text(__('Changes will be saved to Tax Article when you save this Asset')) + $('
') + .html(' ' + __('Changes will be saved to Tax Article when you save this Asset')) .appendTo($container); // Сохраняем ссылки на контролы @@ -318,6 +322,11 @@ function render_tax_validity_fields(frm, type) { date_to: initial_date_to, duration: initial_duration }; + + // Снимаем блокировку dirty после небольшой задержки + setTimeout(() => { + frm[`_loading_validity_${type}`] = false; + }, 100); } }, error: function() { @@ -327,6 +336,11 @@ function render_tax_validity_fields(frm, type) { } function handle_date_from_change(frm, type) { + // Игнорируем изменения во время загрузки + if (frm[`_loading_validity_${type}`]) { + return; + } + if (!frm._tax_validity_controls || !frm._tax_validity_controls[type]) { return; } @@ -407,7 +421,7 @@ function save_tax_validity_data(frm) { return Promise.resolve(); } -// ===== ОСТАЛЬНЫЕ ФУНКЦИИ ===== +// ===== ОСТАЛЬНЫЕ ФУНКЦИИ (БЕЗ ИЗМЕНЕНИЙ) ===== function update_area_field_label(frm) { let asset_type = frm.doc.custom_asset_type;