From 3db65ef7e86f997f15770c0053839caf3d7dd39b Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Tue, 15 Oct 2019 19:16:45 +0530 Subject: [PATCH 1/8] fix: Demo Script --- erpnext/demo/setup/setup_data.py | 28 +++++++----- erpnext/demo/user/accounts.py | 14 +++--- erpnext/demo/user/projects.py | 57 ------------------------ erpnext/demo/user/sales.py | 2 +- erpnext/setup/doctype/company/company.py | 2 +- 5 files changed, 28 insertions(+), 75 deletions(-) diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py index 48dcdbe8638..a395c7c17ae 100644 --- a/erpnext/demo/setup/setup_data.py +++ b/erpnext/demo/setup/setup_data.py @@ -10,13 +10,14 @@ from erpnext.demo.domains import data from frappe import _ def setup(domain): + frappe.flags.in_demo = 1 complete_setup(domain) setup_demo_page() setup_fiscal_year() setup_holiday_list() setup_user() setup_employee() - setup_user_roles() + setup_user_roles(domain) setup_role_permissions() setup_custom_field_for_domain() @@ -183,13 +184,19 @@ def setup_salary_structure(employees, salary_slip_based_on_timesheet=0): return ss -def setup_user_roles(): +def setup_user_roles(domain): user = frappe.get_doc('User', 'demo@erpnext.com') user.add_roles('HR User', 'HR Manager', 'Accounts User', 'Accounts Manager', 'Stock User', 'Stock Manager', 'Sales User', 'Sales Manager', 'Purchase User', 'Purchase Manager', 'Projects User', 'Manufacturing User', 'Manufacturing Manager', - 'Support Team', 'Academics User', 'Physician', 'Healthcare Administrator', 'Laboratory User', - 'Nursing User', 'Patient') + 'Support Team') + + if domain == "Healthcare": + user.add_roles('Physician', 'Healthcare Administrator', 'Laboratory User', + 'Nursing User', 'Patient') + + if domain == "Education": + user.add_roles('Academics User') if not frappe.db.get_global('demo_hr_user'): user = frappe.get_doc('User', 'CaitlinSnow@example.com') @@ -219,7 +226,7 @@ def setup_user_roles(): if not frappe.db.get_global('demo_manufacturing_user'): user = frappe.get_doc('User', 'NeptuniaAquaria@example.com') - user.add_roles('Manufacturing User', 'Stock User', 'Purchase User', 'Accounts User') + user.add_roles('Manufacturing User', 'Stock Manager', 'Stock User', 'Purchase User', 'Accounts User') update_employee_department(user.name, 'Production') frappe.db.set_global('demo_manufacturing_user', user.name) @@ -241,11 +248,12 @@ def setup_user_roles(): update_employee_department(user.name, 'Management') frappe.db.set_global('demo_projects_user', user.name) - if not frappe.db.get_global('demo_education_user'): - user = frappe.get_doc('User', 'ArthurCurry@example.com') - user.add_roles('Academics User') - update_employee_department(user.name, 'Management') - frappe.db.set_global('demo_education_user', user.name) + if domain == "Education": + if not frappe.db.get_global('demo_education_user'): + user = frappe.get_doc('User', 'ArthurCurry@example.com') + user.add_roles('Academics User') + update_employee_department(user.name, 'Management') + frappe.db.set_global('demo_education_user', user.name) #Add Expense Approver user = frappe.get_doc('User', 'ClarkKent@example.com') diff --git a/erpnext/demo/user/accounts.py b/erpnext/demo/user/accounts.py index 6206dfd2d03..7fab7722358 100644 --- a/erpnext/demo/user/accounts.py +++ b/erpnext/demo/user/accounts.py @@ -73,14 +73,16 @@ def work(): make_pos_invoice() def make_payment_entries(ref_doctype, report): - outstanding_invoices = list(set([r[3] for r in query_report.run(report, { - "report_date": frappe.flags.current_date, - "company": erpnext.get_default_company() - })["result"] if r[2]==ref_doctype])) + + outstanding_invoices = frappe.get_all(ref_doctype, fields=["name"], + filters={ + "company": erpnext.get_default_company(), + "outstanding_amount": (">", 0.0) + }) # make Payment Entry for inv in outstanding_invoices[:random.randint(1, 2)]: - pe = get_payment_entry(ref_doctype, inv) + pe = get_payment_entry(ref_doctype, inv.name) pe.posting_date = frappe.flags.current_date pe.reference_no = random_string(6) pe.reference_date = frappe.flags.current_date @@ -91,7 +93,7 @@ def make_payment_entries(ref_doctype, report): # make payment via JV for inv in outstanding_invoices[:1]: - jv = frappe.get_doc(get_payment_entry_against_invoice(ref_doctype, inv)) + jv = frappe.get_doc(get_payment_entry_against_invoice(ref_doctype, inv.name)) jv.posting_date = frappe.flags.current_date jv.cheque_no = random_string(6) jv.cheque_date = frappe.flags.current_date diff --git a/erpnext/demo/user/projects.py b/erpnext/demo/user/projects.py index 36d676f3173..044e2967fde 100644 --- a/erpnext/demo/user/projects.py +++ b/erpnext/demo/user/projects.py @@ -39,61 +39,4 @@ def make_project(current_date): "doctype": "Project", "project_name": "New Product Development " + current_date.strftime("%Y-%m-%d"), }) - project.set("tasks", [ - { - "title": "Review Requirements", - "start_date": frappe.utils.add_days(current_date, 10), - "end_date": frappe.utils.add_days(current_date, 11) - }, - { - "title": "Design Options", - "start_date": frappe.utils.add_days(current_date, 11), - "end_date": frappe.utils.add_days(current_date, 20) - }, - { - "title": "Make Prototypes", - "start_date": frappe.utils.add_days(current_date, 20), - "end_date": frappe.utils.add_days(current_date, 30) - }, - { - "title": "Customer Feedback on Prototypes", - "start_date": frappe.utils.add_days(current_date, 30), - "end_date": frappe.utils.add_days(current_date, 40) - }, - { - "title": "Freeze Feature Set", - "start_date": frappe.utils.add_days(current_date, 40), - "end_date": frappe.utils.add_days(current_date, 45) - }, - { - "title": "Testing", - "start_date": frappe.utils.add_days(current_date, 45), - "end_date": frappe.utils.add_days(current_date, 60) - }, - { - "title": "Product Engineering", - "start_date": frappe.utils.add_days(current_date, 45), - "end_date": frappe.utils.add_days(current_date, 55) - }, - { - "title": "Supplier Contracts", - "start_date": frappe.utils.add_days(current_date, 55), - "end_date": frappe.utils.add_days(current_date, 70) - }, - { - "title": "Design and Build Fixtures", - "start_date": frappe.utils.add_days(current_date, 45), - "end_date": frappe.utils.add_days(current_date, 65) - }, - { - "title": "Test Run", - "start_date": frappe.utils.add_days(current_date, 70), - "end_date": frappe.utils.add_days(current_date, 80) - }, - { - "title": "Launch", - "start_date": frappe.utils.add_days(current_date, 80), - "end_date": frappe.utils.add_days(current_date, 90) - }, - ]) project.insert() diff --git a/erpnext/demo/user/sales.py b/erpnext/demo/user/sales.py index 457e9763dc7..8d5ba28b79a 100644 --- a/erpnext/demo/user/sales.py +++ b/erpnext/demo/user/sales.py @@ -66,7 +66,7 @@ def make_opportunity(domain): b = frappe.get_doc({ "doctype": "Opportunity", "opportunity_from": "Customer", - "customer": get_random("Customer"), + "party_name": frappe.get_value("Customer", get_random("Customer"), 'name'), "opportunity_type": "Sales", "with_items": 1, "transaction_date": frappe.flags.current_date, diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 9eb374824a7..e69a6aaded4 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -204,7 +204,7 @@ class Company(NestedSet): }) for default_account in default_accounts: - if self.is_new() or frappe.flags.in_test: + if self.is_new() or frappe.flags.in_test or frappe.flags.in_demo: self._set_default_account(default_account, default_accounts.get(default_account)) if not self.default_income_account: From a32618dff46e5bfebb23f68c34ba42592b6d826a Mon Sep 17 00:00:00 2001 From: ashish-greycube Date: Wed, 16 Oct 2019 10:26:25 +0530 Subject: [PATCH 2/8] add coupon code on selling card of desk --- erpnext/config/selling.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py index 928bd5fa328..5db4cc27021 100644 --- a/erpnext/config/selling.py +++ b/erpnext/config/selling.py @@ -127,7 +127,11 @@ def get_data(): "name": "Shipping Rule", "description": _("Rules for adding shipping costs."), }, - + { + "type": "doctype", + "name": "Coupon Code", + "description": _("Define coupon codes."), + } ] }, { From c41e44d964a296145332eafee7c342456e5326ce Mon Sep 17 00:00:00 2001 From: ashish-greycube Date: Wed, 16 Oct 2019 10:38:31 +0530 Subject: [PATCH 3/8] fix: relative link in href --- erpnext/www/all-products/item_row.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/www/all-products/item_row.html b/erpnext/www/all-products/item_row.html index 9fa7fa35395..b61785aa2d1 100644 --- a/erpnext/www/all-products/item_row.html +++ b/erpnext/www/all-products/item_row.html @@ -2,7 +2,7 @@
@@ -10,7 +10,7 @@
- + {{ item.item_name or item.name }}
From 22bc0a929b7a6c1e6265c41fdf39d07dff9445f4 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Tue, 22 Oct 2019 13:14:57 +0530 Subject: [PATCH 4/8] chore(docs): Added contribution templates, SECURITY policy --- .github/ISSUE_TEMPLATE/bug_report.md | 47 +++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 28 +++++++++++ .../question-about-using-erpnext.md | 17 +++++++ .github/PULL_REQUEST_TEMPLATE.md | 33 ++++++++++++- SECURITY.md | 7 +++ 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/question-about-using-erpnext.md create mode 100644 SECURITY.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000000..c145291b57c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,47 @@ +--- +name: Bug report +about: Report a bug encountered while using ERPNext +labels: bug +--- + + + +## Description of the issue + +## Context information (for bug reports) + +**Output of `bench version`** +``` +(paste here) +``` + +## Steps to reproduce the issue + +1. +2. +3. + +### Observed result + +### Expected result + +### Stacktrace / full error message + +``` +(paste here) +``` + +## Additional information + +OS version / distribution, `ERPNext` install method, etc. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000000..6cdad356cd0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,28 @@ +--- +name: Feature request +about: Suggest an idea to improve ERPNext +labels: feature-request +--- + + + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/question-about-using-erpnext.md b/.github/ISSUE_TEMPLATE/question-about-using-erpnext.md new file mode 100644 index 00000000000..455c20ebda4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question-about-using-erpnext.md @@ -0,0 +1,17 @@ +--- +name: Question about using ERPNext +about: This is not the appropriate channel +labels: invalid +--- + +Please post on our forums: + +for questions about using `ERPNext`: https://discuss.erpnext.com + +for questions about using the `Frappe Framework`: https://discuss.frappe.io + +for questions about using `bench`, probably the best place to start is the [bench repo](https://github.com/frappe/bench) + +For documentation issues, use the [ERPNext Documentation](https://erpnext.com/docs/) or [Frappe Framework Documentation](https://frappe.io/docs/user/en) or the [developer cheetsheet](https://github.com/frappe/frappe/wiki/Developer-Cheatsheet) + +> **Posts that are not bug reports or feature requests will not be addressed on this issue tracker.** \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c0e186dbfd9..8fc5248b7b7 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,2 +1,33 @@ -Please read the pull request checklist to make sure your changes are merged: https://github.com/frappe/erpnext/wiki/Pull-Request-Checklist + + +> Please provide enough information so that others can review your pull request: + + + +> Explain the **details** for making this change. What existing problem does the pull request solve? + + + +> Screenshots/GIFs + + diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000000..46ed43725be --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,7 @@ +# Security Policy + +The ERPNext team and community take security issues seriously. To report a security issue, fill out the form at [https://erpnext.com/security/report](https://erpnext.com/security/report). + +You can help us make ERPNext and all it's users more secure by following the [Reporting guidelines](https://erpnext.com/security). + +We appreciate your efforts to responsibly disclose your findings. We'll endeavor to respond quickly, and will keep you updated throughout the process. \ No newline at end of file From ce77c4ac4cfb0cd667d607253bd3d3a25845e00a Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Tue, 22 Oct 2019 13:20:02 +0530 Subject: [PATCH 5/8] fix(docs): link update frappe => erpnext --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8fc5248b7b7..091cf4715a2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,7 +14,7 @@ Also, if you're new here - Documentation Guidelines => https://github.com/frappe/erpnext/wiki/Updating-Documentation -- Contribution Guide => https://github.com/frappe/frappe/blob/develop/.github/CONTRIBUTING.md +- Contribution Guide => https://github.com/frappe/erpnext/blob/develop/.github/CONTRIBUTING.md - Pull Request Checklist => https://github.com/frappe/erpnext/wiki/Pull-Request-Checklist From b5bd3f3abf1782f20e9ca2cf5122fd8fffbbae6d Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 22 Oct 2019 13:38:36 +0530 Subject: [PATCH 6/8] fix: custom doctypes and reports not visible in Accounts module view --- erpnext/config/{accounting.py => accounts.py} | 0 erpnext/config/desktop.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename erpnext/config/{accounting.py => accounts.py} (100%) diff --git a/erpnext/config/accounting.py b/erpnext/config/accounts.py similarity index 100% rename from erpnext/config/accounting.py rename to erpnext/config/accounts.py diff --git a/erpnext/config/desktop.py b/erpnext/config/desktop.py index 8ce096499dc..95f6f7c510c 100644 --- a/erpnext/config/desktop.py +++ b/erpnext/config/desktop.py @@ -18,7 +18,7 @@ def get_data(): "onboard_present": 1 }, { - "module_name": "Accounting", + "module_name": "Accounts", "category": "Modules", "label": _("Accounting"), "color": "#3498db", From d8ddd1e2ec0228ed9f795a88dd3ecb93fb554173 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 22 Oct 2019 14:03:27 +0530 Subject: [PATCH 7/8] fix: not able to select the zero qty batch while making the sales return entry --- erpnext/controllers/queries.py | 39 ++++++++++++-------- erpnext/public/js/controllers/transaction.js | 5 +++ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 19dea080b17..2f6b59f0fbe 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -280,22 +280,31 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters): "page_len": page_len } + having_clause = "having sum(sle.actual_qty) > 0" + if filters.get("is_return"): + having_clause = "" + if args.get('warehouse'): - batch_nos = frappe.db.sql("""select sle.batch_no, round(sum(sle.actual_qty),2), sle.stock_uom, concat('MFG-',batch.manufacturing_date), concat('EXP-',batch.expiry_date) - from `tabStock Ledger Entry` sle - INNER JOIN `tabBatch` batch on sle.batch_no = batch.name - where - batch.disabled = 0 - and sle.item_code = %(item_code)s - and sle.warehouse = %(warehouse)s - and (sle.batch_no like %(txt)s - or batch.manufacturing_date like %(txt)s) - and batch.docstatus < 2 - {0} - {match_conditions} - group by batch_no having sum(sle.actual_qty) > 0 - order by batch.expiry_date, sle.batch_no desc - limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args) + batch_nos = frappe.db.sql("""select sle.batch_no, round(sum(sle.actual_qty),2), sle.stock_uom, + concat('MFG-',batch.manufacturing_date), concat('EXP-',batch.expiry_date) + from `tabStock Ledger Entry` sle + INNER JOIN `tabBatch` batch on sle.batch_no = batch.name + where + batch.disabled = 0 + and sle.item_code = %(item_code)s + and sle.warehouse = %(warehouse)s + and (sle.batch_no like %(txt)s + or batch.manufacturing_date like %(txt)s) + and batch.docstatus < 2 + {cond} + {match_conditions} + group by batch_no {having_clause} + order by batch.expiry_date, sle.batch_no desc + limit %(start)s, %(page_len)s""".format( + cond=cond, + match_conditions=get_match_cond(doctype), + having_clause = having_clause + ), args) return batch_nos else: diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index a9b19eddd7e..57a1cc2ca19 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1652,6 +1652,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ 'item_code': item.item_code, 'posting_date': me.frm.doc.posting_date || frappe.datetime.nowdate(), } + + if (doc.is_return) { + filters["is_return"] = 1; + } + if (item.warehouse) filters["warehouse"] = item.warehouse; return { From 5ff377e2bb634034554a2d6fb6a5729460136730 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Wed, 23 Oct 2019 11:09:21 +0530 Subject: [PATCH 8/8] fix: product link not working in website (#19373) --- erpnext/www/all-products/item_row.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/www/all-products/item_row.html b/erpnext/www/all-products/item_row.html index 9fa7fa35395..9e628265aa6 100644 --- a/erpnext/www/all-products/item_row.html +++ b/erpnext/www/all-products/item_row.html @@ -2,7 +2,7 @@
@@ -10,14 +10,14 @@
- + {{ item.item_name or item.name }}

{{ item.website_description or item.description or 'No description' }}

- {{ _('More details') }} + {{ _('More details') }}