Renamed subcontract to Send to Subcontractor

This commit is contained in:
Rohit Waghchaure 2019-03-26 12:39:28 +05:30
parent ffbeb02428
commit 5816fc2801
12 changed files with 39 additions and 38 deletions

View File

@ -444,7 +444,7 @@ def make_rm_stock_entry(purchase_order, rm_items):
item_wh = get_item_details(items)
stock_entry = frappe.new_doc("Stock Entry")
stock_entry.purpose = "Subcontract"
stock_entry.purpose = "Send to Subcontractor"
stock_entry.purchase_order = purchase_order.name
stock_entry.supplier = purchase_order.supplier
stock_entry.supplier_name = purchase_order.supplier_name

View File

@ -729,7 +729,7 @@ def get_subcontracted_raw_materials_from_se(purchase_orders):
sed.stock_uom, sed.subcontracted_item as main_item_code, sed.serial_no, sed.batch_no
from `tabStock Entry` se,`tabStock Entry Detail` sed
where
se.name = sed.parent and se.docstatus=1 and se.purpose='Subcontract'
se.name = sed.parent and se.docstatus=1 and se.purpose='Send to Subcontractor'
and se.purchase_order in (%s) and ifnull(sed.t_warehouse, '') != ''
group by sed.item_code, sed.t_warehouse
""" % (','.join(['%s'] * len(purchase_orders))), tuple(purchase_orders), as_dict=1)

View File

@ -7,13 +7,13 @@ import frappe
def execute():
frappe.reload_doc('buying', 'doctype', 'buying_settings')
frappe.db.set_value('Buying Settings', None, 'backflush_raw_materials_of_subcontract_based_on', 'BOM')
frappe.reload_doc('stock', 'doctype', 'stock_entry_detail')
frappe.db.sql(""" update `tabStock Entry Detail` as sed,
frappe.db.sql(""" update `tabStock Entry Detail` as sed,
`tabStock Entry` as se, `tabPurchase Order Item Supplied` as pois
set
sed.subcontracted_item = pois.main_item_code
where
se.purpose = 'Subcontract' and sed.parent = se.name
se.purpose = 'Send to Subcontractor' and sed.parent = se.name
and pois.rm_item_code = sed.item_code and se.docstatus = 1
and pois.parenttype = 'Purchase Order'""")

View File

@ -19,7 +19,7 @@ def create_stock_entry_types():
for purpose in ["Material Issue", "Material Receipt", "Material Transfer",
"Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture",
"Repack", "Subcontract", "Send to Warehouse", "Receive at Warehouse"]:
"Repack", "Send to Subcontractor", "Send to Warehouse", "Receive at Warehouse"]:
ste_type = frappe.get_doc({
'doctype': 'Stock Entry Type',
@ -32,6 +32,7 @@ def create_stock_entry_types():
except frappe.DuplicateEntryError:
pass
frappe.db.sql(" UPDATE `tabStock Entry` set purpose = 'Send to Subcontractor' where purpose = 'Subcontract'")
frappe.db.sql(" UPDATE `tabStock Entry` set stock_entry_type = purpose ")
def add_gst_hsn_code_field():

View File

@ -89,7 +89,7 @@ def install(country=None):
{'doctype': 'Stock Entry Type', 'name': 'Material Transfer', 'purpose': 'Material Transfer'},
{'doctype': 'Stock Entry Type', 'name': 'Manufacture', 'purpose': 'Manufacture'},
{'doctype': 'Stock Entry Type', 'name': 'Repack', 'purpose': 'Repack'},
{'doctype': 'Stock Entry Type', 'name': 'Subcontract', 'purpose': 'Subcontract'},
{'doctype': 'Stock Entry Type', 'name': 'Send to Subcontractor', 'purpose': 'Send to Subcontractor'},
{'doctype': 'Stock Entry Type', 'name': 'Material Transfer for Manufacture', 'purpose': 'Material Transfer for Manufacture'},
{'doctype': 'Stock Entry Type', 'name': 'Material Consumption for Manufacture', 'purpose': 'Material Consumption for Manufacture'},
{'doctype': 'Stock Entry Type', 'name': 'Send to Warehouse', 'purpose': 'Send to Warehouse'},

View File

@ -106,7 +106,7 @@ class Bin(Document):
`tabStock Entry` se, `tabStock Entry Detail` sed, `tabPurchase Order` po
where
se.docstatus=1
and se.purpose='Subcontract'
and se.purpose='Send to Subcontractor'
and ifnull(se.purchase_order, '') !=''
and (sed.item_code = %(item)s or sed.original_item = %(item)s)
and se.name = sed.parent

View File

@ -49,7 +49,7 @@ frappe.ui.form.on('Stock Entry', {
if(!item.item_code) {
frappe.throw(__("Please enter Item Code to get Batch Number"));
} else {
if (in_list(["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"], doc.purpose)) {
if (in_list(["Material Transfer for Manufacture", "Manufacture", "Repack", "Send to Subcontractor"], doc.purpose)) {
var filters = {
'item_code': item.item_code,
'posting_date': frm.doc.posting_date || frappe.datetime.nowdate()
@ -781,9 +781,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
if(!row.t_warehouse) row.t_warehouse = this.frm.doc.to_warehouse;
},
source_mandatory: ["Material Issue", "Material Transfer", "Subcontract",
source_mandatory: ["Material Issue", "Material Transfer", "Send to Subcontractor",
"Material Transfer for Manufacture", "Send to Warehouse", "Receive at Warehouse"],
target_mandatory: ["Material Receipt", "Material Transfer", "Subcontract",
target_mandatory: ["Material Receipt", "Material Transfer", "Send to Subcontractor",
"Material Transfer for Manufacture", "Send to Warehouse", "Receive at Warehouse"],
from_warehouse: function(doc) {
@ -831,7 +831,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
this.frm.cscript.toggle_enable_bom();
if (doc.purpose == 'Subcontract') {
if (doc.purpose == 'Send to Subcontractor') {
doc.customer = doc.customer_name = doc.customer_address =
doc.delivery_note_no = doc.sales_invoice_no = null;
} else {

View File

@ -210,7 +210,7 @@
"no_copy": 0,
"oldfieldname": "purpose",
"oldfieldtype": "Select",
"options": "Material Issue\nMaterial Receipt\nMaterial Transfer\nMaterial Transfer for Manufacture\nMaterial Consumption for Manufacture\nManufacture\nRepack\nSubcontract\nSend to Warehouse\nReceive at Warehouse",
"options": "Material Issue\nMaterial Receipt\nMaterial Transfer\nMaterial Transfer for Manufacture\nMaterial Consumption for Manufacture\nManufacture\nRepack\nSend to Subcontractor\nSend to Warehouse\nReceive at Warehouse",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
@ -301,7 +301,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.purpose==\"Subcontract\"",
"depends_on": "eval:doc.purpose==\"Send to Subcontractor\"",
"fetch_if_empty": 0,
"fieldname": "purchase_order",
"fieldtype": "Link",
@ -615,7 +615,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:in_list([\"Material Issue\", \"Material Transfer\", \"Manufacture\", \"Repack\", \t\t\t\t\t\"Subcontract\", \"Material Transfer for Manufacture\", \"Material Consumption for Manufacture\"], doc.purpose)",
"depends_on": "eval:in_list([\"Material Issue\", \"Material Transfer\", \"Manufacture\", \"Repack\", \t\t\t\t\t\"Send to Subcontractor\", \"Material Transfer for Manufacture\", \"Material Consumption for Manufacture\"], doc.purpose)",
"fetch_if_empty": 0,
"fieldname": "from_bom",
"fieldtype": "Check",
@ -1524,7 +1524,7 @@
"bold": 0,
"collapsible": 1,
"columns": 0,
"depends_on": "eval: in_list([\"Sales Return\", \"Purchase Return\", \"Subcontract\"], doc.purpose)",
"depends_on": "eval: in_list([\"Sales Return\", \"Purchase Return\", \"Send to Subcontractor\"], doc.purpose)",
"fetch_if_empty": 0,
"fieldname": "contact_section",
"fieldtype": "Section Break",
@ -1557,7 +1557,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Subcontract\"",
"depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Send to Subcontractor\"",
"fetch_if_empty": 0,
"fieldname": "supplier",
"fieldtype": "Link",
@ -1593,7 +1593,7 @@
"bold": 1,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Subcontract\"",
"depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Send to Subcontractor\"",
"fetch_if_empty": 0,
"fieldname": "supplier_name",
"fieldtype": "Data",
@ -1628,7 +1628,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Subcontract\"",
"depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Send to Subcontractor\"",
"fetch_if_empty": 0,
"fieldname": "supplier_address",
"fieldtype": "Link",
@ -2246,7 +2246,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-03-26 12:02:19.319467",
"modified": "2019-03-26 12:24:46.439626",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry",

View File

@ -83,7 +83,7 @@ class StockEntry(StockController):
update_serial_nos_after_submit(self, "items")
self.update_work_order()
self.validate_purchase_order()
if self.purchase_order and self.purpose == "Subcontract":
if self.purchase_order and self.purpose == "Send to Subcontractor":
self.update_purchase_order_supplied_items()
self.make_gl_entries()
self.update_cost_in_project()
@ -94,7 +94,7 @@ class StockEntry(StockController):
def on_cancel(self):
if self.purchase_order and self.purpose == "Subcontract":
if self.purchase_order and self.purpose == "Send to Subcontractor":
self.update_purchase_order_supplied_items()
if self.work_order and self.purpose == "Material Consumption for Manufacture":
@ -123,7 +123,7 @@ class StockEntry(StockController):
def validate_purpose(self):
valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer",
"Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract",
"Material Transfer for Manufacture", "Manufacture", "Repack", "Send to Subcontractor",
"Material Consumption for Manufacture", "Send to Warehouse", "Receive at Warehouse"]
if self.purpose not in valid_purposes:
@ -227,10 +227,10 @@ class StockEntry(StockController):
def validate_warehouse(self):
"""perform various (sometimes conditional) validations on warehouse"""
source_mandatory = ["Material Issue", "Material Transfer", "Subcontract", "Material Transfer for Manufacture",
source_mandatory = ["Material Issue", "Material Transfer", "Send to Subcontractor", "Material Transfer for Manufacture",
"Material Consumption for Manufacture", "Send to Warehouse", "Receive at Warehouse"]
target_mandatory = ["Material Receipt", "Material Transfer", "Subcontract",
target_mandatory = ["Material Receipt", "Material Transfer", "Send to Subcontractor",
"Material Transfer for Manufacture", "Send to Warehouse", "Receive at Warehouse"]
validate_for_manufacture_repack = any([d.bom_no for d in self.get("items")])
@ -502,7 +502,7 @@ class StockEntry(StockController):
backflush_raw_materials_based_on = frappe.db.get_single_value("Buying Settings",
"backflush_raw_materials_of_subcontract_based_on")
if (self.purpose == "Subcontract" and self.purchase_order and
if (self.purpose == "Send to Subcontractor" and self.purchase_order and
backflush_raw_materials_based_on == 'BOM'):
purchase_order = frappe.get_doc("Purchase Order", self.purchase_order)
for se_item in self.items:
@ -538,7 +538,7 @@ class StockEntry(StockController):
"overproduction_percentage_for_work_order"))
for d in self.get('items'):
if self.purpose != "Subcontract" and d.bom_no and flt(d.transfer_qty) > flt(self.fg_completed_qty) and (d.t_warehouse != getattr(self, "pro_doc", frappe._dict()).scrap_warehouse):
if self.purpose != "Send to Subcontractor" and d.bom_no and flt(d.transfer_qty) > flt(self.fg_completed_qty) and (d.t_warehouse != getattr(self, "pro_doc", frappe._dict()).scrap_warehouse):
frappe.throw(_("Quantity in row {0} ({1}) must be same as manufactured quantity {2}"). \
format(d.idx, d.transfer_qty, self.fg_completed_qty))
@ -738,7 +738,7 @@ class StockEntry(StockController):
if self.bom_no:
if self.purpose in ["Material Issue", "Material Transfer", "Manufacture", "Repack",
"Subcontract", "Material Transfer for Manufacture", "Material Consumption for Manufacture"]:
"Send to Subcontractor", "Material Transfer for Manufacture", "Material Consumption for Manufacture"]:
if self.work_order and self.purpose == "Material Transfer for Manufacture":
item_dict = self.get_pending_raw_materials()
@ -764,7 +764,7 @@ class StockEntry(StockController):
item_dict = self.get_bom_raw_materials(self.fg_completed_qty)
#Get PO Supplied Items Details
if self.purchase_order and self.purpose == "Subcontract":
if self.purchase_order and self.purpose == "Send to Subcontractor":
#Get PO Supplied Items Details
item_wh = frappe._dict(frappe.db.sql("""
select rm_item_code, reserve_warehouse
@ -776,13 +776,13 @@ class StockEntry(StockController):
if self.pro_doc and (cint(self.pro_doc.from_wip_warehouse) or not self.pro_doc.skip_transfer):
item["from_warehouse"] = self.pro_doc.wip_warehouse
#Get Reserve Warehouse from PO
if self.purchase_order and self.purpose=="Subcontract":
if self.purchase_order and self.purpose=="Send to Subcontractor":
item["from_warehouse"] = item_wh.get(item.item_code)
item["to_warehouse"] = self.to_warehouse if self.purpose=="Subcontract" else ""
item["to_warehouse"] = self.to_warehouse if self.purpose=="Send to Subcontractor" else ""
self.add_to_stock_entry_detail(item_dict)
if self.purpose != "Subcontract":
if self.purpose != "Send to Subcontractor":
scrap_item_dict = self.get_bom_scrap_material(self.fg_completed_qty)
for item in itervalues(scrap_item_dict):
if self.pro_doc and self.pro_doc.scrap_warehouse:
@ -1116,7 +1116,7 @@ class StockEntry(StockController):
frappe.MappingMismatchError)
def validate_batch(self):
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract", "Material Issue"]:
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Send to Subcontractor", "Material Issue"]:
for item in self.get("items"):
if item.batch_no:
disabled = frappe.db.get_value("Batch", item.batch_no, "disabled")
@ -1349,7 +1349,7 @@ def get_used_alternative_items(purchase_order=None, work_order=None):
cond = ""
if purchase_order:
cond = "and ste.purpose = 'Subcontract' and ste.purchase_order = '{0}'".format(purchase_order)
cond = "and ste.purpose = 'Send to Subcontractor' and ste.purchase_order = '{0}'".format(purchase_order)
elif work_order:
cond = "and ste.purpose = 'Material Transfer for Manufacture' and ste.work_order = '{0}'".format(work_order)

View File

@ -6,7 +6,7 @@ QUnit.test("test material Transfer to manufacture", function(assert) {
frappe.run_serially([
() => {
return frappe.tests.make('Stock Entry', [
{purpose:'Subcontract'},
{purpose:'Send to Subcontractor'},
{from_warehouse:'Work In Progress - '+frappe.get_abbr(frappe.defaults.get_default('Company'))},
{to_warehouse:'Finished Goods - '+frappe.get_abbr(frappe.defaults.get_default('Company'))},
{items: [

View File

@ -35,7 +35,7 @@
"label": "Purpose",
"length": 0,
"no_copy": 0,
"options": "\nMaterial Issue\nMaterial Receipt\nMaterial Transfer\nMaterial Transfer for Manufacture\nMaterial Consumption for Manufacture\nManufacture\nRepack\nSubcontract\nSend to Warehouse\nReceive at Warehouse",
"options": "\nMaterial Issue\nMaterial Receipt\nMaterial Transfer\nMaterial Transfer for Manufacture\nMaterial Consumption for Manufacture\nManufacture\nRepack\nSend to Subcontractor\nSend to Warehouse\nReceive at Warehouse",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -60,7 +60,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-03-25 19:30:42.144377",
"modified": "2019-03-26 12:02:42.144377",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry Type",

View File

@ -59,7 +59,7 @@ def get_consumed_items(condition):
sum(se_item.transfer_qty) as 'consume_qty'
from `tabStock Entry` se, `tabStock Entry Detail` se_item
where se.name = se_item.parent and se.docstatus = 1
and (ifnull(se_item.t_warehouse, '') = '' or se.purpose = 'Subcontract') %s
and (ifnull(se_item.t_warehouse, '') = '' or se.purpose = 'Send to Subcontractor') %s
group by se_item.item_code""" % (condition), as_dict=1)
cn_items_map = {}