Merge pull request #4355 from nabinhait/items_from_product_bundle
Get Items from Product Bundle button in purchase cycle
This commit is contained in:
commit
17e9b9444d
@ -625,6 +625,29 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "get_items_from_product_bundle",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Get Items from Product Bundle",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -2364,7 +2387,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2015-11-16 06:29:52.962561",
|
"modified": "2015-11-23 10:09:18.620977",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice",
|
"name": "Purchase Invoice",
|
||||||
|
@ -157,6 +157,10 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
},
|
},
|
||||||
add_deduct_tax: function(doc, cdt, cdn) {
|
add_deduct_tax: function(doc, cdt, cdn) {
|
||||||
this.calculate_taxes_and_totals();
|
this.calculate_taxes_and_totals();
|
||||||
|
},
|
||||||
|
|
||||||
|
get_items_from_product_bundle: function() {
|
||||||
|
erpnext.buying.get_items_from_product_bundle(this.frm)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -180,3 +184,78 @@ erpnext.buying.get_default_bom = function(frm) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
erpnext.buying.get_items_from_product_bundle = function(frm) {
|
||||||
|
var dialog = new frappe.ui.Dialog({
|
||||||
|
title: __("Get Items from Product Bundle"),
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": __("Product Bundle"),
|
||||||
|
"fieldname": "product_bundle",
|
||||||
|
"options":"Product Bundle",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": __("Quantity"),
|
||||||
|
"fieldname": "quantity",
|
||||||
|
"reqd": 1,
|
||||||
|
"default": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": __("Get Items"),
|
||||||
|
"fieldname": "get_items",
|
||||||
|
"cssClass": "btn-primary"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.fields_dict.get_items.$input.click(function() {
|
||||||
|
args = dialog.get_values();
|
||||||
|
if(!args) return;
|
||||||
|
dialog.hide();
|
||||||
|
return frappe.call({
|
||||||
|
type: "GET",
|
||||||
|
method: "erpnext.stock.doctype.packed_item.packed_item.get_items_from_product_bundle",
|
||||||
|
args: {
|
||||||
|
args: {
|
||||||
|
item_code: args.product_bundle,
|
||||||
|
quantity: args.quantity,
|
||||||
|
parenttype: frm.doc.doctype,
|
||||||
|
parent: frm.doc.name,
|
||||||
|
supplier: frm.doc.supplier,
|
||||||
|
currency: frm.doc.currency,
|
||||||
|
conversion_rate: frm.doc.conversion_rate,
|
||||||
|
price_list: frm.doc.buying_price_list,
|
||||||
|
price_list_currency: frm.doc.price_list_currency,
|
||||||
|
plc_conversion_rate: frm.doc.plc_conversion_rate,
|
||||||
|
company: frm.doc.company,
|
||||||
|
is_subcontracted: frm.doc.is_subcontracted,
|
||||||
|
transaction_date: frm.doc.transaction_date || frm.doc.posting_date,
|
||||||
|
ignore_pricing_rule: frm.doc.ignore_pricing_rule
|
||||||
|
}
|
||||||
|
},
|
||||||
|
freeze: true,
|
||||||
|
callback: function(r) {
|
||||||
|
if(!r.exc && r.message) {
|
||||||
|
for ( var i=0; i< r.message.length; i++ ) {
|
||||||
|
var d = frm.add_child("items");
|
||||||
|
var item = r.message[i];
|
||||||
|
for ( var key in item) {
|
||||||
|
if ( !is_null(item[key]) ) {
|
||||||
|
d[key] = item[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(frappe.meta.get_docfield(d.doctype, "price_list_rate", d.name)) {
|
||||||
|
frm.script_manager.trigger("price_list_rate", d.doctype, d.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frm.refresh_field("items");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
@ -188,15 +188,19 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
stop_purchase_order: function(){
|
stop_purchase_order: function(){
|
||||||
cur_frm.cscript.update_status('Stop', 'Stopped')
|
cur_frm.cscript.update_status('Stop', 'Stopped')
|
||||||
},
|
},
|
||||||
|
|
||||||
unstop_purchase_order: function(){
|
unstop_purchase_order: function(){
|
||||||
cur_frm.cscript.update_status('Re-open', 'Submitted')
|
cur_frm.cscript.update_status('Re-open', 'Submitted')
|
||||||
},
|
},
|
||||||
|
|
||||||
close_purchase_order: function(){
|
close_purchase_order: function(){
|
||||||
cur_frm.cscript.update_status('Close', 'Closed')
|
cur_frm.cscript.update_status('Close', 'Closed')
|
||||||
},
|
},
|
||||||
|
|
||||||
delivered_by_supplier: function(){
|
delivered_by_supplier: function(){
|
||||||
cur_frm.cscript.update_status('Deliver', 'Delivered')
|
cur_frm.cscript.update_status('Deliver', 'Delivered')
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -555,6 +555,29 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "get_items_from_product_bundle",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Get Items from Product Bundle",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -1622,7 +1645,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2015-11-16 06:29:58.617934",
|
"modified": "2015-11-23 10:28:06.637629",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Supplier Quotation",
|
"name": "Supplier Quotation",
|
||||||
|
@ -228,6 +228,29 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "get_items_from_product_bundle",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Get Items from Product Bundle",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -532,7 +555,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2015-11-16 06:29:50.143668",
|
"modified": "2015-11-23 10:24:21.882513",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Material Request",
|
"name": "Material Request",
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe, json
|
||||||
from frappe.utils import cstr, flt
|
from frappe.utils import cstr, flt
|
||||||
|
from erpnext.stock.get_item_details import get_item_details
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
@ -89,3 +89,17 @@ def cleanup_packing_list(doc, parent_items):
|
|||||||
for d in packed_items:
|
for d in packed_items:
|
||||||
if d not in delete_list:
|
if d not in delete_list:
|
||||||
doc.append("packed_items", d)
|
doc.append("packed_items", d)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_items_from_product_bundle(args):
|
||||||
|
args = json.loads(args)
|
||||||
|
items = []
|
||||||
|
bundled_items = get_product_bundle_items(args["item_code"])
|
||||||
|
for item in bundled_items:
|
||||||
|
args.update({
|
||||||
|
"item_code": item.item_code,
|
||||||
|
"qty": flt(args["quantity"]) * flt(item.qty)
|
||||||
|
})
|
||||||
|
items.append(get_item_details(args))
|
||||||
|
|
||||||
|
return items
|
@ -633,6 +633,29 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "get_items_from_product_bundle",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Get Items from Product Bundle",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -2165,7 +2188,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2015-11-16 06:29:54.102760",
|
"modified": "2015-11-23 10:08:53.836249",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Purchase Receipt",
|
"name": "Purchase Receipt",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user