fix: allow sending invoice without customer object selection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ali 2026-04-01 14:50:33 +04:00
parent 10be61958c
commit c561371a16
1 changed files with 10 additions and 2 deletions

View File

@ -1715,6 +1715,14 @@ function show_object_picker_dialog(frm, objects, customerName, taxId) {
objectsHtml += '<th style="width: 40%;">' + __('Address') + '</th>'; objectsHtml += '<th style="width: 40%;">' + __('Address') + '</th>';
objectsHtml += '</tr></thead><tbody>'; objectsHtml += '</tr></thead><tbody>';
// Empty object option
objectsHtml += '<tr class="object-row" data-index="empty" style="cursor: pointer;">';
objectsHtml += '<td><input type="radio" name="object_selection" value="empty" class="object-radio"></td>';
objectsHtml += '<td>—</td>';
objectsHtml += '<td>—</td>';
objectsHtml += '<td style="color: var(--text-muted);">' + __('Without object') + '</td>';
objectsHtml += '</tr>';
objects.forEach(function(obj, index) { objects.forEach(function(obj, index) {
const objectName = obj.name || '-'; const objectName = obj.name || '-';
const objectCode = obj.code || '-'; const objectCode = obj.code || '-';
@ -1767,7 +1775,7 @@ function show_object_picker_dialog(frm, objects, customerName, taxId) {
return; return;
} }
const selectedObject = objects[parseInt(selectedIndex)]; const objectCode = selectedIndex === 'empty' ? '' : objects[parseInt(selectedIndex)].code;
// Hide dialog // Hide dialog
d.hide(); d.hide();
@ -1780,7 +1788,7 @@ function show_object_picker_dialog(frm, objects, customerName, taxId) {
doctype: 'Sales Invoice', doctype: 'Sales Invoice',
name: frm.doc.name, name: frm.doc.name,
fieldname: 'customer_object_name', fieldname: 'customer_object_name',
value: selectedObject.code value: objectCode
}, },
callback: function(r) { callback: function(r) {
if (r.message) { if (r.message) {