From 33df0b4fbfdbe9225b5392bf2f5438249aa47fa4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 26 May 2018 09:09:02 +0530 Subject: [PATCH] Test case fixes (#14219) * Test case fixes * fetch_from fixes --- .../payment_schedule/payment_schedule.json | 5 ++-- .../doctype/crop_cycle/crop_cycle.json | 8 +++-- .../asset_maintenance_log.json | 8 +++-- erpnext/controllers/buying_controller.py | 3 +- .../doctype/opportunity/test_opportunity.py | 1 + .../doctype/fee_validity/test_fee_validity.py | 1 + .../lab_test_groups/lab_test_groups.json | 5 ++-- .../employee_benefit_application_detail.json | 5 ++-- .../employee_benefit_claim.json | 8 +++-- erpnext/hr/doctype/loan/loan.json | 7 +++-- .../loan_application/loan_application.json | 5 ++-- .../doctype/salary_slip/test_salary_slip.py | 6 ++-- .../travel_request/travel_request.json | 5 ++-- .../projects/doctype/timesheet/timesheet.py | 1 + erpnext/stock/doctype/item/test_records.json | 29 +++++++++---------- .../purchase_receipt_item.json | 8 +++-- .../stock_entry_detail.json | 5 ++-- erpnext/stock/get_item_details.py | 3 +- 18 files changed, 63 insertions(+), 50 deletions(-) diff --git a/erpnext/accounts/doctype/payment_schedule/payment_schedule.json b/erpnext/accounts/doctype/payment_schedule/payment_schedule.json index a145e852850..83e3ba0cd08 100644 --- a/erpnext/accounts/doctype/payment_schedule/payment_schedule.json +++ b/erpnext/accounts/doctype/payment_schedule/payment_schedule.json @@ -116,6 +116,7 @@ "bold": 0, "collapsible": 0, "columns": 2, + "fetch_from": "payment_term.invoice_portion", "fieldname": "invoice_portion", "fieldtype": "Percent", "hidden": 0, @@ -128,7 +129,7 @@ "label": "Invoice Portion", "length": 0, "no_copy": 0, - "options": "payment_term.invoice_portion", + "options": "", "permlevel": 0, "precision": "", "print_hide": 1, @@ -217,7 +218,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-05-16 22:43:31.890251", + "modified": "2018-05-25 22:43:31.890251", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Schedule", diff --git a/erpnext/agriculture/doctype/crop_cycle/crop_cycle.json b/erpnext/agriculture/doctype/crop_cycle/crop_cycle.json index 79e3abe70e2..f14213b687c 100644 --- a/erpnext/agriculture/doctype/crop_cycle/crop_cycle.json +++ b/erpnext/agriculture/doctype/crop_cycle/crop_cycle.json @@ -460,6 +460,7 @@ "collapsible": 0, "columns": 0, "description": "The minimum length between each plant in the field for optimum growth", + "fetch_from": "crop.crop_spacing", "fieldname": "crop_spacing", "fieldtype": "Float", "hidden": 0, @@ -472,7 +473,7 @@ "label": "Crop Spacing", "length": 0, "no_copy": 0, - "options": "crop.crop_spacing", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -555,6 +556,7 @@ "collapsible": 0, "columns": 0, "description": "The minimum distance between rows of plants for optimum growth", + "fetch_from": "crop.row_spacing", "fieldname": "row_spacing", "fieldtype": "Float", "hidden": 0, @@ -567,7 +569,7 @@ "label": "Row Spacing", "length": 0, "no_copy": 0, - "options": "crop.row_spacing", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -817,7 +819,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-16 22:43:33.462001", + "modified": "2018-05-25 22:43:33.462001", "modified_by": "Administrator", "module": "Agriculture", "name": "Crop Cycle", diff --git a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json index 45967b994ef..767097dd349 100644 --- a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json +++ b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json @@ -403,6 +403,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "task.next_due_date", "fieldname": "due_date", "fieldtype": "Date", "hidden": 0, @@ -415,7 +416,7 @@ "label": "Due Date", "length": 0, "no_copy": 0, - "options": "task.next_due_date", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -528,6 +529,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "task.has_certificate", "fieldname": "has_certificate", "fieldtype": "Check", "hidden": 0, @@ -540,7 +542,7 @@ "label": "Has Certificate ", "length": 0, "no_copy": 0, - "options": "task.has_certificate", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -753,7 +755,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-16 22:43:39.866477", + "modified": "2018-05-25 22:43:39.866477", "modified_by": "Administrator", "module": "Assets", "name": "Asset Maintenance Log", diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 83fe46a7bf0..40993922436 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -74,7 +74,8 @@ class BuyingController(StockController): def set_supplier_from_item_default(self): if self.meta.get_field("supplier") and not self.supplier: for d in self.get("items"): - supplier = frappe.db.get_value("Item", d.item_code, "default_supplier") + supplier = frappe.db.get_value("Item Default", + {"parent": d.item_code, "company": self.company}, "default_supplier") if supplier: self.supplier = supplier break diff --git a/erpnext/crm/doctype/opportunity/test_opportunity.py b/erpnext/crm/doctype/opportunity/test_opportunity.py index 1e969762aca..ef2945b41f9 100644 --- a/erpnext/crm/doctype/opportunity/test_opportunity.py +++ b/erpnext/crm/doctype/opportunity/test_opportunity.py @@ -64,6 +64,7 @@ def make_opportunity(**args): opp_doc = frappe.get_doc({ "doctype": "Opportunity", + "company": args.company or "_Test Company", "enquiry_from": args.enquiry_from or "Customer", "opportunity_type": "Sales", "with_items": args.with_items or 0, diff --git a/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py b/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py index 7ad673d5355..ed852f1ed14 100644 --- a/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py +++ b/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py @@ -61,5 +61,6 @@ def create_appointment(patient, physician, appointment_date, department): appointment.physician = physician appointment.department = department appointment.appointment_date = appointment_date + appointment.company = "_Test Company" appointment.save(ignore_permissions=True) return appointment diff --git a/erpnext/healthcare/doctype/lab_test_groups/lab_test_groups.json b/erpnext/healthcare/doctype/lab_test_groups/lab_test_groups.json index 8fa5c64b78b..82d88eeda08 100644 --- a/erpnext/healthcare/doctype/lab_test_groups/lab_test_groups.json +++ b/erpnext/healthcare/doctype/lab_test_groups/lab_test_groups.json @@ -84,6 +84,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "test_template.test_rate", "fieldname": "test_rate", "fieldtype": "Currency", "hidden": 0, @@ -96,7 +97,7 @@ "label": "Rate", "length": 0, "no_copy": 0, - "options": "test_template.test_rate", + "options": "", "permlevel": 0, "precision": "", "print_hide": 1, @@ -281,7 +282,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-05-16 22:43:38.667043", + "modified": "2018-05-25 22:43:38.667043", "modified_by": "Administrator", "module": "Healthcare", "name": "Lab Test Groups", diff --git a/erpnext/hr/doctype/employee_benefit_application_detail/employee_benefit_application_detail.json b/erpnext/hr/doctype/employee_benefit_application_detail/employee_benefit_application_detail.json index 37f32429e04..d2b1d2a9989 100644 --- a/erpnext/hr/doctype/employee_benefit_application_detail/employee_benefit_application_detail.json +++ b/erpnext/hr/doctype/employee_benefit_application_detail/employee_benefit_application_detail.json @@ -51,6 +51,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "earning_component.is_pro_rata_applicable", "fieldname": "is_pro_rata_applicable", "fieldtype": "Check", "hidden": 0, @@ -63,7 +64,7 @@ "label": "Is Pro-rata Applicable", "length": 0, "no_copy": 0, - "options": "earning_component.is_pro_rata_applicable", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -119,7 +120,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-05-15 12:03:25.545041", + "modified": "2018-05-25 12:03:25.545041", "modified_by": "Administrator", "module": "HR", "name": "Employee Benefit Application Detail", diff --git a/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.json b/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.json index 33fc942255d..a5b707f990e 100644 --- a/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.json +++ b/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.json @@ -210,6 +210,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "earning_component.max_benefit_amount", "fieldname": "max_amount_eligible", "fieldtype": "Currency", "hidden": 0, @@ -222,7 +223,7 @@ "label": "Max Amount Eligible", "length": 0, "no_copy": 0, - "options": "earning_component.max_benefit_amount", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -242,6 +243,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "earning_component.is_pro_rata_applicable", "fieldname": "is_pro_rata_applicable", "fieldtype": "Check", "hidden": 1, @@ -254,7 +256,7 @@ "label": "Is Pro-Rata Applicable", "length": 0, "no_copy": 0, - "options": "earning_component.is_pro_rata_applicable", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -434,7 +436,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-17 12:43:21.082282", + "modified": "2018-05-25 12:43:21.082282", "modified_by": "Administrator", "module": "HR", "name": "Employee Benefit Claim", diff --git a/erpnext/hr/doctype/loan/loan.json b/erpnext/hr/doctype/loan/loan.json index a073ec4048a..e305f54c35b 100644 --- a/erpnext/hr/doctype/loan/loan.json +++ b/erpnext/hr/doctype/loan/loan.json @@ -400,7 +400,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "", + "default": "", + "fetch_from": "loan_type.rate_of_interest", "fieldname": "rate_of_interest", "fieldtype": "Percent", "hidden": 0, @@ -413,7 +414,7 @@ "label": "Rate of Interest (%) / Year", "length": 0, "no_copy": 0, - "options": "loan_type.rate_of_interest", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -1072,7 +1073,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-04-08 15:32:58.948412", + "modified": "2018-05-25 15:32:58.948412", "modified_by": "Administrator", "module": "HR", "name": "Loan", diff --git a/erpnext/hr/doctype/loan_application/loan_application.json b/erpnext/hr/doctype/loan_application/loan_application.json index ea305efa6b3..44490df8886 100644 --- a/erpnext/hr/doctype/loan_application/loan_application.json +++ b/erpnext/hr/doctype/loan_application/loan_application.json @@ -491,6 +491,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "loan_type.rate_of_interest", "fieldname": "rate_of_interest", "fieldtype": "Percent", "hidden": 0, @@ -503,7 +504,7 @@ "label": "Rate of Interest", "length": 0, "no_copy": 0, - "options": "loan_type.rate_of_interest", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -718,7 +719,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-02-26 08:35:57.606555", + "modified": "2018-05-25 08:35:57.606555", "modified_by": "Administrator", "module": "HR", "name": "Loan Application", diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index ae58298bff2..1f913aaa737 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -270,7 +270,7 @@ def make_deduction_salary_component(salary_components): def make_salary_structure(sal_struct, payroll_frequency, employee): if not frappe.db.exists('Salary Structure', sal_struct): - frappe.get_doc({ + salary_structure = frappe.get_doc({ "doctype": "Salary Structure", "name": sal_struct, "company": "_Test Company", @@ -280,12 +280,10 @@ def make_salary_structure(sal_struct, payroll_frequency, employee): "payment_account": get_random("Account") }).insert() - create_salary_structure_assignment(employee, sal_struct) + create_salary_structure_assignment(employee, salary_structure) elif not frappe.db.get_value("Salary Structure Assignment",{'salary_structure':sal_struct, 'employee':employee},'name'): - sal_struct = frappe.get_doc("Salary Structure", sal_struct) create_salary_structure_assignment(employee, sal_struct) - sal_struct = sal_struct.name return sal_struct def create_salary_structure_assignment(employee, salary_structure): diff --git a/erpnext/hr/doctype/travel_request/travel_request.json b/erpnext/hr/doctype/travel_request/travel_request.json index 21968fa4b06..6146b49724f 100644 --- a/erpnext/hr/doctype/travel_request/travel_request.json +++ b/erpnext/hr/doctype/travel_request/travel_request.json @@ -461,6 +461,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "employee.date_of_birth", "fieldname": "date_of_birth", "fieldtype": "Date", "hidden": 0, @@ -473,7 +474,7 @@ "label": "Date of Birth", "length": 0, "no_copy": 0, - "options": "employee.date_of_birth", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -875,7 +876,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-16 22:43:34.438949", + "modified": "2018-05-25 22:43:34.438949", "modified_by": "Administrator", "module": "HR", "name": "Travel Request", diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index c358a542879..a5b7de1cdc4 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -343,6 +343,7 @@ def make_sales_invoice(source_name, item_code=None, customer=None): billing_amount = flt(timesheet.total_billable_amount) - flt(timesheet.total_billed_amount) billing_rate = billing_amount / hours + target.company = timesheet.company if customer: target.customer = customer diff --git a/erpnext/stock/doctype/item/test_records.json b/erpnext/stock/doctype/item/test_records.json index fdf8f6bc494..fc44fa70f77 100644 --- a/erpnext/stock/doctype/item/test_records.json +++ b/erpnext/stock/doctype/item/test_records.json @@ -4,7 +4,6 @@ "doctype": "Item", "has_batch_no": 0, "has_serial_no": 0, - "inspection_required": 0, "is_stock_item": 1, "is_sub_contracted_item": 0, @@ -20,7 +19,7 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }], "reorder_levels": [ { @@ -64,9 +63,8 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", - }], - + "income_account": "Sales - _TC" + }] }, { "description": "_Test Item Home Desktop 100 3", @@ -86,9 +84,8 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }], - "taxes": [ { "doctype": "Item Tax", @@ -116,7 +113,7 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }] }, { @@ -137,7 +134,7 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }] }, { @@ -158,7 +155,7 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }] }, { @@ -192,7 +189,7 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }] }, { @@ -214,7 +211,7 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }] }, { @@ -235,7 +232,7 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }] }, { @@ -256,7 +253,7 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }] }, { @@ -278,7 +275,7 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }], "attributes": [ { @@ -313,7 +310,7 @@ "expense_account": "_Test Account Cost for Goods Sold - _TC", "buying_cost_center": "_Test Cost Center - _TC", "selling_cost_center": "_Test Cost Center - _TC", - "income_account": "Sales - _TC", + "income_account": "Sales - _TC" }], "reorder_levels": [ { diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json index 87c9a757bf8..9607fb964c4 100755 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -632,6 +632,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "item_code.retain_sample", "fieldname": "retain_sample", "fieldtype": "Check", "hidden": 0, @@ -644,7 +645,7 @@ "label": "Retain Sample", "length": 0, "no_copy": 0, - "options": "item_code.retain_sample", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -665,6 +666,7 @@ "collapsible": 0, "columns": 0, "depends_on": "retain_sample", + "fetch_from": "item_code.sample_quantity", "fieldname": "sample_quantity", "fieldtype": "Int", "hidden": 0, @@ -677,7 +679,7 @@ "label": "Sample Quantity", "length": 0, "no_copy": 0, - "options": "item_code.sample_quantity", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -2492,7 +2494,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-05-07 13:42:05.061386", + "modified": "2018-05-25 13:42:05.061386", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item", diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json index 5fdab6f8f33..6176bf98a7d 100644 --- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json +++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json @@ -837,6 +837,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "item_code.retain_sample", "fieldname": "retain_sample", "fieldtype": "Check", "hidden": 0, @@ -849,7 +850,7 @@ "label": "Retain Sample", "length": 0, "no_copy": 0, - "options": "item_code.retain_sample", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -1469,7 +1470,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-03-05 13:09:25.849700", + "modified": "2018-05-25 13:09:25.849700", "modified_by": "Administrator", "module": "Stock", "name": "Stock Entry Detail", diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 68936acdb0b..59f43a6426e 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -289,8 +289,7 @@ def get_basic_details(args, item): ["Account", "expense_account", "default_expense_account"], ["Cost Center", "cost_center", "cost_center"], ["Warehouse", "warehouse", ""]]: - company = frappe.db.get_value(d[0], out.get(d[1]), "company") - if not out[d[1]] or (company and args.company != company): + if not out[d[1]]: out[d[1]] = frappe.db.get_value("Company", args.company, d[2]) if d[2] else None for fieldname in ("item_name", "item_group", "barcodes", "brand", "stock_uom"):