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'));
}
if (doc.docstatus == 1) {
if (doc.docstatus === 1) {
cur_frm.add_custom_button(__('Maintenance Schedule'), function () {
cur_frm.cscript.make_maintenance_schedule();
}, __('Create'));

View File

@ -9,10 +9,9 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
def execute():
create_stock_entry_types()
company = frappe.get_cached_value("Company", {'country': 'India'}, 'name')
company = frappe.db.get_value("Company", {'country': 'India'}, 'name')
if company:
pass
# add_gst_hsn_code_field()
add_gst_hsn_code_field()
def create_stock_entry_types():
frappe.reload_doc('stock', 'doctype', 'stock_entry_type')

View File

@ -1,6 +1,5 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@ -20,7 +19,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "sales_person",
"fieldtype": "Link",
"hidden": 0,
@ -57,7 +55,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "contact_no",
"fieldtype": "Data",
"hidden": 1,
@ -93,7 +90,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "allocated_percentage",
"fieldtype": "Float",
"hidden": 0,
@ -122,40 +118,6 @@
"unique": 0,
"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_in_quick_entry": 0,
@ -163,7 +125,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "allocated_amount",
"fieldtype": "Currency",
"hidden": 0,
@ -200,8 +161,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "item_group.commission_rate",
"fetch_if_empty": 1,
"fieldname": "commission_rate",
"fieldtype": "Data",
"hidden": 0,
@ -234,7 +193,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "incentives",
"fieldtype": "Currency",
"hidden": 0,
@ -273,7 +231,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2019-03-15 00:06:59.441936",
"modified": "2018-09-17 13:03:14.755974",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Team",

View File

@ -21,7 +21,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "gs",
"fieldtype": "Section Break",
"hidden": 0,
@ -53,7 +52,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "item_group_name",
"fieldtype": "Data",
"hidden": 0,
@ -88,7 +86,6 @@
"collapsible": 0,
"columns": 0,
"description": "",
"fetch_if_empty": 0,
"fieldname": "parent_item_group",
"fieldtype": "Link",
"hidden": 0,
@ -124,7 +121,6 @@
"collapsible": 0,
"columns": 0,
"description": "Only leaf nodes are allowed in transaction",
"fetch_if_empty": 0,
"fieldname": "is_group",
"fieldtype": "Check",
"hidden": 0,
@ -159,71 +155,6 @@
"bold": 0,
"collapsible": 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",
"fieldtype": "Attach Image",
"hidden": 1,
@ -256,7 +187,36 @@
"bold": 0,
"collapsible": 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",
"fieldtype": "Section Break",
"hidden": 0,
@ -289,7 +249,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "item_group_defaults",
"fieldtype": "Table",
"hidden": 0,
@ -324,7 +283,6 @@
"collapsible": 0,
"collapsible_depends_on": "",
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "sec_break_taxes",
"fieldtype": "Section Break",
"hidden": 0,
@ -357,7 +315,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "taxes",
"fieldtype": "Table",
"hidden": 0,
@ -391,7 +348,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "sb9",
"fieldtype": "Section Break",
"hidden": 0,
@ -424,7 +380,6 @@
"collapsible": 0,
"columns": 0,
"description": "Check this if you want to show in website",
"fetch_if_empty": 0,
"fieldname": "show_in_website",
"fieldtype": "Check",
"hidden": 0,
@ -457,7 +412,6 @@
"collapsible": 0,
"columns": 0,
"depends_on": "show_in_website",
"fetch_if_empty": 0,
"fieldname": "route",
"fieldtype": "Data",
"hidden": 0,
@ -490,7 +444,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "weightage",
"fieldtype": "Int",
"hidden": 0,
@ -525,7 +478,6 @@
"columns": 0,
"depends_on": "show_in_website",
"description": "Show this slideshow at the top of the page",
"fetch_if_empty": 0,
"fieldname": "slideshow",
"fieldtype": "Link",
"hidden": 0,
@ -560,7 +512,6 @@
"columns": 0,
"depends_on": "show_in_website",
"description": "HTML / Banner that will show on the top of product list.",
"fetch_if_empty": 0,
"fieldname": "description",
"fieldtype": "Text Editor",
"hidden": 0,
@ -593,7 +544,6 @@
"collapsible": 0,
"columns": 0,
"depends_on": "show_in_website",
"fetch_if_empty": 0,
"fieldname": "website_specifications",
"fieldtype": "Table",
"hidden": 0,
@ -626,7 +576,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "lft",
"fieldtype": "Int",
"hidden": 1,
@ -660,7 +609,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "rgt",
"fieldtype": "Int",
"hidden": 1,
@ -695,7 +643,6 @@
"collapsible": 0,
"columns": 0,
"description": "",
"fetch_if_empty": 0,
"fieldname": "old_parent",
"fieldtype": "Link",
"hidden": 1,
@ -736,7 +683,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 3,
"modified": "2019-03-15 00:05:25.816002",
"modified": "2018-11-23 15:17:28.003933",
"modified_by": "Administrator",
"module": "Setup",
"name": "Item Group",

View File

@ -92,6 +92,8 @@ def install(country=None):
{'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 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
{'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.submit()

View File

@ -67,7 +67,10 @@ class TestBatch(unittest.TestCase):
rate = 10
)
]
)).insert()
))
stock_entry.set_stock_entry_type()
stock_entry.insert()
stock_entry.submit()
self.assertTrue(stock_entry.items[0].batch_no)
@ -136,7 +139,10 @@ class TestBatch(unittest.TestCase):
s_warehouse=receipt.items[0].warehouse,
)
]
)).insert()
))
stock_entry.set_stock_entry_type()
stock_entry.insert()
stock_entry.submit()
# assert same batch is selected
@ -193,7 +199,10 @@ class TestBatch(unittest.TestCase):
allow_zero_valuation_rate = 1
)
]
)).insert()
))
stock_entry.set_stock_entry_type()
stock_entry.insert()
stock_entry.submit()
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.submit()
@ -388,6 +390,7 @@ class TestMaterialRequest(unittest.TestCase):
# check for stopped status of Material Request
se = frappe.copy_doc(se_doc)
se.set_stock_entry_type()
se.insert()
mr.update_status('Stopped')
self.assertRaises(frappe.InvalidStatusError, se.submit)
@ -395,6 +398,7 @@ class TestMaterialRequest(unittest.TestCase):
mr.update_status('Submitted')
se = frappe.copy_doc(se_doc)
se.set_stock_entry_type()
se.insert()
se.submit()

View File

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

View File

@ -62,6 +62,7 @@ class StockEntry(StockController):
self.validate_inspection()
self.validate_fg_completed_qty()
self.set_job_card_data()
self.set_purpose_for_stock_entry()
if not self.from_bom:
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")])
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',
{'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):
"""Throw exception if more raw material is transferred against Purchase Order than in
the raw materials supplied table"""
@ -1248,12 +1254,10 @@ def move_sample_to_retention_warehouse(company, items):
if stock_entry.get('items'):
return stock_entry.as_dict()
@frappe.whitelist()
def make_stock_in_entry(source_name, target_doc=None):
def set_missing_values(source, target):
target.purpose = 'Stock In'
target.stock_entry_type = ''
target.set_stock_entry_type()
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`",
"`tabStock Entry`.`purpose`", "`tabStock Entry`.`work_order`", "`tabStock Entry`.`bom_no`"],
get_indicator: function (doc) {
debugger
if (doc.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
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"];
} else if (doc.docstatus === 2) {
return [__("Canceled"), "red", "docstatus,=,2"];

View File

@ -2,6 +2,8 @@
{
"company": "_Test Company",
"doctype": "Stock Entry",
"stock_entry_type": "Material Receipt",
"purpose": "Material Receipt",
"items": [
{
"conversion_factor": 1.0,
@ -17,15 +19,14 @@
"transfer_qty": 50.0,
"uom": "_Test UOM"
}
],
"stock_entry_type": "Material Receipt",
"purpose": "Material Receipt"
]
},
{
"company": "_Test Company",
"doctype": "Stock Entry",
"posting_date": "2013-01-25",
"purpose": "Material Issue",
"stock_entry_type": "Material Issue",
"items": [
{
"conversion_factor": 1.0,
@ -41,16 +42,14 @@
"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",
"stock_entry_type": "Material Transfer",
"items": [
{
"conversion_factor": 1.0,
@ -67,16 +66,13 @@
"transfer_qty": 45.0,
"uom": "_Test UOM"
}
],
"posting_date": "2013-01-25",
"purpose": "Material Transfer",
"stock_entry_type": "Material Transfer"
]
},
{
"company": "_Test Company",
"doctype": "Stock Entry",
"purpose": "Repack",
"stock_entry_type": "Repack",
"items": [
{
"conversion_factor": 1.0,
@ -106,8 +102,6 @@
"transfer_qty": 1,
"uom": "_Test UOM"
}
],
"purpose": "Repack",
"stock_entry_type": "Repack"
]
}
]