Browse Source

Merge pull request #4355 from nabinhait/items_from_product_bundle

Get Items from Product Bundle button in purchase cycle
develop
Anand Doshi 9 years ago
parent
commit
17e9b9444d
  1. 25
      erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
  2. 79
      erpnext/buying/doctype/purchase_common/purchase_common.js
  3. 4
      erpnext/buying/doctype/purchase_order/purchase_order.js
  4. 4989
      erpnext/buying/doctype/purchase_order/purchase_order.json
  5. 25
      erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
  6. 25
      erpnext/stock/doctype/material_request/material_request.json
  7. 18
      erpnext/stock/doctype/packed_item/packed_item.py
  8. 25
      erpnext/stock/doctype/purchase_receipt/purchase_receipt.json

25
erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json

@ -625,6 +625,29 @@
"set_only_once": 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,
"bold": 0,
@ -2364,7 +2387,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2015-11-16 06:29:52.962561",
"modified": "2015-11-23 10:09:18.620977",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice",

79
erpnext/buying/doctype/purchase_common/purchase_common.js

@ -157,6 +157,10 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
},
add_deduct_tax: function(doc, cdt, cdn) {
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();
}

4
erpnext/buying/doctype/purchase_order/purchase_order.js

@ -188,15 +188,19 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
}
});
},
stop_purchase_order: function(){
cur_frm.cscript.update_status('Stop', 'Stopped')
},
unstop_purchase_order: function(){
cur_frm.cscript.update_status('Re-open', 'Submitted')
},
close_purchase_order: function(){
cur_frm.cscript.update_status('Close', 'Closed')
},
delivered_by_supplier: function(){
cur_frm.cscript.update_status('Deliver', 'Delivered')
}

4989
erpnext/buying/doctype/purchase_order/purchase_order.json

File diff suppressed because it is too large

25
erpnext/buying/doctype/supplier_quotation/supplier_quotation.json

@ -555,6 +555,29 @@
"set_only_once": 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,
"bold": 0,
@ -1622,7 +1645,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2015-11-16 06:29:58.617934",
"modified": "2015-11-23 10:28:06.637629",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier Quotation",

25
erpnext/stock/doctype/material_request/material_request.json

@ -228,6 +228,29 @@
"set_only_once": 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,
"bold": 0,
@ -532,7 +555,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2015-11-16 06:29:50.143668",
"modified": "2015-11-23 10:24:21.882513",
"modified_by": "Administrator",
"module": "Stock",
"name": "Material Request",

18
erpnext/stock/doctype/packed_item/packed_item.py

@ -4,9 +4,9 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
import frappe, json
from frappe.utils import cstr, flt
from erpnext.stock.get_item_details import get_item_details
from frappe.model.document import Document
@ -89,3 +89,17 @@ def cleanup_packing_list(doc, parent_items):
for d in packed_items:
if d not in delete_list:
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

25
erpnext/stock/doctype/purchase_receipt/purchase_receipt.json

@ -633,6 +633,29 @@
"set_only_once": 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,
"bold": 0,
@ -2165,7 +2188,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2015-11-16 06:29:54.102760",
"modified": "2015-11-23 10:08:53.836249",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt",

Loading…
Cancel
Save