mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-30 17:42:32 +02:00
fix: UX improvements for Serial and Batch Bundle
(cherry picked from commit 5d94f0bde5)
This commit is contained in:
committed by
Mergify
parent
a6b4d5b101
commit
c76145985d
@@ -179,11 +179,52 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
|||||||
label = __('Serial Nos / Batch Nos');
|
label = __('Serial Nos / Batch Nos');
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
let fields = [
|
||||||
{
|
{
|
||||||
fieldtype: 'Section Break',
|
fieldtype: 'Section Break',
|
||||||
label: __('{0} {1} via CSV File', [primary_label, label])
|
label: __('{0} {1} via CSV File', [primary_label, label])
|
||||||
},
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
if (this.item?.has_serial_no) {
|
||||||
|
fields = [...fields,
|
||||||
|
{
|
||||||
|
fieldtype: 'Check',
|
||||||
|
label: __('Upload Using CSV file'),
|
||||||
|
fieldname: 'upload_using_csv',
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: 'Section Break',
|
||||||
|
depends_on: 'eval:doc.upload_using_csv === 0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: 'Small Text',
|
||||||
|
label: __('Serial Nos'),
|
||||||
|
fieldname: 'upload_serial_nos',
|
||||||
|
depends_on: 'eval:doc.upload_using_csv === 0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: 'Column Break',
|
||||||
|
depends_on: 'eval:doc.upload_using_csv === 0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: 'Button',
|
||||||
|
fieldname: 'make_serial_nos',
|
||||||
|
label: __('Create Serial Nos'),
|
||||||
|
depends_on: 'eval:doc.upload_using_csv === 0',
|
||||||
|
click: () => {
|
||||||
|
this.create_serial_nos();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: 'Section Break',
|
||||||
|
depends_on: 'eval:doc.upload_using_csv === 1',
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
fields = [...fields,
|
||||||
{
|
{
|
||||||
fieldtype: 'Button',
|
fieldtype: 'Button',
|
||||||
fieldname: 'download_csv',
|
fieldname: 'download_csv',
|
||||||
@@ -199,7 +240,31 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
|||||||
label: __('Attach CSV File'),
|
label: __('Attach CSV File'),
|
||||||
onchange: () => this.upload_csv_file()
|
onchange: () => this.upload_csv_file()
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
|
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
create_serial_nos() {
|
||||||
|
let {upload_serial_nos} = this.dialog.get_values();
|
||||||
|
|
||||||
|
if (!upload_serial_nos) {
|
||||||
|
frappe.throw(__('Please enter Serial Nos'));
|
||||||
|
}
|
||||||
|
|
||||||
|
frappe.call({
|
||||||
|
method: 'erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle.create_serial_nos',
|
||||||
|
args: {
|
||||||
|
item_code: this.item.item_code,
|
||||||
|
serial_nos: upload_serial_nos
|
||||||
|
},
|
||||||
|
callback: (r) => {
|
||||||
|
if (r.message) {
|
||||||
|
this.dialog.fields_dict.entries.df.data = [];
|
||||||
|
this.set_data(r.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
download_csv_file() {
|
download_csv_file() {
|
||||||
|
|||||||
@@ -999,9 +999,25 @@ def get_serial_batch_from_data(item_code, kwargs):
|
|||||||
|
|
||||||
make_serial_nos(item_code, serial_nos)
|
make_serial_nos(item_code, serial_nos)
|
||||||
|
|
||||||
|
if kwargs.get("_has_serial_nos"):
|
||||||
|
return serial_nos
|
||||||
|
|
||||||
return serial_nos, batch_nos
|
return serial_nos, batch_nos
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def create_serial_nos(item_code, serial_nos):
|
||||||
|
serial_nos = get_serial_batch_from_data(
|
||||||
|
item_code,
|
||||||
|
{
|
||||||
|
"serial_nos": serial_nos,
|
||||||
|
"_has_serial_nos": True,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
return serial_nos
|
||||||
|
|
||||||
|
|
||||||
def make_serial_nos(item_code, serial_nos):
|
def make_serial_nos(item_code, serial_nos):
|
||||||
item = frappe.get_cached_value("Item", item_code, ["description", "item_code"], as_dict=1)
|
item = frappe.get_cached_value("Item", item_code, ["description", "item_code"], as_dict=1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user