Data import Tool bug fix (#13165)
* fixes #13064 * commonified naming series checks * test fixes replaced test employee names according to naming series
This commit is contained in:
parent
e69747ca6d
commit
f2d28ebd6a
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe.defaults
|
||||
from frappe import msgprint, _
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe.model.naming import set_name_by_naming_series
|
||||
from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
from erpnext.accounts.party import validate_party_accounts, get_dashboard_info, get_timeline_data # keep this
|
||||
@ -28,7 +28,7 @@ class Supplier(TransactionBase):
|
||||
if supp_master_name == 'Supplier Name':
|
||||
self.name = self.supplier_name
|
||||
else:
|
||||
self.name = make_autoname(self.naming_series + '.#####')
|
||||
set_name_by_naming_series(self)
|
||||
|
||||
def on_update(self):
|
||||
if not self.naming_series:
|
||||
|
@ -6,7 +6,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe.model.naming import set_name_by_naming_series
|
||||
|
||||
class Instructor(Document):
|
||||
def autoname(self):
|
||||
@ -15,7 +15,7 @@ class Instructor(Document):
|
||||
frappe.throw(_("Please setup Instructor Naming System in Education > Education Settings"))
|
||||
else:
|
||||
if naming_method == 'Naming Series':
|
||||
self.name = make_autoname(self.naming_series + '.####')
|
||||
set_name_by_naming_series(self)
|
||||
elif naming_method == 'Employee Number':
|
||||
if not self.employee:
|
||||
frappe.throw(_("Please select Employee"))
|
||||
|
@ -1,12 +1,12 @@
|
||||
[
|
||||
{
|
||||
"naming_series": "_T-Instructor-",
|
||||
"employee": "_T-Employee-0001",
|
||||
"employee": "_T-Employee-00001",
|
||||
"instructor_name": "_Test Instructor"
|
||||
},
|
||||
{
|
||||
"naming_series": "_T-Instructor-",
|
||||
"employee": "_T-Employee-0002",
|
||||
"employee": "_T-Employee-00002",
|
||||
"instructor_name": "_Test Instructor 2"
|
||||
}
|
||||
]
|
||||
|
@ -8,7 +8,7 @@ from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import cint, cstr, getdate
|
||||
import dateutil
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe.model.naming import set_name_by_naming_series
|
||||
from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account,get_income_account,send_registration_sms
|
||||
|
||||
class Patient(Document):
|
||||
@ -42,10 +42,7 @@ class Patient(Document):
|
||||
if patient_master_name == 'Patient Name':
|
||||
self.name = self.get_patient_name()
|
||||
else:
|
||||
if not self.naming_series:
|
||||
frappe.throw(_("Series is mandatory"), frappe.MandatoryError)
|
||||
|
||||
self.name = make_autoname(self.naming_series+'.#####')
|
||||
set_name_by_naming_series(self)
|
||||
|
||||
def get_patient_name(self):
|
||||
name = self.patient_name
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
"doctype": "Attendance",
|
||||
"name": "_Test Attendance 1",
|
||||
"employee": "_T-Employee-0001",
|
||||
"employee": "_T-Employee-00001",
|
||||
"status": "Present",
|
||||
"attendance_date": "2014-02-01",
|
||||
"company": "_Test Company"
|
||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import getdate, validate_email_add, today, add_years
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe.model.naming import set_name_by_naming_series
|
||||
from frappe import throw, _, scrub
|
||||
import frappe.permissions
|
||||
from frappe.model.document import Document
|
||||
@ -24,7 +24,7 @@ class Employee(NestedSet):
|
||||
throw(_("Please setup Employee Naming System in Human Resource > HR Settings"))
|
||||
else:
|
||||
if naming_method == 'Naming Series':
|
||||
self.name = make_autoname(self.naming_series + '.####')
|
||||
set_name_by_naming_series(self)
|
||||
elif naming_method == 'Employee Number':
|
||||
self.name = self.employee_number
|
||||
elif naming_method == 'Full Name':
|
||||
|
@ -35,7 +35,7 @@ def make_payment_entry(advance):
|
||||
|
||||
def make_employee_advance():
|
||||
doc = frappe.new_doc("Employee Advance")
|
||||
doc.employee = "_T-Employee-0001"
|
||||
doc.employee = "_T-Employee-00001"
|
||||
doc.company = "_Test company"
|
||||
doc.purpose = "For site visit"
|
||||
doc.advance_amount = 1000
|
||||
@ -43,5 +43,5 @@ def make_employee_advance():
|
||||
doc.advance_account = "_Test Employee Advance - _TC"
|
||||
doc.insert()
|
||||
doc.submit()
|
||||
|
||||
|
||||
return doc
|
@ -87,7 +87,7 @@ def get_payable_account(company):
|
||||
def make_expense_claim(payable_account,claim_amount, sanctioned_amount, company, account, project=None, task_name=None):
|
||||
expense_claim = frappe.get_doc({
|
||||
"doctype": "Expense Claim",
|
||||
"employee": "_T-Employee-0001",
|
||||
"employee": "_T-Employee-00001",
|
||||
"payable_account": payable_account,
|
||||
"company": company,
|
||||
"expenses":
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
"docstatus": 1,
|
||||
"doctype": "Leave Allocation",
|
||||
"employee": "_T-Employee-0001",
|
||||
"employee": "_T-Employee-00001",
|
||||
"from_date": "2013-01-01",
|
||||
"to_date": "2013-12-31",
|
||||
"leave_type": "_Test Leave Type",
|
||||
@ -11,7 +11,7 @@
|
||||
{
|
||||
"docstatus": 1,
|
||||
"doctype": "Leave Allocation",
|
||||
"employee": "_T-Employee-0002",
|
||||
"employee": "_T-Employee-00002",
|
||||
"from_date": "2013-01-01",
|
||||
"to_date": "2013-12-31",
|
||||
"leave_type": "_Test Leave Type",
|
||||
|
@ -14,7 +14,7 @@ _test_records = [
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Leave Application",
|
||||
"employee": "_T-Employee-0001",
|
||||
"employee": "_T-Employee-00001",
|
||||
"from_date": "2013-05-01",
|
||||
"leave_type": "_Test Leave Type",
|
||||
"posting_date": "2013-01-02",
|
||||
@ -23,7 +23,7 @@ _test_records = [
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Leave Application",
|
||||
"employee": "_T-Employee-0002",
|
||||
"employee": "_T-Employee-00002",
|
||||
"from_date": "2013-05-01",
|
||||
"leave_type": "_Test Leave Type",
|
||||
"posting_date": "2013-01-02",
|
||||
@ -32,7 +32,7 @@ _test_records = [
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"doctype": "Leave Application",
|
||||
"employee": "_T-Employee-0001",
|
||||
"employee": "_T-Employee-00001",
|
||||
"from_date": "2013-01-15",
|
||||
"leave_type": "_Test Leave Type LWP",
|
||||
"posting_date": "2013-01-02",
|
||||
@ -188,7 +188,7 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
application.half_day_date = application.from_date
|
||||
|
||||
self.assertRaises(OverlapError, application.insert)
|
||||
|
||||
|
||||
def test_overlap_with_half_day_3(self):
|
||||
self._clear_roles()
|
||||
self._clear_applications()
|
||||
@ -206,14 +206,14 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
application.half_day = 1
|
||||
application.half_day_date = "2013-01-05"
|
||||
application.insert()
|
||||
|
||||
|
||||
# Apply leave from 4-7, half day on 5th
|
||||
application = self.get_application(_test_records[0])
|
||||
application.from_date = "2013-01-04"
|
||||
application.to_date = "2013-01-07"
|
||||
application.half_day = 1
|
||||
application.half_day_date = "2013-01-05"
|
||||
|
||||
|
||||
self.assertRaises(OverlapError, application.insert)
|
||||
|
||||
# Apply leave from 5-7, half day on 5th
|
||||
@ -230,15 +230,15 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
from frappe.utils.user import add_role
|
||||
add_role("test1@example.com", "Employee")
|
||||
add_role("test@example.com", "Leave Approver")
|
||||
self._add_employee_leave_approver("_T-Employee-0002", "test@example.com")
|
||||
self._add_employee_leave_approver("_T-Employee-00002", "test@example.com")
|
||||
|
||||
make_allocation_record(employee="_T-Employee-0002")
|
||||
make_allocation_record(employee="_T-Employee-00002")
|
||||
|
||||
application = self.get_application(_test_records[1])
|
||||
|
||||
frappe.db.set_value("Leave Block List", "_Test Leave Block List",
|
||||
"applies_to_all_departments", 1)
|
||||
frappe.db.set_value("Employee", "_T-Employee-0002", "department",
|
||||
frappe.db.set_value("Employee", "_T-Employee-00002", "department",
|
||||
"_Test Department")
|
||||
|
||||
frappe.set_user("test1@example.com")
|
||||
@ -255,7 +255,7 @@ def make_allocation_record(employee=None, leave_type=None):
|
||||
|
||||
allocation = frappe.get_doc({
|
||||
"doctype": "Leave Allocation",
|
||||
"employee": employee or "_T-Employee-0001",
|
||||
"employee": employee or "_T-Employee-00001",
|
||||
"leave_type": leave_type or "_Test Leave Type",
|
||||
"from_date": "2013-01-01",
|
||||
"to_date": "2015-12-31",
|
||||
|
@ -13,7 +13,7 @@ class TestActivityCost(unittest.TestCase):
|
||||
frappe.db.sql("delete from `tabActivity Cost`")
|
||||
activity_cost1 = frappe.new_doc('Activity Cost')
|
||||
activity_cost1.update({
|
||||
"employee": "_T-Employee-0001",
|
||||
"employee": "_T-Employee-00001",
|
||||
"employee_name": "_Test Employee",
|
||||
"activity_type": "_Test Activity Type 1",
|
||||
"billing_rate": 100,
|
||||
|
@ -14,8 +14,8 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal
|
||||
|
||||
class TestTimesheet(unittest.TestCase):
|
||||
def test_timesheet_billing_amount(self):
|
||||
make_salary_structure("_T-Employee-0001")
|
||||
timesheet = make_timesheet("_T-Employee-0001", simulate=True, billable=1)
|
||||
make_salary_structure("_T-Employee-00001")
|
||||
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1)
|
||||
|
||||
self.assertEqual(timesheet.total_hours, 2)
|
||||
self.assertEqual(timesheet.total_billable_hours, 2)
|
||||
@ -24,8 +24,8 @@ class TestTimesheet(unittest.TestCase):
|
||||
self.assertEqual(timesheet.total_billable_amount, 100)
|
||||
|
||||
def test_timesheet_billing_amount_not_billable(self):
|
||||
make_salary_structure("_T-Employee-0001")
|
||||
timesheet = make_timesheet("_T-Employee-0001", simulate=True, billable=0)
|
||||
make_salary_structure("_T-Employee-00001")
|
||||
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=0)
|
||||
|
||||
self.assertEqual(timesheet.total_hours, 2)
|
||||
self.assertEqual(timesheet.total_billable_hours, 0)
|
||||
@ -34,8 +34,8 @@ class TestTimesheet(unittest.TestCase):
|
||||
self.assertEqual(timesheet.total_billable_amount, 0)
|
||||
|
||||
def test_salary_slip_from_timesheet(self):
|
||||
salary_structure = make_salary_structure("_T-Employee-0001")
|
||||
timesheet = make_timesheet("_T-Employee-0001", simulate = True, billable=1)
|
||||
salary_structure = make_salary_structure("_T-Employee-00001")
|
||||
timesheet = make_timesheet("_T-Employee-00001", simulate = True, billable=1)
|
||||
salary_slip = make_salary_slip(timesheet.name)
|
||||
salary_slip.submit()
|
||||
|
||||
@ -44,7 +44,7 @@ class TestTimesheet(unittest.TestCase):
|
||||
self.assertEqual(salary_slip.net_pay, 150)
|
||||
self.assertEqual(salary_slip.timesheets[0].time_sheet, timesheet.name)
|
||||
self.assertEqual(salary_slip.timesheets[0].working_hours, 2)
|
||||
|
||||
|
||||
timesheet = frappe.get_doc('Timesheet', timesheet.name)
|
||||
self.assertEqual(timesheet.status, 'Payslip')
|
||||
salary_slip.cancel()
|
||||
@ -53,7 +53,7 @@ class TestTimesheet(unittest.TestCase):
|
||||
self.assertEqual(timesheet.status, 'Submitted')
|
||||
|
||||
def test_sales_invoice_from_timesheet(self):
|
||||
timesheet = make_timesheet("_T-Employee-0001", simulate=True, billable=1)
|
||||
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1)
|
||||
sales_invoice = make_sales_invoice(timesheet.name, '_Test Item', '_Test Customer')
|
||||
sales_invoice.due_date = nowdate()
|
||||
sales_invoice.submit()
|
||||
@ -68,7 +68,7 @@ class TestTimesheet(unittest.TestCase):
|
||||
self.assertEqual(item.rate, 50.00)
|
||||
|
||||
def test_timesheet_billing_based_on_project(self):
|
||||
timesheet = make_timesheet("_T-Employee-0001", simulate=True, billable=1, project = '_Test Project', company='_Test Company')
|
||||
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1, project = '_Test Project', company='_Test Company')
|
||||
sales_invoice = create_sales_invoice(do_not_save=True)
|
||||
sales_invoice.project = '_Test Project'
|
||||
sales_invoice.submit()
|
||||
@ -85,7 +85,7 @@ class TestTimesheet(unittest.TestCase):
|
||||
|
||||
update_activity_type("_Test Activity Type")
|
||||
timesheet = frappe.new_doc("Timesheet")
|
||||
timesheet.employee = "_T-Employee-0001"
|
||||
timesheet.employee = "_T-Employee-00001"
|
||||
timesheet.append(
|
||||
'time_logs',
|
||||
{
|
||||
@ -140,11 +140,11 @@ def make_salary_structure(employee):
|
||||
"base": 1200,
|
||||
"from_date": add_months(nowdate(),-1)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
es = salary_structure.append('earnings', {
|
||||
"salary_component": "_Test Allowance",
|
||||
"amount": 100
|
||||
"amount": 100
|
||||
})
|
||||
|
||||
ds = salary_structure.append('deductions', {
|
||||
|
@ -5,11 +5,11 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe.model.naming import set_name_by_naming_series
|
||||
|
||||
class Campaign(Document):
|
||||
def autoname(self):
|
||||
if frappe.defaults.get_global_default('campaign_naming_by') != 'Naming Series':
|
||||
self.name = self.campaign_name
|
||||
else:
|
||||
self.name = make_autoname(self.naming_series+'.#####')
|
||||
set_name_by_naming_series(self)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe.model.naming import set_name_by_naming_series
|
||||
from frappe import _, msgprint, throw
|
||||
import frappe.defaults
|
||||
from frappe.utils import flt, cint, cstr
|
||||
@ -31,10 +31,7 @@ class Customer(TransactionBase):
|
||||
if cust_master_name == 'Customer Name':
|
||||
self.name = self.get_customer_name()
|
||||
else:
|
||||
if not self.naming_series:
|
||||
frappe.throw(_("Series is mandatory"), frappe.MandatoryError)
|
||||
|
||||
self.name = make_autoname(self.naming_series+'.#####')
|
||||
set_name_by_naming_series(self)
|
||||
|
||||
def get_customer_name(self):
|
||||
if frappe.db.get_value("Customer", self.customer_name):
|
||||
|
@ -1,23 +1,23 @@
|
||||
[
|
||||
{
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-0001",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-00001",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"sales_person_name": "_Test Sales Person"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-0002",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-00002",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"sales_person_name": "_Test Sales Person 1"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-0003",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-00003",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"sales_person_name": "_Test Sales Person 2"
|
||||
}
|
||||
]
|
@ -53,8 +53,8 @@ class Item(WebsiteGenerator):
|
||||
template_item_name = frappe.db.get_value("Item", self.variant_of, "item_name")
|
||||
self.item_code = make_variant_item_code(self.variant_of, template_item_name, self)
|
||||
else:
|
||||
from frappe.model.naming import make_autoname
|
||||
self.item_code = make_autoname(self.naming_series + '.#####')
|
||||
from frappe.model.naming import set_name_by_naming_series
|
||||
set_name_by_naming_series(self)
|
||||
elif not self.item_code:
|
||||
msgprint(_("Item Code is mandatory because Item is not automatically numbered"), raise_exception=1)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user