From ed8c31e4adae667a8a0b7f4b162bac732fb2f74c Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Thu, 19 Feb 2026 15:23:32 +0400 Subject: [PATCH] feat: extend SelectionDialog to 11 additional DocTypes - Add child_doctype, items_field, has_rate, warehouse_field_name, price_list_type, price_list_field constructor options to SelectionDialog - No-rate mode hides price column, price list filter, discount and total in cart (Material Request, Stock Entry, Pick List, Request for Quotation) - Stock Entry uses s_warehouse field; Pick List uses locations child table - Buying documents (Purchase Order/Invoice, Supplier Quotation, Purchase Receipt) now use buying price list filter and buying_price_list field - api.py: add skip_price param to skip price enrichment for no-rate docs - hooks.py: register 11 new doctype JS integrations Co-Authored-By: Claude Sonnet 4.5 --- selections/api.py | 8 +-- selections/hooks.py | 13 ++++- selections/public/css/selection_dialog.css | 8 +++ selections/public/js/delivery_note.js | 41 +++++++++++++++ selections/public/js/material_request.js | 32 ++++++++++++ selections/public/js/pick_list.js | 33 ++++++++++++ selections/public/js/purchase_invoice.js | 42 +++++++++++++++ selections/public/js/purchase_order.js | 42 +++++++++++++++ selections/public/js/purchase_receipt.js | 42 +++++++++++++++ selections/public/js/quotation.js | 41 +++++++++++++++ selections/public/js/request_for_quotation.js | 32 ++++++++++++ selections/public/js/sales_invoice.js | 3 +- selections/public/js/sales_order.js | 41 +++++++++++++++ selections/public/js/selection_dialog.js | 51 +++++++++++-------- selections/public/js/stock_entry.js | 33 ++++++++++++ selections/public/js/supplier_quotation.js | 42 +++++++++++++++ 16 files changed, 479 insertions(+), 25 deletions(-) create mode 100644 selections/public/js/delivery_note.js create mode 100644 selections/public/js/material_request.js create mode 100644 selections/public/js/pick_list.js create mode 100644 selections/public/js/purchase_invoice.js create mode 100644 selections/public/js/purchase_order.js create mode 100644 selections/public/js/purchase_receipt.js create mode 100644 selections/public/js/quotation.js create mode 100644 selections/public/js/request_for_quotation.js create mode 100644 selections/public/js/sales_order.js create mode 100644 selections/public/js/stock_entry.js create mode 100644 selections/public/js/supplier_quotation.js diff --git a/selections/api.py b/selections/api.py index 8493c2f..4df0ea0 100644 --- a/selections/api.py +++ b/selections/api.py @@ -11,7 +11,7 @@ from erpnext.stock.get_item_details import get_item_details @frappe.whitelist() -def get_items_for_selection(filters=None, start=0, page_length=50, custom_filters=None): +def get_items_for_selection(filters=None, start=0, page_length=50, custom_filters=None, skip_price=0): """ Получить список товаров с остатками и ценами для формы подбора @@ -33,6 +33,8 @@ def get_items_for_selection(filters=None, start=0, page_length=50, custom_filter if isinstance(custom_filters, str): custom_filters = frappe.parse_json(custom_filters) + skip_price = flt(skip_price) + if not filters: filters = {} @@ -166,7 +168,7 @@ def get_items_for_selection(filters=None, start=0, page_length=50, custom_filter }) # Цены - if price_list and company: + if not skip_price and price_list and company: price_data = get_price_data( item.item_code, warehouse=warehouse, @@ -180,7 +182,7 @@ def get_items_for_selection(filters=None, start=0, page_length=50, custom_filter item_dict.update({ 'price_list_rate': 0.0, 'rate': 0.0, - 'currency': frappe.defaults.get_global_default('currency') or 'USD' + 'currency': '' if skip_price else (frappe.defaults.get_global_default('currency') or 'USD') }) result_items.append(item_dict) diff --git a/selections/hooks.py b/selections/hooks.py index f16e1d4..60fbcd7 100644 --- a/selections/hooks.py +++ b/selections/hooks.py @@ -44,7 +44,18 @@ app_include_js = "/assets/selections/js/selection_dialog.js" # include js in doctype views doctype_js = { - "Sales Invoice": "public/js/sales_invoice.js" + "Sales Invoice": "public/js/sales_invoice.js", + "Sales Order": "public/js/sales_order.js", + "Quotation": "public/js/quotation.js", + "Purchase Order": "public/js/purchase_order.js", + "Purchase Invoice": "public/js/purchase_invoice.js", + "Supplier Quotation": "public/js/supplier_quotation.js", + "Request for Quotation": "public/js/request_for_quotation.js", + "Delivery Note": "public/js/delivery_note.js", + "Purchase Receipt": "public/js/purchase_receipt.js", + "Material Request": "public/js/material_request.js", + "Stock Entry": "public/js/stock_entry.js", + "Pick List": "public/js/pick_list.js", } # doctype_list_js = {"doctype" : "public/js/doctype_list.js"} # doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"} diff --git a/selections/public/css/selection_dialog.css b/selections/public/css/selection_dialog.css index 7ebb45a..1783a51 100644 --- a/selections/public/css/selection_dialog.css +++ b/selections/public/css/selection_dialog.css @@ -853,3 +853,11 @@ body.selection-resizing * { .selection-filters::-webkit-scrollbar-thumb:hover { background: var(--text-color); } + +/* No-rate mode: hide price-related elements */ +.selection-no-rate #selection-pricelist-link, +.selection-no-rate label[for="selection-pricelist-link"], +.selection-no-rate .cart-item-discount, +.selection-no-rate .cart-total, +.selection-no-rate .cart-item-price, +.selection-no-rate .line-through { display: none !important; } diff --git a/selections/public/js/delivery_note.js b/selections/public/js/delivery_note.js new file mode 100644 index 0000000..d980794 --- /dev/null +++ b/selections/public/js/delivery_note.js @@ -0,0 +1,41 @@ +/** + * Интеграция формы подбора с Delivery Note + */ + +frappe.ui.form.on('Delivery Note', { + refresh: function(frm) { + if (frm.doc.docstatus === 0) { + setup_selection_button(frm); + } + } +}); + +function setup_selection_button(frm) { + const grid = frm.fields_dict.items.grid; + + grid.wrapper.find('.grid-add-multiple-rows').remove(); + + $('