From 23b7591c913e0cdab590ca0277480f6c2811c31c Mon Sep 17 00:00:00 2001 From: marination Date: Wed, 4 Nov 2020 18:23:00 +0530 Subject: [PATCH 1/6] fix: SO to PO Mapping Issue - removed type: GET , which made the URL longer - Added only relevant fields from Items table to Dialog table to reduce args load - Made separate method to set table data in dialog - Added freeze message --- .../doctype/sales_order/sales_order.js | 42 ++++++++++--------- .../doctype/sales_order/sales_order.py | 8 +++- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 989bd33e42..203b840db9 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -572,12 +572,6 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( "fieldname": "against_default_supplier", "default": 0 }, - { - "fieldtype": "Section Break", - "label": "", - "fieldname": "sec_break_dialog", - "hide_border": 1 - }, { fieldname: 'items_for_po', fieldtype: 'Table', label: 'Select Items', fields: [ @@ -616,16 +610,13 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( read_only:1, in_list_view:1 }, - ], - data: me.frm.doc.items.map((item) =>{ - item.pending_qty = (flt(item.stock_qty) - flt(item.ordered_qty)) / flt(item.conversion_factor); - return item; - }).filter((item) => {return item.pending_qty > 0;}) + ] } ], primary_action_label: 'Create Purchase Order', primary_action (args) { if (!args) return; + let selected_items = dialog.fields_dict.items_for_po.grid.get_selected_children(); if(selected_items.length == 0) { frappe.throw({message: 'Please select Items from the Table', title: __('Items Required'), indicator:'blue'}) @@ -635,8 +626,9 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( var method = args.against_default_supplier ? "make_purchase_order_for_default_supplier" : "make_purchase_order" return frappe.call({ - type: "GET", method: "erpnext.selling.doctype.sales_order.sales_order." + method, + freeze: true, + freeze_message: __("Creating Purchase Order ..."), args: { "source_name": me.frm.doc.name, "selected_items": selected_items @@ -660,8 +652,9 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( } }); - dialog.fields_dict["against_default_supplier"].df.onchange = () => { - console.log("yo"); + dialog.fields_dict["against_default_supplier"].df.onchange = () => set_po_items_data(dialog); + + function set_po_items_data (dialog) { var against_default_supplier = dialog.get_value("against_default_supplier"); var items_for_po = dialog.get_value("items_for_po"); @@ -671,16 +664,27 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( dialog.fields_dict["items_for_po"].df.data = items_with_supplier; dialog.get_field("items_for_po").refresh(); } else { - let pending_items = me.frm.doc.items.map((item) =>{ - item.pending_qty = (flt(item.stock_qty) - flt(item.ordered_qty)) / flt(item.conversion_factor); - return item; - }).filter((item) => {return item.pending_qty > 0;}); + let po_items = []; + me.frm.doc.items.forEach(d => { + let pending_qty = (flt(d.stock_qty) - flt(d.ordered_qty)) / flt(d.conversion_factor); + if (pending_qty > 0) { + po_items.push({ + "name": d.name, + "item_name": d.item_name, + "item_code": d.item_code, + "pending_qty": pending_qty, + "uom": d.uom, + "supplier": d.supplier + }); + } + }); - dialog.fields_dict["items_for_po"].df.data = pending_items; + dialog.fields_dict["items_for_po"].df.data = po_items; dialog.get_field("items_for_po").refresh(); } } + set_po_items_data(dialog); dialog.get_field("items_for_po").grid.only_sortable(); dialog.get_field("items_for_po").refresh(); dialog.wrapper.find('.grid-heading-row .grid-row-check').click(); diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index ae227e0110..ec1c82339b 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -779,7 +779,9 @@ def get_events(start, end, filters=None): return data @frappe.whitelist() -def make_purchase_order_for_default_supplier(source_name, selected_items=[], target_doc=None): +def make_purchase_order_for_default_supplier(source_name, selected_items=None, target_doc=None): + if not selected_items: return + if isinstance(selected_items, string_types): selected_items = json.loads(selected_items) @@ -878,7 +880,9 @@ def make_purchase_order_for_default_supplier(source_name, selected_items=[], tar frappe.msgprint(_("Purchase Order already created for all Sales Order items")) @frappe.whitelist() -def make_purchase_order(source_name, selected_items=[], target_doc=None): +def make_purchase_order(source_name, selected_items=None, target_doc=None): + if not selected_items: return + if isinstance(selected_items, string_types): selected_items = json.loads(selected_items) From 2b8aa91cf2a986e2a122e01aac8357075aa50aff Mon Sep 17 00:00:00 2001 From: marination Date: Wed, 4 Nov 2020 21:00:52 +0530 Subject: [PATCH 2/6] fix: Make sure row object has doctype so that read only property is applied to rows --- erpnext/selling/doctype/sales_order/sales_order.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 203b840db9..f162291b7c 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -669,6 +669,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( let pending_qty = (flt(d.stock_qty) - flt(d.ordered_qty)) / flt(d.conversion_factor); if (pending_qty > 0) { po_items.push({ + "doctype": "Sales Order Item", "name": d.name, "item_name": d.item_name, "item_code": d.item_code, From 421348a5f2c674cb977dcf96ceab42ada2386733 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 5 Nov 2020 15:35:48 +0530 Subject: [PATCH 3/6] fix: not able to select assign to --- erpnext/assets/doctype/asset_maintenance/asset_maintenance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py index 60c528bcc4..a506deec93 100644 --- a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py +++ b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py @@ -108,7 +108,7 @@ def update_maintenance_log(asset_maintenance, item_code, item_name, task): @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs def get_team_members(doctype, txt, searchfield, start, page_len, filters): - return frappe.db.get_values('Maintenance Team Member', { 'parent': filters.get("maintenance_team") }) + return frappe.db.get_values('Maintenance Team Member', { 'parent': filters.get("maintenance_team") }, "team_member") @frappe.whitelist() def get_maintenance_log(asset_name): From 19df4534f50751f91577f8ec3fab56fad5892360 Mon Sep 17 00:00:00 2001 From: Saqib Date: Thu, 5 Nov 2020 16:37:40 +0530 Subject: [PATCH 4/6] fix: asset finance book depreciation posting date fix (#23833) --- .../doctype/asset_finance_book/asset_finance_book.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json b/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json index d422876047..d9b7b695f7 100644 --- a/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json +++ b/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json @@ -50,13 +50,11 @@ "reqd": 1 }, { - "depends_on": "eval:parent.doctype == 'Asset'", "fieldname": "depreciation_start_date", "fieldtype": "Date", "in_list_view": 1, "label": "Depreciation Posting Date", - "mandatory_depends_on": "eval:parent.doctype == 'Asset'", - "reqd": 1 + "mandatory_depends_on": "eval:parent.doctype == 'Asset'" }, { "default": "0", @@ -87,7 +85,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2020-10-30 15:22:29.119868", + "modified": "2020-11-05 16:30:09.213479", "modified_by": "Administrator", "module": "Assets", "name": "Asset Finance Book", From bc919e2e7db2571ade74594473835b01c6a7a6b9 Mon Sep 17 00:00:00 2001 From: Saqib Date: Thu, 5 Nov 2020 17:38:35 +0530 Subject: [PATCH 5/6] fix: cannot expand row in update items dialog (#23839) --- erpnext/public/js/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index ea2093eee1..891bbe5b59 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -539,7 +539,7 @@ erpnext.utils.update_child_items = function(opts) { fieldtype: "Table", label: "Items", cannot_add_rows: cannot_add_row, - in_place_edit: true, + in_place_edit: false, reqd: 1, data: this.data, get_data: () => { From 3a9dc90695033828a6d24d61eb6b1106fc9f9689 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Thu, 5 Nov 2020 18:51:56 +0530 Subject: [PATCH 6/6] fix: fix: replaced formatdate -> format_date (#23829) --- .../journal_auditing_voucher/journal_auditing_voucher.html | 2 +- .../payment_receipt_voucher/payment_receipt_voucher.html | 2 +- .../purchase_auditing_voucher/purchase_auditing_voucher.html | 4 ++-- .../sales_auditing_voucher/sales_auditing_voucher.html | 4 ++-- erpnext/templates/pages/material_request_info.html | 2 +- erpnext/templates/pages/order.html | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html b/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html index 1351517981..0ca940f8bd 100644 --- a/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html +++ b/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html @@ -17,7 +17,7 @@
- +
Date: {{ frappe.utils.formatdate(doc.creation) }}
Date: {{ frappe.utils.format_date(doc.creation) }}
diff --git a/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.html b/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.html index f2e65d3334..283d505e3b 100644 --- a/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.html +++ b/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.html @@ -5,7 +5,7 @@ {{ add_header(0, 1, doc, letter_head, no_letterhead, print_settings) }} {%- for label, value in ( - (_("Received On"), frappe.utils.formatdate(doc.voucher_date)), + (_("Received On"), frappe.utils.format_date(doc.voucher_date)), (_("Received From"), doc.pay_to_recd_from), (_("Amount"), "" + doc.get_formatted("total_amount") + "
" + (doc.total_amount_in_words or "") + "
"), (_("Remarks"), doc.remark) diff --git a/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html b/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html index a7c3bce0b4..043ac254ed 100644 --- a/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html +++ b/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html @@ -8,7 +8,7 @@
- + @@ -17,7 +17,7 @@
Supplier Name: {{ doc.supplier }}
Due Date: {{ frappe.utils.formatdate(doc.due_date) }}
Due Date: {{ frappe.utils.format_date(doc.due_date) }}
Address: {{doc.address_display}}
Contact: {{doc.contact_display}}
Mobile no: {{doc.contact_mobile}}
- +
Voucher No: {{ doc.name }}
Date: {{ frappe.utils.formatdate(doc.creation) }}
Date: {{ frappe.utils.format_date(doc.creation) }}
diff --git a/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html b/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html index ef4ada14a3..a53b593a72 100644 --- a/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html +++ b/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html @@ -8,7 +8,7 @@
- + @@ -17,7 +17,7 @@
Customer Name: {{ doc.customer }}
Due Date: {{ frappe.utils.formatdate(doc.due_date) }}
Due Date: {{ frappe.utils.format_date(doc.due_date) }}
Address: {{doc.address_display}}
Contact: {{doc.contact_display}}
Mobile no: {{doc.contact_mobile}}
- +
Voucher No: {{ doc.name }}
Date: {{ frappe.utils.formatdate(doc.creation) }}
Date: {{ frappe.utils.format_date(doc.creation) }}
diff --git a/erpnext/templates/pages/material_request_info.html b/erpnext/templates/pages/material_request_info.html index 9d189895b6..c7a78027b1 100644 --- a/erpnext/templates/pages/material_request_info.html +++ b/erpnext/templates/pages/material_request_info.html @@ -25,7 +25,7 @@
- {{ frappe.utils.formatdate(doc.transaction_date, 'medium') }} + {{ frappe.utils.format_date(doc.transaction_date, 'medium') }}
diff --git a/erpnext/templates/pages/order.html b/erpnext/templates/pages/order.html index 01b5f6df6c..af7af11677 100644 --- a/erpnext/templates/pages/order.html +++ b/erpnext/templates/pages/order.html @@ -42,10 +42,10 @@
- {{ frappe.utils.formatdate(doc.transaction_date, 'medium') }} + {{ frappe.utils.format_date(doc.transaction_date, 'medium') }} {% if doc.valid_till %}

- {{ _("Valid Till") }}: {{ frappe.utils.formatdate(doc.valid_till, 'medium') }} + {{ _("Valid Till") }}: {{ frappe.utils.format_date(doc.valid_till, 'medium') }}

{% endif %}