[subcontract] refactor, make stock entry from PO
This commit is contained in:
parent
49ecbd7353
commit
e693f794f5
@ -8,7 +8,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "supplier_section",
|
"fieldname": "supplier_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Supplier",
|
"label": "",
|
||||||
"options": "icon-user",
|
"options": "icon-user",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@ -315,7 +315,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "taxes_section",
|
"fieldname": "taxes_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Taxes and Charges",
|
"label": "",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"options": "icon-money",
|
"options": "icon-money",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@ -655,7 +655,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "terms_section_break",
|
"fieldname": "terms_section_break",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Terms and Conditions",
|
"label": "",
|
||||||
"options": "icon-legal",
|
"options": "icon-legal",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@ -710,7 +710,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "more_info",
|
"fieldname": "more_info",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "More Info",
|
"label": "",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"options": "icon-file-text",
|
"options": "icon-file-text",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@ -963,7 +963,7 @@
|
|||||||
"icon": "icon-file-text",
|
"icon": "icon-file-text",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-24 15:59:49.908324",
|
"modified": "2015-03-03 02:46:30.118418",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice",
|
"name": "Purchase Invoice",
|
||||||
|
@ -749,7 +749,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "terms_section_break",
|
"fieldname": "terms_section_break",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Terms and Conditions",
|
"label": "",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"options": "icon-legal",
|
"options": "icon-legal",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@ -780,7 +780,7 @@
|
|||||||
"fieldname": "contact_section",
|
"fieldname": "contact_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"label": "Contact Info",
|
"label": "",
|
||||||
"options": "icon-bullhorn",
|
"options": "icon-bullhorn",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 0
|
"read_only": 0
|
||||||
@ -1244,7 +1244,7 @@
|
|||||||
"icon": "icon-file-text",
|
"icon": "icon-file-text",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-24 15:23:28.554373",
|
"modified": "2015-03-03 02:47:05.467179",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice",
|
"name": "Sales Invoice",
|
||||||
|
@ -7,6 +7,7 @@ frappe.provide("erpnext.buying");
|
|||||||
|
|
||||||
erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
|
erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
|
||||||
refresh: function(doc, cdt, cdn) {
|
refresh: function(doc, cdt, cdn) {
|
||||||
|
var me = this;
|
||||||
this._super();
|
this._super();
|
||||||
// this.frm.dashboard.reset();
|
// this.frm.dashboard.reset();
|
||||||
|
|
||||||
@ -16,9 +17,14 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
// cur_frm.dashboard.add_progress(cint(doc.per_billed) + __("% Billed"),
|
// cur_frm.dashboard.add_progress(cint(doc.per_billed) + __("% Billed"),
|
||||||
// doc.per_billed);
|
// doc.per_billed);
|
||||||
|
|
||||||
if(flt(doc.per_received, 2) < 100)
|
if(flt(doc.per_received, 2) < 100) {
|
||||||
cur_frm.add_custom_button(__('Make Purchase Receipt'),
|
cur_frm.add_custom_button(__('Make Purchase Receipt'),
|
||||||
this.make_purchase_receipt, frappe.boot.doctype_icons["Purchase Receipt"]);
|
this.make_purchase_receipt);
|
||||||
|
if(doc.is_subcontracted==="Yes") {
|
||||||
|
cur_frm.add_custom_button(__('Transfer Material to Supplier'),
|
||||||
|
function() { me.make_stock_entry() });
|
||||||
|
}
|
||||||
|
}
|
||||||
if(flt(doc.per_billed, 2) < 100)
|
if(flt(doc.per_billed, 2) < 100)
|
||||||
cur_frm.add_custom_button(__('Make Invoice'), this.make_purchase_invoice,
|
cur_frm.add_custom_button(__('Make Invoice'), this.make_purchase_invoice,
|
||||||
frappe.boot.doctype_icons["Purchase Invoice"]);
|
frappe.boot.doctype_icons["Purchase Invoice"]);
|
||||||
@ -35,6 +41,33 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
cur_frm.cscript['Unstop Purchase Order'], "icon-check");
|
cur_frm.cscript['Unstop Purchase Order'], "icon-check");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
make_stock_entry: function() {
|
||||||
|
var items = $.map(cur_frm.doc.items, function(d) { return d.bom ? d.item_code : false; }),
|
||||||
|
me = this;
|
||||||
|
if(items.length===1) {
|
||||||
|
me._make_stock_entry(items[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
frappe.prompt({fieldname:"item", options: items, fieldtype:"Select",
|
||||||
|
label: __("Select Item for Transfer"), reqd: 1}, function(data) {
|
||||||
|
me._make_stock_entry(data.item);
|
||||||
|
}, __("Select Item"), __("Make"));
|
||||||
|
},
|
||||||
|
|
||||||
|
_make_stock_entry: function(item) {
|
||||||
|
frappe.call({
|
||||||
|
method:"erpnext.buying.doctype.purchase_order.purchase_order.make_stock_entry",
|
||||||
|
args: {
|
||||||
|
purchase_order: cur_frm.doc.name,
|
||||||
|
item_code: item
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
var doclist = frappe.model.sync(r.message);
|
||||||
|
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
make_purchase_receipt: function() {
|
make_purchase_receipt: function() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "supplier_section",
|
"fieldname": "supplier_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Supplier",
|
"label": "",
|
||||||
"options": "icon-user",
|
"options": "icon-user",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@ -39,6 +39,15 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"default": "No",
|
||||||
|
"fieldname": "is_subcontracted",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Supply Raw Materials",
|
||||||
|
"options": "No\nYes",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "supplier_name",
|
"fieldname": "supplier_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
@ -290,7 +299,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "taxes_section",
|
"fieldname": "taxes_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Taxes and Charges",
|
"label": "",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"options": "icon-money",
|
"options": "icon-money",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@ -540,7 +549,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "terms_section_break",
|
"fieldname": "terms_section_break",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Terms and Conditions",
|
"label": "",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"options": "icon-legal",
|
"options": "icon-legal",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
@ -567,7 +576,7 @@
|
|||||||
"depends_on": "supplier",
|
"depends_on": "supplier",
|
||||||
"fieldname": "contact_section",
|
"fieldname": "contact_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Contact Info",
|
"label": "",
|
||||||
"options": "icon-bullhorn",
|
"options": "icon-bullhorn",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@ -597,7 +606,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "more_info",
|
"fieldname": "more_info",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "More Info",
|
"label": "",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@ -617,13 +626,18 @@
|
|||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "No",
|
"fieldname": "fiscal_year",
|
||||||
"fieldname": "is_subcontracted",
|
"fieldtype": "Link",
|
||||||
"fieldtype": "Select",
|
"in_filter": 1,
|
||||||
"label": "Is Subcontracted",
|
"label": "Fiscal Year",
|
||||||
"options": "\nYes\nNo",
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "fiscal_year",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "Fiscal Year",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1
|
"print_hide": 1,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "ref_sq",
|
"fieldname": "ref_sq",
|
||||||
@ -637,6 +651,15 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break5",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"oldfieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"print_width": "50%",
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"fieldname": "letter_head",
|
"fieldname": "letter_head",
|
||||||
@ -648,20 +671,6 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1
|
"print_hide": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "fiscal_year",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Fiscal Year",
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "fiscal_year",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "Fiscal Year",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"fieldname": "select_print_heading",
|
"fieldname": "select_print_heading",
|
||||||
@ -676,13 +685,11 @@
|
|||||||
"report_hide": 1
|
"report_hide": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break5",
|
"fieldname": "sub_contracting",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Section Break",
|
||||||
"oldfieldtype": "Column Break",
|
"label": "",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"precision": ""
|
||||||
"print_width": "50%",
|
|
||||||
"width": "50%"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:!doc.__islocal",
|
"depends_on": "eval:!doc.__islocal",
|
||||||
@ -698,6 +705,12 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_74",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:!doc.__islocal",
|
"depends_on": "eval:!doc.__islocal",
|
||||||
"description": "% of materials billed against this Purchase Order.",
|
"description": "% of materials billed against this Purchase Order.",
|
||||||
@ -738,7 +751,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "recurring_order",
|
"fieldname": "recurring_order",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Recurring Order",
|
"label": "Recurring",
|
||||||
"options": "icon-time",
|
"options": "icon-time",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@ -857,7 +870,7 @@
|
|||||||
"icon": "icon-file-text",
|
"icon": "icon-file-text",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-24 16:00:36.892356",
|
"modified": "2015-03-03 01:58:41.152545",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order",
|
"name": "Purchase Order",
|
||||||
|
@ -291,3 +291,21 @@ def make_purchase_invoice(source_name, target_doc=None):
|
|||||||
}, target_doc, postprocess)
|
}, target_doc, postprocess)
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def make_stock_entry(purchase_order, item_code):
|
||||||
|
purchase_order = frappe.get_doc("Purchase Order", purchase_order)
|
||||||
|
|
||||||
|
stock_entry = frappe.new_doc("Stock Entry")
|
||||||
|
stock_entry.purpose = "Subcontract"
|
||||||
|
stock_entry.purchase_order = purchase_order.name
|
||||||
|
stock_entry.supplier = purchase_order.supplier
|
||||||
|
stock_entry.supplier_name = purchase_order.supplier_name
|
||||||
|
stock_entry.supplier_address = purchase_order.address_display
|
||||||
|
stock_entry.company = purchase_order.company
|
||||||
|
stock_entry.from_bom = 1
|
||||||
|
po_item = [d for d in purchase_order.items if d.item_code == item_code][0]
|
||||||
|
stock_entry.fg_completed_qty = po_item.qty
|
||||||
|
stock_entry.bom_no = po_item.bom
|
||||||
|
stock_entry.get_items()
|
||||||
|
return stock_entry.as_dict()
|
||||||
|
@ -1,31 +1,8 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-02-22 01:27:42.000000",
|
"creation": "2013-02-22 01:27:42",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
|
||||||
"fieldname": "reference_name",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Reference Name",
|
|
||||||
"oldfieldname": "reference_name",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"permlevel": 0,
|
|
||||||
"read_only": 1,
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "bom_detail_no",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "BOM Detail No",
|
|
||||||
"oldfieldname": "bom_detail_no",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"permlevel": 0,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "main_item_code",
|
"fieldname": "main_item_code",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
@ -50,7 +27,7 @@
|
|||||||
"fieldname": "required_qty",
|
"fieldname": "required_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Required Qty",
|
"label": "Supplied Qty",
|
||||||
"oldfieldname": "required_qty",
|
"oldfieldname": "required_qty",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@ -76,6 +53,29 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "bom_detail_no",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "BOM Detail No",
|
||||||
|
"oldfieldname": "bom_detail_no",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "reference_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Reference Name",
|
||||||
|
"oldfieldname": "reference_name",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "conversion_factor",
|
"fieldname": "conversion_factor",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
@ -100,9 +100,10 @@
|
|||||||
"hide_toolbar": 1,
|
"hide_toolbar": 1,
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2013-12-20 19:23:33.000000",
|
"modified": "2015-03-03 03:40:45.982762",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order Item Supplied",
|
"name": "Purchase Order Item Supplied",
|
||||||
"owner": "dhanalekshmi@webnotestech.com"
|
"owner": "dhanalekshmi@webnotestech.com",
|
||||||
|
"permissions": []
|
||||||
}
|
}
|
@ -149,12 +149,11 @@ class BuyingController(StockController):
|
|||||||
def create_raw_materials_supplied(self, raw_material_table):
|
def create_raw_materials_supplied(self, raw_material_table):
|
||||||
if self.is_subcontracted=="Yes":
|
if self.is_subcontracted=="Yes":
|
||||||
parent_items = []
|
parent_items = []
|
||||||
rm_supplied_idx = 0
|
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if self.doctype == "Purchase Receipt":
|
if self.doctype == "Purchase Receipt":
|
||||||
item.rm_supp_cost = 0.0
|
item.rm_supp_cost = 0.0
|
||||||
if item.item_code in self.sub_contracted_items:
|
if item.item_code in self.sub_contracted_items:
|
||||||
self.update_raw_materials_supplied(item, raw_material_table, rm_supplied_idx)
|
self.update_raw_materials_supplied(item, raw_material_table)
|
||||||
|
|
||||||
if [item.item_code, item.name] not in parent_items:
|
if [item.item_code, item.name] not in parent_items:
|
||||||
parent_items.append([item.item_code, item.name])
|
parent_items.append([item.item_code, item.name])
|
||||||
@ -165,7 +164,7 @@ class BuyingController(StockController):
|
|||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
item.rm_supp_cost = 0.0
|
item.rm_supp_cost = 0.0
|
||||||
|
|
||||||
def update_raw_materials_supplied(self, item, raw_material_table, rm_supplied_idx):
|
def update_raw_materials_supplied(self, item, raw_material_table):
|
||||||
bom_items = self.get_items_from_bom(item.item_code, item.bom)
|
bom_items = self.get_items_from_bom(item.item_code, item.bom)
|
||||||
raw_materials_cost = 0
|
raw_materials_cost = 0
|
||||||
|
|
||||||
@ -190,7 +189,6 @@ class BuyingController(StockController):
|
|||||||
rm.required_qty = required_qty
|
rm.required_qty = required_qty
|
||||||
|
|
||||||
rm.conversion_factor = item.conversion_factor
|
rm.conversion_factor = item.conversion_factor
|
||||||
rm.idx = rm_supplied_idx
|
|
||||||
|
|
||||||
if self.doctype == "Purchase Receipt":
|
if self.doctype == "Purchase Receipt":
|
||||||
rm.consumed_qty = required_qty
|
rm.consumed_qty = required_qty
|
||||||
@ -198,8 +196,6 @@ class BuyingController(StockController):
|
|||||||
if item.batch_no and not rm.batch_no:
|
if item.batch_no and not rm.batch_no:
|
||||||
rm.batch_no = item.batch_no
|
rm.batch_no = item.batch_no
|
||||||
|
|
||||||
rm_supplied_idx += 1
|
|
||||||
|
|
||||||
# get raw materials rate
|
# get raw materials rate
|
||||||
if self.doctype == "Purchase Receipt":
|
if self.doctype == "Purchase Receipt":
|
||||||
from erpnext.stock.utils import get_incoming_rate
|
from erpnext.stock.utils import get_incoming_rate
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
"fieldname": "price_list",
|
"fieldname": "price_list",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Price List",
|
"label": "Price List",
|
||||||
"options": "Price List",
|
"options": "Price List",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@ -26,7 +27,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "buying",
|
"fieldname": "buying",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"in_list_view": 1,
|
"in_list_view": 0,
|
||||||
"label": "Buying",
|
"label": "Buying",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
@ -34,7 +35,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "selling",
|
"fieldname": "selling",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"in_list_view": 1,
|
"in_list_view": 0,
|
||||||
"label": "Selling",
|
"label": "Selling",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
@ -50,7 +51,7 @@
|
|||||||
"fieldname": "item_code",
|
"fieldname": "item_code",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"in_list_view": 1,
|
"in_list_view": 0,
|
||||||
"label": "Item Code",
|
"label": "Item Code",
|
||||||
"oldfieldname": "price_list_name",
|
"oldfieldname": "price_list_name",
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Select",
|
||||||
@ -105,7 +106,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"in_create": 0,
|
"in_create": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"modified": "2015-02-20 05:04:11.609416",
|
"modified": "2015-03-03 01:05:09.876025",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Item Price",
|
"name": "Item Price",
|
||||||
@ -138,5 +139,6 @@
|
|||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"read_only": 0
|
"read_only": 0,
|
||||||
|
"title_field": "item_code"
|
||||||
}
|
}
|
@ -32,6 +32,8 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
|||||||
})
|
})
|
||||||
}, "icon-download", "btn-default");
|
}, "icon-download", "btn-default");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes");
|
||||||
},
|
},
|
||||||
|
|
||||||
received_qty: function(doc, cdt, cdn) {
|
received_qty: function(doc, cdt, cdn) {
|
||||||
@ -178,4 +180,5 @@ frappe.ui.form.on("Purchase Receipt", "is_subcontracted", function(frm) {
|
|||||||
if (frm.doc.is_subcontracted === "Yes") {
|
if (frm.doc.is_subcontracted === "Yes") {
|
||||||
erpnext.buying.get_default_bom(frm);
|
erpnext.buying.get_default_bom(frm);
|
||||||
}
|
}
|
||||||
|
frm.toggle_reqd("supplier_warehouse", frm.doc.is_subcontracted==="Yes");
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "supplier_section",
|
"fieldname": "supplier_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Supplier",
|
"label": "",
|
||||||
"options": "icon-user",
|
"options": "icon-user",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@ -292,7 +292,7 @@
|
|||||||
"description": "Add / Edit Taxes and Charges",
|
"description": "Add / Edit Taxes and Charges",
|
||||||
"fieldname": "taxes_section",
|
"fieldname": "taxes_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Taxes and Charges",
|
"label": "",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"options": "icon-money",
|
"options": "icon-money",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
@ -464,7 +464,7 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "In Words will be visible once you save the Purchase Receipt.",
|
"description": "",
|
||||||
"fieldname": "base_in_words",
|
"fieldname": "base_in_words",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "In Words (Company Currency)",
|
"label": "In Words (Company Currency)",
|
||||||
@ -521,7 +521,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "terms_section_break",
|
"fieldname": "terms_section_break",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Terms and Conditions",
|
"label": "",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"options": "icon-legal",
|
"options": "icon-legal",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
@ -548,7 +548,7 @@
|
|||||||
"depends_on": "supplier",
|
"depends_on": "supplier",
|
||||||
"fieldname": "contact_section",
|
"fieldname": "contact_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Contact Info",
|
"label": "",
|
||||||
"options": "icon-bullhorn",
|
"options": "icon-bullhorn",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@ -560,11 +560,6 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1
|
"print_hide": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "column_break_57",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "contact_person",
|
"fieldname": "contact_person",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@ -573,10 +568,61 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1
|
"print_hide": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_57",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "No",
|
||||||
|
"description": "",
|
||||||
|
"fieldname": "is_subcontracted",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Raw Materials Supplied",
|
||||||
|
"oldfieldname": "is_subcontracted",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "No\nYes",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "",
|
||||||
|
"fieldname": "supplier_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Supplier Warehouse",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "supplier_warehouse",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Warehouse",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"print_width": "50px",
|
||||||
|
"width": "50px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "bill_no",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Bill No",
|
||||||
|
"oldfieldname": "bill_no",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "bill_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Bill Date",
|
||||||
|
"oldfieldname": "bill_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "more_info",
|
"fieldname": "more_info",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "More Info",
|
"label": "",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"options": "icon-file-text",
|
"options": "icon-file-text",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
@ -599,16 +645,17 @@
|
|||||||
"width": "150px"
|
"width": "150px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "No",
|
"description": "Warehouse where you are maintaining stock of rejected items",
|
||||||
"description": "Select \"Yes\" for sub - contracting items",
|
"fieldname": "rejected_warehouse",
|
||||||
"fieldname": "is_subcontracted",
|
"fieldtype": "Link",
|
||||||
"fieldtype": "Select",
|
"label": "Rejected Warehouse",
|
||||||
"label": "Is Subcontracted",
|
"no_copy": 1,
|
||||||
"oldfieldname": "is_subcontracted",
|
"oldfieldname": "rejected_warehouse",
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Link",
|
||||||
"options": "\nYes\nNo",
|
"options": "Warehouse",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1
|
"print_hide": 1,
|
||||||
|
"reqd": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "amended_from",
|
"fieldname": "amended_from",
|
||||||
@ -636,26 +683,6 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1
|
"print_hide": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "bill_no",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Bill No",
|
|
||||||
"oldfieldname": "bill_no",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "bill_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Bill Date",
|
|
||||||
"oldfieldname": "bill_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"fieldname": "letter_head",
|
"fieldname": "letter_head",
|
||||||
@ -733,33 +760,6 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"width": "30%"
|
"width": "30%"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"description": "Warehouse where you are maintaining stock of rejected items",
|
|
||||||
"fieldname": "rejected_warehouse",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Rejected Warehouse",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "rejected_warehouse",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Warehouse",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Supplier warehouse where you have issued raw materials for sub - contracting",
|
|
||||||
"fieldname": "supplier_warehouse",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Supplier Warehouse",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "supplier_warehouse",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Warehouse",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"print_width": "50px",
|
|
||||||
"width": "50px"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "instructions",
|
"fieldname": "instructions",
|
||||||
"fieldtype": "Small Text",
|
"fieldtype": "Small Text",
|
||||||
@ -824,7 +824,7 @@
|
|||||||
"width": "50%"
|
"width": "50%"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Following table will show values if items are sub - contracted. These values will be fetched from the master of \"Bill of Materials\" of sub - contracted items.",
|
"description": "Automatically updated from BOM table",
|
||||||
"fieldname": "raw_material_details",
|
"fieldname": "raw_material_details",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Raw Materials Supplied",
|
"label": "Raw Materials Supplied",
|
||||||
@ -850,7 +850,7 @@
|
|||||||
"icon": "icon-truck",
|
"icon": "icon-truck",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-24 16:00:11.869752",
|
"modified": "2015-03-03 05:12:46.199024",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Purchase Receipt",
|
"name": "Purchase Receipt",
|
||||||
|
@ -245,23 +245,23 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
|||||||
|
|
||||||
from_warehouse: function(doc) {
|
from_warehouse: function(doc) {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.set_warehouse_if_missing("s_warehouse", doc.from_warehouse, function(row) {
|
this.set_warehouse_if_different("s_warehouse", doc.from_warehouse, function(row) {
|
||||||
return me.source_mandatory.indexOf(me.frm.doc.purpose)!==-1;
|
return me.source_mandatory.indexOf(me.frm.doc.purpose)!==-1;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
to_warehouse: function(doc) {
|
to_warehouse: function(doc) {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.set_warehouse_if_missing("t_warehouse", doc.to_warehouse, function(row) {
|
this.set_warehouse_if_different("t_warehouse", doc.to_warehouse, function(row) {
|
||||||
return me.target_mandatory.indexOf(me.frm.doc.purpose)!==-1;
|
return me.target_mandatory.indexOf(me.frm.doc.purpose)!==-1;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
set_warehouse_if_missing: function(fieldname, value, condition) {
|
set_warehouse_if_different: function(fieldname, value, condition) {
|
||||||
var changed = false;
|
var changed = false;
|
||||||
for (var i=0, l=(this.frm.doc.items || []).length; i<l; i++) {
|
for (var i=0, l=(this.frm.doc.items || []).length; i<l; i++) {
|
||||||
var row = this.frm.doc.items[i];
|
var row = this.frm.doc.items[i];
|
||||||
if (!row[fieldname]) {
|
if (row[fieldname] != value) {
|
||||||
if (condition && !condition(row)) {
|
if (condition && !condition(row)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -353,20 +353,6 @@ cur_frm.cscript.toggle_related_fields = function(doc) {
|
|||||||
|
|
||||||
cur_frm.cscript.toggle_enable_bom();
|
cur_frm.cscript.toggle_enable_bom();
|
||||||
|
|
||||||
if(doc.purpose == 'Purchase Return') {
|
|
||||||
doc.customer = doc.customer_name = doc.customer_address =
|
|
||||||
doc.delivery_note_no = doc.sales_invoice_no = null;
|
|
||||||
doc.bom_no = doc.production_order = doc.fg_completed_qty = null;
|
|
||||||
} else if(doc.purpose == 'Sales Return') {
|
|
||||||
doc.supplier=doc.supplier_name = doc.supplier_address = doc.purchase_receipt_no=null;
|
|
||||||
doc.bom_no = doc.production_order = doc.fg_completed_qty = null;
|
|
||||||
} else {
|
|
||||||
doc.customer = doc.customer_name = doc.customer_address =
|
|
||||||
doc.delivery_note_no = doc.sales_invoice_no = doc.supplier =
|
|
||||||
doc.supplier_name = doc.supplier_address = doc.purchase_receipt_no = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.fields_dict['production_order'].get_query = function(doc) {
|
cur_frm.fields_dict['production_order'].get_query = function(doc) {
|
||||||
|
@ -81,6 +81,15 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.purpose==\"Subcontract\"",
|
||||||
|
"fieldname": "purchase_order",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Purchase Order",
|
||||||
|
"options": "Purchase Order",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"depends_on": "eval:doc.purpose==\"Sales Return\"",
|
"depends_on": "eval:doc.purpose==\"Sales Return\"",
|
||||||
@ -224,7 +233,7 @@
|
|||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"label": "Manufacturing Quantity",
|
"label": "For Quantity",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldname": "fg_completed_qty",
|
"oldfieldname": "fg_completed_qty",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
@ -400,16 +409,16 @@
|
|||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:(doc.purpose==\"Sales Return\" || doc.purpose==\"Purchase Return\")",
|
"depends_on": "eval: in_list([\"Sales Return\", \"Purchase Return\", \"Subcontract\"], doc.purpose)",
|
||||||
"fieldname": "contact_section",
|
"fieldname": "contact_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Contact Info",
|
"label": "",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 0
|
"read_only": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"depends_on": "eval:doc.purpose==\"Purchase Return\"",
|
"depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Subcontract\"",
|
||||||
"fieldname": "supplier",
|
"fieldname": "supplier",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -428,7 +437,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"depends_on": "eval:doc.purpose==\"Purchase Return\"",
|
"depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Subcontract\"",
|
||||||
"fieldname": "supplier_name",
|
"fieldname": "supplier_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -446,7 +455,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"depends_on": "eval:doc.purpose==\"Purchase Return\"",
|
"depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Subcontract\"",
|
||||||
"fieldname": "supplier_address",
|
"fieldname": "supplier_address",
|
||||||
"fieldtype": "Small Text",
|
"fieldtype": "Small Text",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -462,6 +471,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0
|
"search_index": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_39",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"depends_on": "eval:doc.purpose==\"Sales Return\"",
|
"depends_on": "eval:doc.purpose==\"Sales Return\"",
|
||||||
@ -520,7 +535,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "more_info",
|
"fieldname": "more_info",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "More Info",
|
"label": "",
|
||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 0
|
"read_only": 0
|
||||||
@ -654,7 +669,7 @@
|
|||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2015-02-25 06:13:11.899840",
|
"modified": "2015-03-03 01:53:07.157141",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Entry",
|
"name": "Stock Entry",
|
||||||
|
@ -73,6 +73,7 @@ class StockEntry(StockController):
|
|||||||
from erpnext.stock.doctype.serial_no.serial_no import update_serial_nos_after_submit
|
from erpnext.stock.doctype.serial_no.serial_no import update_serial_nos_after_submit
|
||||||
update_serial_nos_after_submit(self, "items")
|
update_serial_nos_after_submit(self, "items")
|
||||||
self.update_production_order()
|
self.update_production_order()
|
||||||
|
self.validate_purchase_order()
|
||||||
self.make_gl_entries()
|
self.make_gl_entries()
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
@ -286,20 +287,22 @@ class StockEntry(StockController):
|
|||||||
if not d.t_warehouse:
|
if not d.t_warehouse:
|
||||||
raw_material_cost += flt(d.amount)
|
raw_material_cost += flt(d.amount)
|
||||||
|
|
||||||
|
|
||||||
self.add_operation_cost(raw_material_cost, force)
|
self.add_operation_cost(raw_material_cost, force)
|
||||||
|
|
||||||
def add_operation_cost(self, raw_material_cost, force):
|
def add_operation_cost(self, raw_material_cost, force):
|
||||||
"""Adds operating cost if Production Order is set"""
|
"""Adds operating cost if Production Order is set"""
|
||||||
# set incoming rate for fg item
|
# set incoming rate for fg item
|
||||||
number_of_fg_items = len([t.t_warehouse for t in self.get("items") if t.t_warehouse])
|
if self.purpose in ("Manufacture", "Repack"):
|
||||||
for d in self.get("items"):
|
number_of_fg_items = len([t.t_warehouse for t in self.get("items") if t.t_warehouse])
|
||||||
if (d.t_warehouse and number_of_fg_items == 1):
|
for d in self.get("items"):
|
||||||
operation_cost_per_unit = 0.0
|
if (d.t_warehouse and number_of_fg_items == 1):
|
||||||
if self.production_order:
|
operation_cost_per_unit = 0.0
|
||||||
operation_cost_per_unit = self.get_operation_cost_per_unit(d.bom_no, d.qty)
|
if self.production_order:
|
||||||
d.incoming_rate = operation_cost_per_unit + (raw_material_cost / flt(d.transfer_qty))
|
operation_cost_per_unit = self.get_operation_cost_per_unit(d.bom_no, d.qty)
|
||||||
d.amount = flt(flt(d.transfer_qty) * flt(d.incoming_rate), self.precision("transfer_qty", d))
|
d.incoming_rate = operation_cost_per_unit + (raw_material_cost / flt(d.transfer_qty))
|
||||||
break
|
d.amount = flt(flt(d.transfer_qty) * flt(d.incoming_rate), self.precision("transfer_qty", d))
|
||||||
|
break
|
||||||
|
|
||||||
def get_operation_cost_per_unit(self, bom_no, qty):
|
def get_operation_cost_per_unit(self, bom_no, qty):
|
||||||
"""Returns operating cost from Production Order for given `bom_no`"""
|
"""Returns operating cost from Production Order for given `bom_no`"""
|
||||||
@ -342,6 +345,26 @@ class StockEntry(StockController):
|
|||||||
|
|
||||||
return incoming_rate
|
return incoming_rate
|
||||||
|
|
||||||
|
def validate_purchase_order(self):
|
||||||
|
"""Throw exception if more raw material is transferred against Purchase Order than in
|
||||||
|
the raw materials supplied table"""
|
||||||
|
if self.purpose == "Subcontract" and self.purchase_order:
|
||||||
|
purchase_order = frappe.get_doc("Purchase Order", self.purchase_order)
|
||||||
|
for se_item in self.items:
|
||||||
|
total_allowed = [d.required_qty for d in purchase_order.supplied_items \
|
||||||
|
if d.rm_item_code == se_item.item_code][0]
|
||||||
|
total_supplied = frappe.db.sql("""select sum(qty)
|
||||||
|
from `tabStock Entry Detail`, `tabStock Entry`
|
||||||
|
where `tabStock Entry`.purchase_order = %s
|
||||||
|
and `tabStock Entry`.docstatus = 1
|
||||||
|
and `tabStock Entry Detail`.item_code = %s
|
||||||
|
and `tabStock Entry Detail`.parent = `tabStock Entry`.name""",
|
||||||
|
(self.purchase_order, se_item.item_code))[0][0]
|
||||||
|
|
||||||
|
if total_supplied > total_allowed:
|
||||||
|
frappe.throw(_("Not allowed to tranfer more {0} than {1} against Purchase Order {2}").format(se_item.item_code,
|
||||||
|
total_allowed, self.purchase_order))
|
||||||
|
|
||||||
def validate_bom(self):
|
def validate_bom(self):
|
||||||
for d in self.get('items'):
|
for d in self.get('items'):
|
||||||
if d.bom_no:
|
if d.bom_no:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user