fix: test cases

This commit is contained in:
Rohit Waghchaure 2019-03-15 13:58:14 +05:30
parent 4389cf0c48
commit c7b916ac46
12 changed files with 205 additions and 288 deletions

View File

@ -89,7 +89,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
}, __('Create')); }, __('Create'));
} }
if (doc.docstatus == 1) { if (doc.docstatus === 1) {
cur_frm.add_custom_button(__('Maintenance Schedule'), function () { cur_frm.add_custom_button(__('Maintenance Schedule'), function () {
cur_frm.cscript.make_maintenance_schedule(); cur_frm.cscript.make_maintenance_schedule();
}, __('Create')); }, __('Create'));

View File

@ -7,46 +7,45 @@ import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
def execute(): def execute():
create_stock_entry_types() create_stock_entry_types()
company = frappe.get_cached_value("Company", {'country': 'India'}, 'name') company = frappe.db.get_value("Company", {'country': 'India'}, 'name')
if company: if company:
pass add_gst_hsn_code_field()
# add_gst_hsn_code_field()
def create_stock_entry_types(): def create_stock_entry_types():
frappe.reload_doc('stock', 'doctype', 'stock_entry_type') frappe.reload_doc('stock', 'doctype', 'stock_entry_type')
frappe.reload_doc('stock', 'doctype', 'stock_entry') frappe.reload_doc('stock', 'doctype', 'stock_entry')
for purpose in ["Material Issue", "Material Receipt", "Material Transfer", for purpose in ["Material Issue", "Material Receipt", "Material Transfer",
"Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture", "Material Transfer for Manufacture", "Material Consumption for Manufacture", "Manufacture",
"Repack", "Subcontract", "Stock Out", "Stock In"]: "Repack", "Subcontract", "Stock Out", "Stock In"]:
ste_type = frappe.get_doc({ ste_type = frappe.get_doc({
'doctype': 'Stock Entry Type', 'doctype': 'Stock Entry Type',
'name': purpose, 'name': purpose,
'purpose': purpose 'purpose': purpose
}) })
try: try:
ste_type.insert() ste_type.insert()
except frappe.DuplicateEntryError: except frappe.DuplicateEntryError:
pass pass
frappe.db.sql(" UPDATE `tabStock Entry` set stock_entry_type = purpose ") frappe.db.sql(" UPDATE `tabStock Entry` set stock_entry_type = purpose ")
def add_gst_hsn_code_field(): def add_gst_hsn_code_field():
custom_fields = { custom_fields = {
'Stock Entry Detail': [dict(fieldname='gst_hsn_code', label='HSN/SAC', 'Stock Entry Detail': [dict(fieldname='gst_hsn_code', label='HSN/SAC',
fieldtype='Data', fetch_from='item_code.gst_hsn_code', fieldtype='Data', fetch_from='item_code.gst_hsn_code',
insert_after='description', allow_on_submit=1, print_hide=0)] insert_after='description', allow_on_submit=1, print_hide=0)]
} }
create_custom_fields(custom_fields, ignore_validate = frappe.flags.in_patch, update=True) create_custom_fields(custom_fields, ignore_validate = frappe.flags.in_patch, update=True)
frappe.db.sql(""" update `tabStock Entry Detail`, `tabItem` frappe.db.sql(""" update `tabStock Entry Detail`, `tabItem`
SET SET
`tabStock Entry Detail`.gst_hsn_code = `tabItem`.gst_hsn_code `tabStock Entry Detail`.gst_hsn_code = `tabItem`.gst_hsn_code
Where Where
`tabItem`.name = `tabStock Entry Detail`.item_code and `tabItem`.gst_hsn_code is not null `tabItem`.name = `tabStock Entry Detail`.item_code and `tabItem`.gst_hsn_code is not null
""") """)

View File

@ -1,6 +1,5 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0, "allow_guest_to_view": 0,
"allow_import": 0, "allow_import": 0,
"allow_rename": 0, "allow_rename": 0,
@ -20,7 +19,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "sales_person", "fieldname": "sales_person",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -57,7 +55,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "contact_no", "fieldname": "contact_no",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
@ -93,7 +90,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "allocated_percentage", "fieldname": "allocated_percentage",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
@ -122,40 +118,6 @@
"unique": 0, "unique": 0,
"width": "100px" "width": "100px"
}, },
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "item_group",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Item Group",
"length": 0,
"no_copy": 0,
"options": "Item Group",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0, "allow_in_quick_entry": 0,
@ -163,7 +125,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "allocated_amount", "fieldname": "allocated_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@ -200,8 +161,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_from": "item_group.commission_rate",
"fetch_if_empty": 1,
"fieldname": "commission_rate", "fieldname": "commission_rate",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@ -234,7 +193,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "incentives", "fieldname": "incentives",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@ -273,7 +231,7 @@
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2019-03-15 00:06:59.441936", "modified": "2018-09-17 13:03:14.755974",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Sales Team", "name": "Sales Team",
@ -286,4 +244,4 @@
"track_changes": 1, "track_changes": 1,
"track_seen": 0, "track_seen": 0,
"track_views": 0 "track_views": 0
} }

View File

@ -21,7 +21,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "gs", "fieldname": "gs",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@ -53,7 +52,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "item_group_name", "fieldname": "item_group_name",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@ -88,7 +86,6 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "parent_item_group", "fieldname": "parent_item_group",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -124,7 +121,6 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "Only leaf nodes are allowed in transaction", "description": "Only leaf nodes are allowed in transaction",
"fetch_if_empty": 0,
"fieldname": "is_group", "fieldname": "is_group",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@ -159,71 +155,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_5",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "commission_rate",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Commission Rate",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "image", "fieldname": "image",
"fieldtype": "Attach Image", "fieldtype": "Attach Image",
"hidden": 1, "hidden": 1,
@ -256,7 +187,36 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0, "fieldname": "column_break_5",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "defaults", "fieldname": "defaults",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@ -289,7 +249,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "item_group_defaults", "fieldname": "item_group_defaults",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
@ -324,7 +283,6 @@
"collapsible": 0, "collapsible": 0,
"collapsible_depends_on": "", "collapsible_depends_on": "",
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "sec_break_taxes", "fieldname": "sec_break_taxes",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@ -357,7 +315,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "taxes", "fieldname": "taxes",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
@ -391,7 +348,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "sb9", "fieldname": "sb9",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@ -424,7 +380,6 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "Check this if you want to show in website", "description": "Check this if you want to show in website",
"fetch_if_empty": 0,
"fieldname": "show_in_website", "fieldname": "show_in_website",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@ -457,7 +412,6 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "show_in_website", "depends_on": "show_in_website",
"fetch_if_empty": 0,
"fieldname": "route", "fieldname": "route",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@ -490,7 +444,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "weightage", "fieldname": "weightage",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 0, "hidden": 0,
@ -525,7 +478,6 @@
"columns": 0, "columns": 0,
"depends_on": "show_in_website", "depends_on": "show_in_website",
"description": "Show this slideshow at the top of the page", "description": "Show this slideshow at the top of the page",
"fetch_if_empty": 0,
"fieldname": "slideshow", "fieldname": "slideshow",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -560,7 +512,6 @@
"columns": 0, "columns": 0,
"depends_on": "show_in_website", "depends_on": "show_in_website",
"description": "HTML / Banner that will show on the top of product list.", "description": "HTML / Banner that will show on the top of product list.",
"fetch_if_empty": 0,
"fieldname": "description", "fieldname": "description",
"fieldtype": "Text Editor", "fieldtype": "Text Editor",
"hidden": 0, "hidden": 0,
@ -593,7 +544,6 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "show_in_website", "depends_on": "show_in_website",
"fetch_if_empty": 0,
"fieldname": "website_specifications", "fieldname": "website_specifications",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
@ -626,7 +576,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "lft", "fieldname": "lft",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 1, "hidden": 1,
@ -660,7 +609,6 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "rgt", "fieldname": "rgt",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 1, "hidden": 1,
@ -695,7 +643,6 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "old_parent", "fieldname": "old_parent",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "hidden": 1,
@ -736,7 +683,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 3, "max_attachments": 3,
"modified": "2019-03-15 00:05:25.816002", "modified": "2018-11-23 15:17:28.003933",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Setup", "module": "Setup",
"name": "Item Group", "name": "Item Group",
@ -867,4 +814,4 @@
"track_changes": 0, "track_changes": 0,
"track_seen": 0, "track_seen": 0,
"track_views": 0 "track_views": 0
} }

View File

@ -92,6 +92,8 @@ def install(country=None):
{'doctype': 'Stock Entry Type', 'name': 'Subcontract', 'purpose': 'Subcontract'}, {'doctype': 'Stock Entry Type', 'name': 'Subcontract', 'purpose': 'Subcontract'},
{'doctype': 'Stock Entry Type', 'name': 'Material Transfer for Manufacture', 'purpose': 'Material Transfer for Manufacture'}, {'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': 'Material Consumption for Manufacture', 'purpose': 'Material Consumption for Manufacture'},
{'doctype': 'Stock Entry Type', 'name': 'Stock Out', 'purpose': 'Stock Out'},
{'doctype': 'Stock Entry Type', 'name': 'Stock In', 'purpose': 'Stock In'},
# Designation # Designation
{'doctype': 'Designation', 'designation_name': _('CEO')}, {'doctype': 'Designation', 'designation_name': _('CEO')},

View File

@ -202,6 +202,7 @@ def split_batch(batch_no, item_code, warehouse, qty, new_batch_id=None):
), ),
] ]
)) ))
stock_entry.set_stock_entry_type()
stock_entry.insert() stock_entry.insert()
stock_entry.submit() stock_entry.submit()

View File

@ -67,7 +67,10 @@ class TestBatch(unittest.TestCase):
rate = 10 rate = 10
) )
] ]
)).insert() ))
stock_entry.set_stock_entry_type()
stock_entry.insert()
stock_entry.submit() stock_entry.submit()
self.assertTrue(stock_entry.items[0].batch_no) self.assertTrue(stock_entry.items[0].batch_no)
@ -136,7 +139,10 @@ class TestBatch(unittest.TestCase):
s_warehouse=receipt.items[0].warehouse, s_warehouse=receipt.items[0].warehouse,
) )
] ]
)).insert() ))
stock_entry.set_stock_entry_type()
stock_entry.insert()
stock_entry.submit() stock_entry.submit()
# assert same batch is selected # assert same batch is selected
@ -193,7 +199,10 @@ class TestBatch(unittest.TestCase):
allow_zero_valuation_rate = 1 allow_zero_valuation_rate = 1
) )
] ]
)).insert() ))
stock_entry.set_stock_entry_type()
stock_entry.insert()
stock_entry.submit() stock_entry.submit()
def test_batch_name_with_naming_series(self): def test_batch_name_with_naming_series(self):

View File

@ -96,6 +96,8 @@ class TestMaterialRequest(unittest.TestCase):
} }
] ]
}) })
se.set_stock_entry_type()
se.insert() se.insert()
se.submit() se.submit()
@ -388,6 +390,7 @@ class TestMaterialRequest(unittest.TestCase):
# check for stopped status of Material Request # check for stopped status of Material Request
se = frappe.copy_doc(se_doc) se = frappe.copy_doc(se_doc)
se.set_stock_entry_type()
se.insert() se.insert()
mr.update_status('Stopped') mr.update_status('Stopped')
self.assertRaises(frappe.InvalidStatusError, se.submit) self.assertRaises(frappe.InvalidStatusError, se.submit)
@ -395,6 +398,7 @@ class TestMaterialRequest(unittest.TestCase):
mr.update_status('Submitted') mr.update_status('Submitted')
se = frappe.copy_doc(se_doc) se = frappe.copy_doc(se_doc)
se.set_stock_entry_type()
se.insert() se.insert()
se.submit() se.submit()
@ -528,7 +532,7 @@ class TestMaterialRequest(unittest.TestCase):
#testing bin requested qty after issuing stock against material request #testing bin requested qty after issuing stock against material request
self.assertEqual(_get_requested_qty(), existing_requested_qty) self.assertEqual(_get_requested_qty(), existing_requested_qty)
def test_material_request_type_manufacture(self): def test_material_request_type_manufacture(self):
mr = frappe.copy_doc(test_records[1]).insert() mr = frappe.copy_doc(test_records[1]).insert()
mr = frappe.get_doc("Material Request", mr.name) mr = frappe.get_doc("Material Request", mr.name)
@ -541,20 +545,20 @@ class TestMaterialRequest(unittest.TestCase):
po = frappe.get_doc("Work Order", prod_order[0]) po = frappe.get_doc("Work Order", prod_order[0])
po.wip_warehouse = "_Test Warehouse 1 - _TC" po.wip_warehouse = "_Test Warehouse 1 - _TC"
po.submit() po.submit()
mr = frappe.get_doc("Material Request", mr.name) mr = frappe.get_doc("Material Request", mr.name)
self.assertEqual(completed_qty + po.qty, mr.items[0].ordered_qty) self.assertEqual(completed_qty + po.qty, mr.items[0].ordered_qty)
new_requested_qty = frappe.db.sql("""select indented_qty from `tabBin` where \ new_requested_qty = frappe.db.sql("""select indented_qty from `tabBin` where \
item_code= %s and warehouse= %s """, (mr.items[0].item_code, mr.items[0].warehouse))[0][0] item_code= %s and warehouse= %s """, (mr.items[0].item_code, mr.items[0].warehouse))[0][0]
self.assertEqual(requested_qty - po.qty, new_requested_qty) self.assertEqual(requested_qty - po.qty, new_requested_qty)
po.cancel() po.cancel()
mr = frappe.get_doc("Material Request", mr.name) mr = frappe.get_doc("Material Request", mr.name)
self.assertEqual(completed_qty, mr.items[0].ordered_qty) self.assertEqual(completed_qty, mr.items[0].ordered_qty)
new_requested_qty = frappe.db.sql("""select indented_qty from `tabBin` where \ new_requested_qty = frappe.db.sql("""select indented_qty from `tabBin` where \
item_code= %s and warehouse= %s """, (mr.items[0].item_code, mr.items[0].warehouse))[0][0] item_code= %s and warehouse= %s """, (mr.items[0].item_code, mr.items[0].warehouse))[0][0]
self.assertEqual(requested_qty, new_requested_qty) self.assertEqual(requested_qty, new_requested_qty)

View File

@ -106,7 +106,7 @@ frappe.ui.form.on('Stock Entry', {
frappe.call({ frappe.call({
doc: frm.doc, doc: frm.doc,
method: "set_items_for_stock_in", method: "set_items_for_stock_in",
callback: function(r) { callback: function() {
refresh_field('items'); refresh_field('items');
} }
}); });

View File

@ -62,6 +62,7 @@ class StockEntry(StockController):
self.validate_inspection() self.validate_inspection()
self.validate_fg_completed_qty() self.validate_fg_completed_qty()
self.set_job_card_data() self.set_job_card_data()
self.set_purpose_for_stock_entry()
if not self.from_bom: if not self.from_bom:
self.fg_completed_qty = 0.0 self.fg_completed_qty = 0.0
@ -486,10 +487,15 @@ class StockEntry(StockController):
self.total_amount = sum([flt(item.amount) for item in self.get("items")]) self.total_amount = sum([flt(item.amount) for item in self.get("items")])
def set_stock_entry_type(self): def set_stock_entry_type(self):
if not self.stock_entry_type and self.purpose: if self.purpose:
self.stock_entry_type = frappe.get_cached_value('Stock Entry Type', self.stock_entry_type = frappe.get_cached_value('Stock Entry Type',
{'purpose': self.purpose}, 'name') {'purpose': self.purpose}, 'name')
def set_purpose_for_stock_entry(self):
if self.stock_entry_type and not self.purpose:
self.purpose = frappe.get_cached_value('Stock Entry Type',
self.stock_entry_type, 'purpose')
def validate_purchase_order(self): def validate_purchase_order(self):
"""Throw exception if more raw material is transferred against Purchase Order than in """Throw exception if more raw material is transferred against Purchase Order than in
the raw materials supplied table""" the raw materials supplied table"""
@ -1248,12 +1254,10 @@ def move_sample_to_retention_warehouse(company, items):
if stock_entry.get('items'): if stock_entry.get('items'):
return stock_entry.as_dict() return stock_entry.as_dict()
@frappe.whitelist() @frappe.whitelist()
def make_stock_in_entry(source_name, target_doc=None): def make_stock_in_entry(source_name, target_doc=None):
def set_missing_values(source, target): def set_missing_values(source, target):
target.purpose = 'Stock In' target.purpose = 'Stock In'
target.stock_entry_type = ''
target.set_stock_entry_type() target.set_stock_entry_type()
def update_item(source_doc, target_doc, source_parent): def update_item(source_doc, target_doc, source_parent):

View File

@ -2,15 +2,14 @@ frappe.listview_settings['Stock Entry'] = {
add_fields: ["`tabStock Entry`.`from_warehouse`", "`tabStock Entry`.`to_warehouse`", add_fields: ["`tabStock Entry`.`from_warehouse`", "`tabStock Entry`.`to_warehouse`",
"`tabStock Entry`.`purpose`", "`tabStock Entry`.`work_order`", "`tabStock Entry`.`bom_no`"], "`tabStock Entry`.`purpose`", "`tabStock Entry`.`work_order`", "`tabStock Entry`.`bom_no`"],
get_indicator: function (doc) { get_indicator: function (doc) {
debugger
if (doc.docstatus === 0) { if (doc.docstatus === 0) {
return [__("Draft"), "red", "docstatus,=,0"]; return [__("Draft"), "red", "docstatus,=,0"];
} else if (doc.purpose == 'Stock Out' && doc.per_transferred < 100) { } else if (doc.purpose === 'Stock Out' && doc.per_transferred < 100) {
// not delivered & overdue // not delivered & overdue
return [__("Goods In Transit"), "grey", "per_transferred,<,100"]; return [__("Goods In Transit"), "grey", "per_transferred,<,100"];
} else if (doc.purpose == 'Stock Out' && doc.per_transferred == 100) { } else if (doc.purpose === 'Stock Out' && doc.per_transferred === 100) {
return [__("Goods Transferred"), "green", "per_transferred,=,100"]; return [__("Goods Transferred"), "green", "per_transferred,=,100"];
} else if (doc.docstatus === 2) { } else if (doc.docstatus === 2) {
return [__("Canceled"), "red", "docstatus,=,2"]; return [__("Canceled"), "red", "docstatus,=,2"];

View File

@ -1,113 +1,107 @@
[ [
{ {
"company": "_Test Company", "company": "_Test Company",
"doctype": "Stock Entry", "doctype": "Stock Entry",
"items": [ "stock_entry_type": "Material Receipt",
{ "purpose": "Material Receipt",
"conversion_factor": 1.0, "items": [
"cost_center": "_Test Cost Center - _TC", {
"doctype": "Stock Entry Detail", "conversion_factor": 1.0,
"expense_account": "Stock Adjustment - _TC", "cost_center": "_Test Cost Center - _TC",
"basic_rate": 100, "doctype": "Stock Entry Detail",
"item_code": "_Test Item", "expense_account": "Stock Adjustment - _TC",
"parentfield": "items", "basic_rate": 100,
"qty": 50.0, "item_code": "_Test Item",
"stock_uom": "_Test UOM", "parentfield": "items",
"t_warehouse": "_Test Warehouse - _TC", "qty": 50.0,
"transfer_qty": 50.0, "stock_uom": "_Test UOM",
"uom": "_Test UOM" "t_warehouse": "_Test Warehouse - _TC",
} "transfer_qty": 50.0,
], "uom": "_Test UOM"
"stock_entry_type": "Material Receipt", }
"purpose": "Material Receipt" ]
}, },
{
"company": "_Test Company",
{ "doctype": "Stock Entry",
"company": "_Test Company", "posting_date": "2013-01-25",
"doctype": "Stock Entry", "purpose": "Material Issue",
"items": [ "stock_entry_type": "Material Issue",
{ "items": [
"conversion_factor": 1.0, {
"cost_center": "_Test Cost Center - _TC", "conversion_factor": 1.0,
"doctype": "Stock Entry Detail", "cost_center": "_Test Cost Center - _TC",
"expense_account": "Stock Adjustment - _TC", "doctype": "Stock Entry Detail",
"basic_rate": 100, "expense_account": "Stock Adjustment - _TC",
"item_code": "_Test Item", "basic_rate": 100,
"parentfield": "items", "item_code": "_Test Item",
"qty": 40.0, "parentfield": "items",
"s_warehouse": "_Test Warehouse - _TC", "qty": 40.0,
"stock_uom": "_Test UOM", "s_warehouse": "_Test Warehouse - _TC",
"transfer_qty": 40.0, "stock_uom": "_Test UOM",
"uom": "_Test UOM" "transfer_qty": 40.0,
} "uom": "_Test UOM"
], }
"posting_date": "2013-01-25", ]
"purpose": "Material Issue", },
"stock_entry_type": "Material Issue" {
}, "company": "_Test Company",
"doctype": "Stock Entry",
"posting_date": "2013-01-25",
{ "purpose": "Material Transfer",
"company": "_Test Company", "stock_entry_type": "Material Transfer",
"doctype": "Stock Entry", "items": [
"items": [ {
{ "conversion_factor": 1.0,
"conversion_factor": 1.0, "cost_center": "_Test Cost Center - _TC",
"cost_center": "_Test Cost Center - _TC", "doctype": "Stock Entry Detail",
"doctype": "Stock Entry Detail", "expense_account": "Stock Adjustment - _TC",
"expense_account": "Stock Adjustment - _TC", "basic_rate": 100,
"basic_rate": 100, "item_code": "_Test Item",
"item_code": "_Test Item", "parentfield": "items",
"parentfield": "items", "qty": 45.0,
"qty": 45.0, "s_warehouse": "_Test Warehouse - _TC",
"s_warehouse": "_Test Warehouse - _TC", "stock_uom": "_Test UOM",
"stock_uom": "_Test UOM", "t_warehouse": "_Test Warehouse 1 - _TC",
"t_warehouse": "_Test Warehouse 1 - _TC", "transfer_qty": 45.0,
"transfer_qty": 45.0, "uom": "_Test UOM"
"uom": "_Test UOM" }
} ]
], },
"posting_date": "2013-01-25", {
"purpose": "Material Transfer", "company": "_Test Company",
"stock_entry_type": "Material Transfer" "doctype": "Stock Entry",
}, "purpose": "Repack",
"stock_entry_type": "Repack",
"items": [
{ {
"company": "_Test Company", "conversion_factor": 1.0,
"doctype": "Stock Entry", "cost_center": "_Test Cost Center - _TC",
"items": [ "doctype": "Stock Entry Detail",
{ "expense_account": "Stock Adjustment - _TC",
"conversion_factor": 1.0, "basic_rate": 100,
"cost_center": "_Test Cost Center - _TC", "item_code": "_Test Item",
"doctype": "Stock Entry Detail", "parentfield": "items",
"expense_account": "Stock Adjustment - _TC", "qty": 50.0,
"basic_rate": 100, "s_warehouse": "_Test Warehouse - _TC",
"item_code": "_Test Item", "stock_uom": "_Test UOM",
"parentfield": "items", "transfer_qty": 50.0,
"qty": 50.0, "uom": "_Test UOM"
"s_warehouse": "_Test Warehouse - _TC", },
"stock_uom": "_Test UOM", {
"transfer_qty": 50.0, "conversion_factor": 1.0,
"uom": "_Test UOM" "cost_center": "_Test Cost Center - _TC",
}, "doctype": "Stock Entry Detail",
{ "expense_account": "Stock Adjustment - _TC",
"conversion_factor": 1.0, "basic_rate": 5000,
"cost_center": "_Test Cost Center - _TC", "item_code": "_Test Item Home Desktop 100",
"doctype": "Stock Entry Detail", "parentfield": "items",
"expense_account": "Stock Adjustment - _TC", "qty": 1,
"basic_rate": 5000, "stock_uom": "_Test UOM",
"item_code": "_Test Item Home Desktop 100", "t_warehouse": "_Test Warehouse - _TC",
"parentfield": "items", "transfer_qty": 1,
"qty": 1, "uom": "_Test UOM"
"stock_uom": "_Test UOM", }
"t_warehouse": "_Test Warehouse - _TC", ]
"transfer_qty": 1, }
"uom": "_Test UOM"
}
],
"purpose": "Repack",
"stock_entry_type": "Repack"
}
] ]