fix: UX improvements for Serial and Batch Bundle
This commit is contained in:
parent
c40719caa5
commit
5d94f0bde5
@ -179,11 +179,52 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
||||
label = __('Serial Nos / Batch Nos');
|
||||
}
|
||||
|
||||
return [
|
||||
let fields = [
|
||||
{
|
||||
fieldtype: 'Section Break',
|
||||
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',
|
||||
fieldname: 'download_csv',
|
||||
@ -199,7 +240,31 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
||||
label: __('Attach 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() {
|
||||
|
@ -999,9 +999,25 @@ def get_serial_batch_from_data(item_code, kwargs):
|
||||
|
||||
make_serial_nos(item_code, serial_nos)
|
||||
|
||||
if kwargs.get("_has_serial_nos"):
|
||||
return serial_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):
|
||||
item = frappe.get_cached_value("Item", item_code, ["description", "item_code"], as_dict=1)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user