Merge branch 'develop' of https://github.com/frappe/erpnext into project-link-for-all-accounts

This commit is contained in:
Deepesh Garg
2020-06-19 11:41:21 +05:30
176 changed files with 4541 additions and 2499 deletions

View File

@@ -18,7 +18,7 @@ frappe.ui.form.on("Project", {
};
},
onload: function (frm) {
var so = frm.get_docfield("Project", "sales_order");
var so = frappe.meta.get_docfield("Project", "sales_order");
so.get_route_options_for_new_doc = function (field) {
if (frm.is_new()) return;
return {
@@ -135,4 +135,4 @@ function open_form(frm, doctype, child_doctype, parentfield) {
frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);
});
}
}

View File

@@ -64,7 +64,7 @@ class TestTask(unittest.TestCase):
def assign():
from frappe.desk.form import assign_to
assign_to.add({
"assign_to": "test@example.com",
"assign_to": ["test@example.com"],
"doctype": task.doctype,
"name": task.name,
"description": "Close this task"

View File

@@ -13,7 +13,7 @@ from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.hr.doctype.salary_structure.test_salary_structure \
import make_salary_structure, create_salary_structure_assignment
from erpnext.hr.doctype.employee.test_employee import make_employee
class TestTimesheet(unittest.TestCase):
def setUp(self):
@@ -25,8 +25,10 @@ class TestTimesheet(unittest.TestCase):
def test_timesheet_billing_amount(self):
make_salary_structure_for_timesheet("_T-Employee-00001")
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1)
emp = make_employee("test_employee_6@salary.com")
make_salary_structure_for_timesheet(emp)
timesheet = make_timesheet(emp, simulate=True, billable=1)
self.assertEqual(timesheet.total_hours, 2)
self.assertEqual(timesheet.total_billable_hours, 2)
@@ -35,8 +37,10 @@ class TestTimesheet(unittest.TestCase):
self.assertEqual(timesheet.total_billable_amount, 100)
def test_timesheet_billing_amount_not_billable(self):
make_salary_structure_for_timesheet("_T-Employee-00001")
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=0)
emp = make_employee("test_employee_6@salary.com")
make_salary_structure_for_timesheet(emp)
timesheet = make_timesheet(emp, simulate=True, billable=0)
self.assertEqual(timesheet.total_hours, 2)
self.assertEqual(timesheet.total_billable_hours, 0)
@@ -45,8 +49,10 @@ class TestTimesheet(unittest.TestCase):
self.assertEqual(timesheet.total_billable_amount, 0)
def test_salary_slip_from_timesheet(self):
salary_structure = make_salary_structure_for_timesheet("_T-Employee-00001")
timesheet = make_timesheet("_T-Employee-00001", simulate = True, billable=1)
emp = make_employee("test_employee_6@salary.com")
salary_structure = make_salary_structure_for_timesheet(emp)
timesheet = make_timesheet(emp, simulate = True, billable=1)
salary_slip = make_salary_slip(timesheet.name)
salary_slip.submit()
@@ -65,7 +71,9 @@ class TestTimesheet(unittest.TestCase):
self.assertEqual(timesheet.status, 'Submitted')
def test_sales_invoice_from_timesheet(self):
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1)
emp = make_employee("test_employee_6@salary.com")
timesheet = make_timesheet(emp, simulate=True, billable=1)
sales_invoice = make_sales_invoice(timesheet.name, '_Test Item', '_Test Customer')
sales_invoice.due_date = nowdate()
sales_invoice.submit()
@@ -80,7 +88,9 @@ class TestTimesheet(unittest.TestCase):
self.assertEqual(item.rate, 50.00)
def test_timesheet_billing_based_on_project(self):
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1, project = '_Test Project', company='_Test Company')
emp = make_employee("test_employee_6@salary.com")
timesheet = make_timesheet(emp, 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()
@@ -90,6 +100,8 @@ class TestTimesheet(unittest.TestCase):
self.assertEqual(ts.time_logs[0].sales_invoice, sales_invoice.name)
def test_timesheet_time_overlap(self):
emp = make_employee("test_employee_6@salary.com")
settings = frappe.get_single('Projects Settings')
initial_setting = settings.ignore_employee_time_overlap
settings.ignore_employee_time_overlap = 0
@@ -97,7 +109,7 @@ class TestTimesheet(unittest.TestCase):
update_activity_type("_Test Activity Type")
timesheet = frappe.new_doc("Timesheet")
timesheet.employee = "_T-Employee-00001"
timesheet.employee = emp
timesheet.append(
'time_logs',
{
@@ -129,12 +141,14 @@ class TestTimesheet(unittest.TestCase):
settings.save()
def test_timesheet_std_working_hours(self):
emp = make_employee("test_employee_6@salary.com")
company = frappe.get_doc('Company', "_Test Company")
company.standard_working_hours = 8
company.save()
timesheet = frappe.new_doc("Timesheet")
timesheet.employee = "_T-Employee-00001"
timesheet.employee = emp
timesheet.company = '_Test Company'
timesheet.append(
'time_logs',
@@ -156,7 +170,7 @@ class TestTimesheet(unittest.TestCase):
company.save()
timesheet = frappe.new_doc("Timesheet")
timesheet.employee = "_T-Employee-00001"
timesheet.employee = emp
timesheet.company = '_Test Company'
timesheet.append(
'time_logs',

View File

@@ -258,7 +258,12 @@ var calculate_end_time = function(frm, cdt, cdn) {
var update_billing_hours = function(frm, cdt, cdn){
var child = locals[cdt][cdn];
if(!child.billable) frappe.model.set_value(cdt, cdn, 'billing_hours', 0.0);
if(!child.billable) {
frappe.model.set_value(cdt, cdn, 'billing_hours', 0.0);
} else {
// bill all hours by default
frappe.model.set_value(cdt, cdn, "billing_hours", child.hours);
}
};
var update_time_rates = function(frm, cdt, cdn){