mirror of
https://github.com/itsdave-de/msp.git
synced 2026-08-14 15:40:05 -03:00
fix: apply_ohne_berechnung sets values directly to avoid async recalculation conflicts
frappe.model.set_value in a loop triggered ERPNext pricing recalculation per item, causing values to be overwritten. Now sets values on locals objects directly and triggers a single recalculation at the end. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
1fca135a83
commit
4bf40ff70a
@@ -204,9 +204,16 @@ function show_ohne_berechnung_dialog(frm) {
|
||||
}
|
||||
|
||||
function apply_ohne_berechnung(frm, selected_items) {
|
||||
// Werte direkt auf den Doc-Objekten setzen (ohne einzelne set_value-Events)
|
||||
selected_items.forEach(item => {
|
||||
const doc_item = locals[item.doctype][item.name];
|
||||
if (!doc_item) return;
|
||||
|
||||
// 100% Rabatt setzen
|
||||
frappe.model.set_value(item.doctype, item.name, 'discount_percentage', 100);
|
||||
doc_item.discount_percentage = 100;
|
||||
doc_item.discount_amount = 0;
|
||||
doc_item.rate = 0;
|
||||
doc_item.amount = 0;
|
||||
|
||||
// Beschreibung bereinigen und "ohne Berechnung" genau einmal anhängen
|
||||
let desc = item.description || '';
|
||||
@@ -225,11 +232,14 @@ function apply_ohne_berechnung(frm, selected_items) {
|
||||
|
||||
// Standard-Zeile einmal anhängen
|
||||
const stamp = '<p><strong>ohne Berechnung</strong></p>';
|
||||
desc = (desc ? desc + stamp : stamp);
|
||||
|
||||
frappe.model.set_value(item.doctype, item.name, 'description', desc);
|
||||
doc_item.description = (desc ? desc + stamp : stamp);
|
||||
});
|
||||
|
||||
// Einmalig Formular neu berechnen und aktualisieren
|
||||
frm.dirty();
|
||||
frm.script_manager.trigger('calculate_taxes_and_totals');
|
||||
frm.refresh_fields();
|
||||
|
||||
frappe.show_alert({
|
||||
message: __("{0} Artikel wurden auf 'ohne Berechnung' gesetzt.", [selected_items.length]),
|
||||
indicator: 'green'
|
||||
|
||||
Reference in New Issue
Block a user