fix: move Company defaults fetch to server-side to avoid Unicode field validation
frappe.db.get_value rejects Unicode fieldnames (mdssüzrə etc.) even with backticks. Replace with a whitelisted Python method that uses frappe.get_doc. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9778ccbca8
commit
ecc770ca46
|
|
@ -3,18 +3,18 @@ function fillFromCompanyDefaults(frm) {
|
||||||
|| frappe.defaults.get_default('Company');
|
|| frappe.defaults.get_default('Company');
|
||||||
if (!company) return;
|
if (!company) return;
|
||||||
|
|
||||||
frappe.db.get_value(
|
frappe.call({
|
||||||
'Company',
|
method: 'taxes_az.taxes_az.doctype.single_declaration_related_to_salaried_and_non_salaried_work.single_declaration_related_to_salaried_and_non_salaried_work.get_company_defaults',
|
||||||
company,
|
args: { company: company },
|
||||||
['`mdssüzrə`', '`icbaritibbisığortaüzrə`', '`işsizlikdənsığortaüzrə`', '`main_activity`']
|
callback: function(r) {
|
||||||
).then(r => {
|
if (!r || !r.message) return;
|
||||||
if (!r || !r.message) return;
|
const v = r.message;
|
||||||
const v = r.message;
|
if (v.mdssüzrə) frm.set_value('mdssüzrə', v.mdssüzrə);
|
||||||
if (v['mdssüzrə']) frm.set_value('mdssüzrə', v['mdssüzrə']);
|
if (v.icbaritibbisığortaüzrə) frm.set_value('icbaritibbisığortaüzrə', v.icbaritibbisığortaüzrə);
|
||||||
if (v['icbaritibbisığortaüzrə']) frm.set_value('icbaritibbisığortaüzrə', v['icbaritibbisığortaüzrə']);
|
if (v.işsizlikdənsığortaüzrə) frm.set_value('işsizlikdənsığortaüzrə', v.işsizlikdənsığortaüzrə);
|
||||||
if (v['işsizlikdənsığortaüzrə']) frm.set_value('işsizlikdənsığortaüzrə', v['işsizlikdənsığortaüzrə']);
|
if (v.main_activity) frm.set_value('vergiüzrə', v.main_activity);
|
||||||
if (v['main_activity']) frm.set_value('vergiüzrə', v['main_activity']);
|
}
|
||||||
}).catch(() => {});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.ui.form.on('Single declaration related to salaried and non-salaried work', {
|
frappe.ui.form.on('Single declaration related to salaried and non-salaried work', {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,18 @@ class Singledeclarationrelatedtosalariedandnonsalariedwork(Document):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_company_defaults(company):
|
||||||
|
"""Fetch Company fields with Unicode names that can't go through client-side get_value."""
|
||||||
|
doc = frappe.get_doc("Company", company)
|
||||||
|
return {
|
||||||
|
"mdssüzrə": doc.get("mdssüzrə") or "",
|
||||||
|
"icbaritibbisığortaüzrə": doc.get("icbaritibbisığortaüzrə") or "",
|
||||||
|
"işsizlikdənsığortaüzrə": doc.get("işsizlikdənsığortaüzrə") or "",
|
||||||
|
"main_activity": doc.get("main_activity") or "",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def populate_declaration_tables(company, year, quarter):
|
def populate_declaration_tables(company, year, quarter):
|
||||||
"""Populate child tables from Employee Payroll Register data.
|
"""Populate child tables from Employee Payroll Register data.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue