feat: (get_items_from) filter material request item in purchase order (#27449)
This commit is contained in:
parent
d743c41b54
commit
7292f5476d
@ -425,7 +425,10 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
||||
status: ["!=", "Stopped"],
|
||||
per_ordered: ["<", 100],
|
||||
company: me.frm.doc.company
|
||||
}
|
||||
},
|
||||
allow_child_item_selection: true,
|
||||
child_fielname: "items",
|
||||
child_columns: ["item_code", "qty"]
|
||||
})
|
||||
}, __("Get Items From"));
|
||||
|
||||
|
@ -709,6 +709,9 @@ erpnext.utils.map_current_doc = function(opts) {
|
||||
setters: opts.setters,
|
||||
get_query: opts.get_query,
|
||||
add_filters_group: 1,
|
||||
allow_child_item_selection: opts.allow_child_item_selection,
|
||||
child_fieldname: opts.child_fielname,
|
||||
child_columns: opts.child_columns,
|
||||
action: function(selections, args) {
|
||||
let values = selections;
|
||||
if(values.length === 0){
|
||||
@ -716,7 +719,7 @@ erpnext.utils.map_current_doc = function(opts) {
|
||||
return;
|
||||
}
|
||||
opts.source_name = values;
|
||||
opts.setters = args;
|
||||
opts.args = args;
|
||||
d.dialog.hide();
|
||||
_map();
|
||||
},
|
||||
|
@ -6,10 +6,13 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
|
||||
import frappe
|
||||
from frappe import _, msgprint
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from frappe.utils import cstr, flt, get_link_to_form, getdate, new_line_sep, nowdate
|
||||
from six import string_types
|
||||
|
||||
from erpnext.buying.utils import check_on_hold_or_closed_status, validate_for_items
|
||||
from erpnext.controllers.buying_controller import BuyingController
|
||||
@ -269,7 +272,10 @@ def update_status(name, status):
|
||||
material_request.update_status(status)
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_purchase_order(source_name, target_doc=None):
|
||||
def make_purchase_order(source_name, target_doc=None, args={}):
|
||||
|
||||
if isinstance(args, string_types):
|
||||
args = json.loads(args)
|
||||
|
||||
def postprocess(source, target_doc):
|
||||
if frappe.flags.args and frappe.flags.args.default_supplier:
|
||||
@ -284,7 +290,10 @@ def make_purchase_order(source_name, target_doc=None):
|
||||
set_missing_values(source, target_doc)
|
||||
|
||||
def select_item(d):
|
||||
return d.ordered_qty < d.stock_qty
|
||||
filtered_items = args.get('filtered_children', [])
|
||||
child_filter = d.name in filtered_items if filtered_items else True
|
||||
|
||||
return d.ordered_qty < d.stock_qty and child_filter
|
||||
|
||||
doclist = get_mapped_doc("Material Request", source_name, {
|
||||
"Material Request": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user