Merge pull request #23210 from michellealva/naming-series-proj
chore: Add Naming Series for Project DocType
This commit is contained in:
commit
5a1c469bf4
@ -122,8 +122,10 @@ class TestBudget(unittest.TestCase):
|
||||
|
||||
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
||||
|
||||
project = frappe.get_value("Project", {"project_name": "_Test Project"})
|
||||
|
||||
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||
"_Test Bank - _TC", 40000, "_Test Cost Center - _TC", project="_Test Project", posting_date=nowdate())
|
||||
"_Test Bank - _TC", 40000, "_Test Cost Center - _TC", project=project, posting_date=nowdate())
|
||||
|
||||
self.assertRaises(BudgetError, jv.submit)
|
||||
|
||||
@ -147,8 +149,11 @@ class TestBudget(unittest.TestCase):
|
||||
|
||||
budget = make_budget(budget_against="Project")
|
||||
|
||||
project = frappe.get_value("Project", {"project_name": "_Test Project"})
|
||||
|
||||
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||
"_Test Bank - _TC", 250000, "_Test Cost Center - _TC", project="_Test Project", posting_date=nowdate())
|
||||
"_Test Bank - _TC", 250000, "_Test Cost Center - _TC",
|
||||
project=project, posting_date=nowdate())
|
||||
|
||||
self.assertRaises(BudgetError, jv.submit)
|
||||
|
||||
@ -184,9 +189,11 @@ class TestBudget(unittest.TestCase):
|
||||
if month > 9:
|
||||
month = 9
|
||||
|
||||
project = frappe.get_value("Project", {"project_name": "_Test Project"})
|
||||
for i in range(month + 1):
|
||||
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||
"_Test Bank - _TC", 20000, "_Test Cost Center - _TC", posting_date=nowdate(), submit=True, project="_Test Project")
|
||||
"_Test Bank - _TC", 20000, "_Test Cost Center - _TC", posting_date=nowdate(), submit=True,
|
||||
project=project)
|
||||
|
||||
self.assertTrue(frappe.db.get_value("GL Entry",
|
||||
{"voucher_type": "Journal Entry", "voucher_no": jv.name}))
|
||||
@ -289,7 +296,7 @@ def make_budget(**args):
|
||||
budget = frappe.new_doc("Budget")
|
||||
|
||||
if budget_against == "Project":
|
||||
budget.project = "_Test Project"
|
||||
budget.project = frappe.get_value("Project", {"project_name": "_Test Project"})
|
||||
else:
|
||||
budget.cost_center =cost_center or "_Test Cost Center - _TC"
|
||||
|
||||
|
@ -160,7 +160,7 @@ class TestJournalEntry(unittest.TestCase):
|
||||
self.assertFalse(gle)
|
||||
|
||||
def test_reverse_journal_entry(self):
|
||||
from erpnext.accounts.doctype.journal_entry.journal_entry import make_reverse_journal_entry
|
||||
from erpnext.accounts.doctype.journal_entry.journal_entry import make_reverse_journal_entry
|
||||
jv = make_journal_entry("_Test Bank USD - _TC",
|
||||
"Sales - _TC", 100, exchange_rate=50, save=False)
|
||||
|
||||
@ -299,15 +299,20 @@ class TestJournalEntry(unittest.TestCase):
|
||||
|
||||
def test_jv_with_project(self):
|
||||
from erpnext.projects.doctype.project.test_project import make_project
|
||||
project = make_project({
|
||||
'project_name': 'Journal Entry Project',
|
||||
'project_template_name': 'Test Project Template',
|
||||
'start_date': '2020-01-01'
|
||||
})
|
||||
|
||||
if not frappe.db.exists("Project", {"project_name": "Journal Entry Project"}):
|
||||
project = make_project({
|
||||
'project_name': 'Journal Entry Project',
|
||||
'project_template_name': 'Test Project Template',
|
||||
'start_date': '2020-01-01'
|
||||
})
|
||||
project_name = project.name
|
||||
else:
|
||||
project_name = frappe.get_value("Project", {"project_name": "_Test Project"})
|
||||
|
||||
jv = make_journal_entry("_Test Cash - _TC", "_Test Bank - _TC", 100, save=False)
|
||||
for d in jv.accounts:
|
||||
d.project = project.project_name
|
||||
d.project = project_name
|
||||
jv.voucher_type = "Bank Entry"
|
||||
jv.multi_currency = 0
|
||||
jv.cheque_no = "112233"
|
||||
@ -317,10 +322,10 @@ class TestJournalEntry(unittest.TestCase):
|
||||
|
||||
expected_values = {
|
||||
"_Test Cash - _TC": {
|
||||
"project": project.project_name
|
||||
"project": project_name
|
||||
},
|
||||
"_Test Bank - _TC": {
|
||||
"project": project.project_name
|
||||
"project": project_name
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,26 +426,31 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_total_purchase_cost_for_project(self):
|
||||
make_project({'project_name':'_Test Project'})
|
||||
if not frappe.db.exists("Project", {"project_name": "_Test Project for Purchase"}):
|
||||
project = make_project({'project_name':'_Test Project for Purchase'})
|
||||
else:
|
||||
project = frappe.get_doc("Project", {"project_name": "_Test Project for Purchase"})
|
||||
|
||||
existing_purchase_cost = frappe.db.sql("""select sum(base_net_amount)
|
||||
from `tabPurchase Invoice Item` where project = '_Test Project' and docstatus=1""")
|
||||
from `tabPurchase Invoice Item`
|
||||
where project = '{0}'
|
||||
and docstatus=1""".format(project.name))
|
||||
existing_purchase_cost = existing_purchase_cost and existing_purchase_cost[0][0] or 0
|
||||
|
||||
pi = make_purchase_invoice(currency="USD", conversion_rate=60, project="_Test Project")
|
||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project", "total_purchase_cost"),
|
||||
pi = make_purchase_invoice(currency="USD", conversion_rate=60, project=project.name)
|
||||
self.assertEqual(frappe.db.get_value("Project", project.name, "total_purchase_cost"),
|
||||
existing_purchase_cost + 15000)
|
||||
|
||||
pi1 = make_purchase_invoice(qty=10, project="_Test Project")
|
||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project", "total_purchase_cost"),
|
||||
pi1 = make_purchase_invoice(qty=10, project=project.name)
|
||||
self.assertEqual(frappe.db.get_value("Project", project.name, "total_purchase_cost"),
|
||||
existing_purchase_cost + 15500)
|
||||
|
||||
pi1.cancel()
|
||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project", "total_purchase_cost"),
|
||||
self.assertEqual(frappe.db.get_value("Project", project.name, "total_purchase_cost"),
|
||||
existing_purchase_cost + 15000)
|
||||
|
||||
pi.cancel()
|
||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project", "total_purchase_cost"), existing_purchase_cost)
|
||||
self.assertEqual(frappe.db.get_value("Project", project.name, "total_purchase_cost"), existing_purchase_cost)
|
||||
|
||||
def test_return_purchase_invoice_with_perpetual_inventory(self):
|
||||
pi = make_purchase_invoice(company = "_Test Company with perpetual inventory", warehouse= "Stores - TCP1",
|
||||
@ -860,17 +865,17 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
})
|
||||
|
||||
pi = make_purchase_invoice(credit_to="Creditors - _TC" ,do_not_save=1)
|
||||
pi.items[0].project = item_project.project_name
|
||||
pi.project = project.project_name
|
||||
pi.items[0].project = item_project.name
|
||||
pi.project = project.name
|
||||
|
||||
pi.submit()
|
||||
|
||||
expected_values = {
|
||||
"Creditors - _TC": {
|
||||
"project": project.project_name
|
||||
"project": project.name
|
||||
},
|
||||
"_Test Account Cost for Goods Sold - _TC": {
|
||||
"project": item_project.project_name
|
||||
"project": item_project.name
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1573,17 +1573,17 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
})
|
||||
|
||||
sales_invoice = create_sales_invoice(do_not_save=1)
|
||||
sales_invoice.items[0].project = item_project.project_name
|
||||
sales_invoice.project = project.project_name
|
||||
sales_invoice.items[0].project = item_project.name
|
||||
sales_invoice.project = project.name
|
||||
|
||||
sales_invoice.submit()
|
||||
|
||||
expected_values = {
|
||||
"Debtors - _TC": {
|
||||
"project": project.project_name
|
||||
"project": project.name
|
||||
},
|
||||
"Sales - _TC": {
|
||||
"project": item_project.project_name
|
||||
"project": item_project.name
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class CropCycle(Document):
|
||||
|
||||
def import_disease_tasks(self, disease, start_date):
|
||||
disease_doc = frappe.get_doc('Disease', disease)
|
||||
self.create_task(disease_doc.treatment_task, self.name, start_date)
|
||||
self.create_task(disease_doc.treatment_task, self.project, start_date)
|
||||
|
||||
def create_project(self, period, crop_tasks):
|
||||
project = frappe.get_doc({
|
||||
|
@ -71,4 +71,4 @@ def check_task_creation():
|
||||
|
||||
|
||||
def check_project_creation():
|
||||
return True if frappe.db.exists('Project', 'Basil from seed 2017') else False
|
||||
return True if frappe.db.exists('Project', {'project_name': 'Basil from seed 2017'}) else False
|
||||
|
@ -38,7 +38,8 @@ class TestEmployeeOnboarding(unittest.TestCase):
|
||||
onboarding.insert()
|
||||
onboarding.submit()
|
||||
|
||||
self.assertEqual(onboarding.project, 'Employee Onboarding : Test Researcher - test@researcher.com')
|
||||
project_name = frappe.db.get_value("Project", onboarding.project, "project_name")
|
||||
self.assertEqual(project_name, 'Employee Onboarding : Test Researcher - test@researcher.com')
|
||||
|
||||
# don't allow making employee if onboarding is not complete
|
||||
self.assertRaises(IncompleteTaskError, make_employee, onboarding.name)
|
||||
|
@ -20,35 +20,36 @@ class TestExpenseClaim(unittest.TestCase):
|
||||
frappe.db.sql("""delete from `tabProject` where name = "_Test Project 1" """)
|
||||
frappe.db.sql("update `tabExpense Claim` set project = '', task = ''")
|
||||
|
||||
frappe.get_doc({
|
||||
project = frappe.get_doc({
|
||||
"project_name": "_Test Project 1",
|
||||
"doctype": "Project"
|
||||
}).save()
|
||||
})
|
||||
project.save()
|
||||
|
||||
task = frappe.get_doc(dict(
|
||||
doctype = 'Task',
|
||||
subject = '_Test Project Task 1',
|
||||
status = 'Open',
|
||||
project = '_Test Project 1'
|
||||
project = project.name
|
||||
)).insert()
|
||||
|
||||
task_name = task.name
|
||||
payable_account = get_payable_account(company_name)
|
||||
|
||||
make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4", "_Test Project 1", task_name)
|
||||
make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4", project.name, task_name)
|
||||
|
||||
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
|
||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200)
|
||||
self.assertEqual(frappe.db.get_value("Project", project.name, "total_expense_claim"), 200)
|
||||
|
||||
expense_claim2 = make_expense_claim(payable_account, 600, 500, company_name, "Travel Expenses - _TC4","_Test Project 1", task_name)
|
||||
expense_claim2 = make_expense_claim(payable_account, 600, 500, company_name, "Travel Expenses - _TC4", project.name, task_name)
|
||||
|
||||
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 700)
|
||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 700)
|
||||
self.assertEqual(frappe.db.get_value("Project", project.name, "total_expense_claim"), 700)
|
||||
|
||||
expense_claim2.cancel()
|
||||
|
||||
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
|
||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200)
|
||||
self.assertEqual(frappe.db.get_value("Project", project.name, "total_expense_claim"), 200)
|
||||
|
||||
def test_expense_claim_status(self):
|
||||
payable_account = get_payable_account(company_name)
|
||||
|
@ -2,12 +2,13 @@
|
||||
"actions": [],
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:project_name",
|
||||
"autoname": "naming_series:",
|
||||
"creation": "2013-03-07 11:55:07",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Setup",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"naming_series",
|
||||
"project_name",
|
||||
"status",
|
||||
"project_type",
|
||||
@ -440,13 +441,24 @@
|
||||
"fieldtype": "Text",
|
||||
"label": "Message",
|
||||
"mandatory_depends_on": "collect_progress"
|
||||
},
|
||||
{
|
||||
"fieldname": "naming_series",
|
||||
"fieldtype": "Select",
|
||||
"label": "Series",
|
||||
"no_copy": 1,
|
||||
"options": "PROJ-.####",
|
||||
"print_hide": 1,
|
||||
"reqd": 1,
|
||||
"set_only_once": 1
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-puzzle-piece",
|
||||
"idx": 29,
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"max_attachments": 4,
|
||||
"modified": "2020-04-08 22:11:14.552615",
|
||||
"modified": "2020-09-02 11:54:01.223620",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Project",
|
||||
@ -488,5 +500,6 @@
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"timeline_field": "customer",
|
||||
"title_field": "project_name",
|
||||
"track_seen": 1
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class TestProject(unittest.TestCase):
|
||||
task2 = task_exists("Test Template Task Child 1")
|
||||
if not task2:
|
||||
task2 = create_task(subject="Test Template Task Child 1", parent_task=task1.name, is_template=1, begin=1, duration=3)
|
||||
|
||||
|
||||
task3 = task_exists("Test Template Task Child 2")
|
||||
if not task3:
|
||||
task3 = create_task(subject="Test Template Task Child 2", parent_task=task1.name, is_template=1, begin=2, duration=3)
|
||||
@ -76,7 +76,7 @@ class TestProject(unittest.TestCase):
|
||||
task2 = task_exists("Test Template Task with Dependency")
|
||||
if not task2:
|
||||
task2 = create_task(subject="Test Template Task with Dependency", depends_on=task1.name, is_template=1, begin=2, duration=2)
|
||||
|
||||
|
||||
template = make_project_template("Test Project with Template - Dependent Tasks", [task1, task2])
|
||||
project = get_project(project_name, template)
|
||||
tasks = frappe.get_all('Task', ['subject','exp_end_date','depends_on_tasks', 'name'], dict(project=project.name), order_by='creation asc')
|
||||
@ -105,6 +105,9 @@ def get_project(name, template):
|
||||
def make_project(args):
|
||||
args = frappe._dict(args)
|
||||
|
||||
if args.project_name and frappe.db.exists("Project", {"project_name": args.project_name}):
|
||||
return frappe.get_doc("Project", {"project_name": args.project_name})
|
||||
|
||||
project = frappe.get_doc(dict(
|
||||
doctype = 'Project',
|
||||
project_name = args.project_name,
|
||||
@ -116,8 +119,7 @@ def make_project(args):
|
||||
template = make_project_template(args.project_template_name)
|
||||
project.project_template = template.name
|
||||
|
||||
if not frappe.db.exists("Project", args.project_name):
|
||||
project.insert()
|
||||
project.insert()
|
||||
|
||||
return project
|
||||
|
||||
|
@ -30,14 +30,16 @@ class TestTask(unittest.TestCase):
|
||||
})
|
||||
|
||||
def test_reschedule_dependent_task(self):
|
||||
project = frappe.get_value("Project", {"project_name": "_Test Project"})
|
||||
|
||||
task1 = create_task("_Test Task 1", nowdate(), add_days(nowdate(), 10))
|
||||
|
||||
task2 = create_task("_Test Task 2", add_days(nowdate(), 11), add_days(nowdate(), 15), task1.name)
|
||||
task2.get("depends_on")[0].project = "_Test Project"
|
||||
task2.get("depends_on")[0].project = project
|
||||
task2.save()
|
||||
|
||||
task3 = create_task("_Test Task 3", add_days(nowdate(), 11), add_days(nowdate(), 15), task2.name)
|
||||
task3.get("depends_on")[0].project = "_Test Project"
|
||||
task3.get("depends_on")[0].project = project
|
||||
task3.save()
|
||||
|
||||
task1.update({
|
||||
@ -104,7 +106,7 @@ def create_task(subject, start=None, end=None, depends_on=None, project=None, pa
|
||||
task.subject = subject
|
||||
task.exp_start_date = start or nowdate()
|
||||
task.exp_end_date = end or nowdate()
|
||||
task.project = project or None if is_template else "_Test Project"
|
||||
task.project = project or None if is_template else frappe.get_value("Project", {"project_name": "_Test Project"})
|
||||
task.is_template = is_template
|
||||
task.start = begin
|
||||
task.duration = duration
|
||||
|
@ -89,10 +89,11 @@ class TestTimesheet(unittest.TestCase):
|
||||
|
||||
def test_timesheet_billing_based_on_project(self):
|
||||
emp = make_employee("test_employee_6@salary.com")
|
||||
project = frappe.get_value("Project", {"project_name": "_Test Project"})
|
||||
|
||||
timesheet = make_timesheet(emp, simulate=True, billable=1, project = '_Test Project', company='_Test Company')
|
||||
timesheet = make_timesheet(emp, simulate=True, billable=1, project=project, company='_Test Company')
|
||||
sales_invoice = create_sales_invoice(do_not_save=True)
|
||||
sales_invoice.project = '_Test Project'
|
||||
sales_invoice.project = project
|
||||
sales_invoice.submit()
|
||||
|
||||
ts = frappe.get_doc('Timesheet', timesheet.name)
|
||||
|
Loading…
Reference in New Issue
Block a user