From a93b6654274b87d383c70a25820adfbaef2a69f0 Mon Sep 17 00:00:00 2001 From: Marica Date: Thu, 5 Sep 2019 18:26:45 +0530 Subject: [PATCH 01/13] fix: Print Format 'Point of Sale' removed from Sales invoice Print Format List (#18937) 'Point of Sale' Print Format for offline POS ,now doesn't appear in the Print Format Labels List in Sales Invoice for v12. --- .../point_of_sale/point_of_sale.json | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/erpnext/accounts/print_format/point_of_sale/point_of_sale.json b/erpnext/accounts/print_format/point_of_sale/point_of_sale.json index a8bedc2b66..c0c50cb4e2 100644 --- a/erpnext/accounts/print_format/point_of_sale/point_of_sale.json +++ b/erpnext/accounts/print_format/point_of_sale/point_of_sale.json @@ -1,22 +1,23 @@ { - "align_labels_right": 0, - "creation": "2016-05-05 17:16:18.564460", - "custom_format": 1, - "disabled": 0, - "doc_type": "Sales Invoice", - "docstatus": 0, - "doctype": "Print Format", - "font": "Default", - "html": "\n\n

\n\t{{ company }}
\n\t{{ __(\"POS No : \") }} {{ offline_pos_name }}
\n

\n

\n\t{{ __(\"Customer\") }}: {{ customer }}
\n

\n\n

\n\t{{ __(\"Date\") }}: {{ dateutil.global_date_format(posting_date) }}
\n

\n\n
\n\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\n\t\n\t\t{% for item in items %}\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t{% endfor %}\n\t\n
{{ __(\"Item\") }}{{ __(\"Qty\") }}{{ __(\"Amount\") }}
\n\t\t\t\t{{ item.item_name }}\n\t\t\t{{ format_number(item.qty, null,precision(\"difference\")) }}
@ {{ format_currency(item.rate, currency) }}
{{ format_currency(item.amount, currency) }}
\n\n\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t{% for row in taxes %}\n\t\t{% if not row.included_in_print_rate %}\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t{% endif %}\n\t\t{% endfor %}\n\t\t{% if discount_amount %}\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t{% endif %}\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\n
\n\t\t\t\t{{ __(\"Net Total\") }}\n\t\t\t\n\t\t\t\t{{ format_currency(total, currency) }}\n\t\t\t
\n\t\t\t\t{{ row.description }}\n\t\t\t\n\t\t\t\t{{ format_currency(row.tax_amount, currency) }}\n\t\t\t
\n\t\t\t\t{{ __(\"Discount\") }}\n\t\t\t\n\t\t\t\t{{ format_currency(discount_amount, currency) }}\n\t\t\t
\n\t\t\t\t{{ __(\"Grand Total\") }}\n\t\t\t\n\t\t\t\t{{ format_currency(grand_total, currency) }}\n\t\t\t
\n\t\t\t\t{{ __(\"Paid Amount\") }}\n\t\t\t\n\t\t\t\t{{ format_currency(paid_amount, currency) }}\n\t\t\t
\n\t\t\t\t{{ __(\"Qty Total\") }}\n\t\t\t\n\t\t\t\t{{ qty_total }}\n\t\t\t
\n\n\n
\n

{{ terms }}

\n

{{ __(\"Thank you, please visit again.\") }}

", - "idx": 0, - "line_breaks": 0, - "modified": "2018-03-21 09:10:16.693732", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Point of Sale", - "owner": "Administrator", - "print_format_builder": 0, - "print_format_type": "Js", - "show_section_headings": 0, + "align_labels_right": 0, + "creation": "2016-05-05 17:16:18.564460", + "custom_format": 1, + "disabled": 0, + "doc_type": "Sales Invoice", + "docstatus": 0, + "doctype": "Print Format", + "font": "Default", + "html": "\n\n

\n\t{{ company }}
\n\t{{ __(\"POS No : \") }} {{ offline_pos_name }}
\n

\n

\n\t{{ __(\"Customer\") }}: {{ customer }}
\n

\n\n

\n\t{{ __(\"Date\") }}: {{ dateutil.global_date_format(posting_date) }}
\n

\n\n
\n\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\n\t\n\t\t{% for item in items %}\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t{% endfor %}\n\t\n
{{ __(\"Item\") }}{{ __(\"Qty\") }}{{ __(\"Amount\") }}
\n\t\t\t\t{{ item.item_name }}\n\t\t\t{{ format_number(item.qty, null,precision(\"difference\")) }}
@ {{ format_currency(item.rate, currency) }}
{{ format_currency(item.amount, currency) }}
\n\n\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t{% for row in taxes %}\n\t\t{% if not row.included_in_print_rate %}\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t{% endif %}\n\t\t{% endfor %}\n\t\t{% if discount_amount %}\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t{% endif %}\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\n
\n\t\t\t\t{{ __(\"Net Total\") }}\n\t\t\t\n\t\t\t\t{{ format_currency(total, currency) }}\n\t\t\t
\n\t\t\t\t{{ row.description }}\n\t\t\t\n\t\t\t\t{{ format_currency(row.tax_amount, currency) }}\n\t\t\t
\n\t\t\t\t{{ __(\"Discount\") }}\n\t\t\t\n\t\t\t\t{{ format_currency(discount_amount, currency) }}\n\t\t\t
\n\t\t\t\t{{ __(\"Grand Total\") }}\n\t\t\t\n\t\t\t\t{{ format_currency(grand_total, currency) }}\n\t\t\t
\n\t\t\t\t{{ __(\"Paid Amount\") }}\n\t\t\t\n\t\t\t\t{{ format_currency(paid_amount, currency) }}\n\t\t\t
\n\t\t\t\t{{ __(\"Qty Total\") }}\n\t\t\t\n\t\t\t\t{{ qty_total }}\n\t\t\t
\n\n\n
\n

{{ terms }}

\n

{{ __(\"Thank you, please visit again.\") }}

", + "idx": 0, + "line_breaks": 0, + "modified": "2019-09-05 17:20:30.726659", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Point of Sale", + "owner": "Administrator", + "print_format_builder": 0, + "print_format_type": "JS", + "raw_printing": 0, + "show_section_headings": 0, "standard": "Yes" } \ No newline at end of file From bbc1b5cdcfb749101c5f9b65ccd855fa5255a7c1 Mon Sep 17 00:00:00 2001 From: Anurag Mishra <32095923+Anurag810@users.noreply.github.com> Date: Fri, 6 Sep 2019 12:10:37 +0530 Subject: [PATCH 02/13] feat: added date filter based on billing date and based date (#18935) --- erpnext/controllers/trends.py | 4 +- erpnext/public/js/purchase_trends_filters.js | 39 +++++++++++++------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py index 28a8fddfac..0404a1e6b0 100644 --- a/erpnext/controllers/trends.py +++ b/erpnext/controllers/trends.py @@ -39,7 +39,6 @@ def validate_filters(filters): frappe.throw(_("'Based On' and 'Group By' can not be same")) def get_data(filters, conditions): - data = [] inc, cond= '','' query_details = conditions["based_on_select"] + conditions["period_wise_select"] @@ -47,10 +46,11 @@ def get_data(filters, conditions): posting_date = 't1.transaction_date' if conditions.get('trans') in ['Sales Invoice', 'Purchase Invoice', 'Purchase Receipt', 'Delivery Note']: posting_date = 't1.posting_date' + if filters.period_based_on: + posting_date = 't1.'+filters.period_based_on if conditions["based_on_select"] in ["t1.project,", "t2.project,"]: cond = ' and '+ conditions["based_on_select"][:-1] +' IS Not NULL' - if conditions.get('trans') in ['Sales Order', 'Purchase Order']: cond += " and t1.status != 'Closed'" diff --git a/erpnext/public/js/purchase_trends_filters.js b/erpnext/public/js/purchase_trends_filters.js index 595a138f12..cd767f5d16 100644 --- a/erpnext/public/js/purchase_trends_filters.js +++ b/erpnext/public/js/purchase_trends_filters.js @@ -3,6 +3,14 @@ erpnext.get_purchase_trends_filters = function() { return [ + { + "fieldname":"company", + "label": __("Company"), + "fieldtype": "Link", + "options": "Company", + "reqd": 1, + "default": frappe.defaults.get_user_default("Company") + }, { "fieldname":"period", "label": __("Period"), @@ -15,6 +23,23 @@ erpnext.get_purchase_trends_filters = function() { ], "default": "Monthly" }, + { + "fieldname":"fiscal_year", + "label": __("Fiscal Year"), + "fieldtype": "Link", + "options":'Fiscal Year', + "default": frappe.sys_defaults.fiscal_year + }, + { + "fieldname":"period_based_on", + "label": __("Period based On"), + "fieldtype": "Select", + "options": [ + { "value": "posting_date", "label": __("Posting Date") }, + { "value": "bill_date", "label": __("Billing Date") }, + ], + "default": "posting_date" + }, { "fieldname":"based_on", "label": __("Based On"), @@ -39,19 +64,5 @@ erpnext.get_purchase_trends_filters = function() { ], "default": "" }, - { - "fieldname":"fiscal_year", - "label": __("Fiscal Year"), - "fieldtype": "Link", - "options":'Fiscal Year', - "default": frappe.sys_defaults.fiscal_year - }, - { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company") - }, ]; } From 1853a834536d4beb525f7ec9dfe692e365cfe7c7 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Tue, 10 Sep 2019 13:21:01 +0530 Subject: [PATCH 03/13] fix(packing-slip): add a descriptive message (#18981) --- erpnext/stock/doctype/packing_slip/packing_slip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.js b/erpnext/stock/doctype/packing_slip/packing_slip.js index 9f6b9ff191..bd14e5f616 100644 --- a/erpnext/stock/doctype/packing_slip/packing_slip.js +++ b/erpnext/stock/doctype/packing_slip/packing_slip.js @@ -10,7 +10,7 @@ cur_frm.fields_dict['delivery_note'].get_query = function(doc, cdt, cdn) { cur_frm.fields_dict['items'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) { if(!doc.delivery_note) { - frappe.throw(__("Please Delivery Note first")) + frappe.throw(__("Please select a Delivery Note")); } else { return { query: "erpnext.stock.doctype.packing_slip.packing_slip.item_details", @@ -125,4 +125,4 @@ cur_frm.pformat.gross_weight_pkg= function(doc){ return '' + make_row('Gross Weight', doc.gross_weight_pkg) + '
' } -// TODO: validate gross weight field \ No newline at end of file +// TODO: validate gross weight field From 0254217314f5fb24931d699366645142f8bc410a Mon Sep 17 00:00:00 2001 From: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> Date: Tue, 10 Sep 2019 14:07:05 +0530 Subject: [PATCH 04/13] fix: Make address fields mandatory (#18979) --- erpnext/public/js/utils/customer_quick_entry.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/public/js/utils/customer_quick_entry.js b/erpnext/public/js/utils/customer_quick_entry.js index f454ba057b..ac9a7828cb 100644 --- a/erpnext/public/js/utils/customer_quick_entry.js +++ b/erpnext/public/js/utils/customer_quick_entry.js @@ -37,7 +37,8 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ { label: __("Address Line 1"), fieldname: "address_line1", - fieldtype: "Data" + fieldtype: "Data", + reqd: 1 }, { label: __("Address Line 2"), @@ -55,7 +56,8 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ { label: __("City"), fieldname: "city", - fieldtype: "Data" + fieldtype: "Data", + reqd: 1, }, { label: __("State"), @@ -66,7 +68,8 @@ frappe.ui.form.CustomerQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ label: __("Country"), fieldname: "country", fieldtype: "Link", - options: "Country" + options: "Country", + reqd: 1 }, { label: __("Customer POS Id"), From 88e8688a4bfd3eb3f067454dec0949224ef666f9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 10 Sep 2019 14:07:45 +0530 Subject: [PATCH 05/13] fix: set raw material's batch based on main item's batch only if RM has batch no (#18977) --- erpnext/controllers/buying_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index a7dc4c738e..084f84b1f9 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -337,7 +337,7 @@ class BuyingController(StockController): if self.doctype in ["Purchase Receipt", "Purchase Invoice"]: rm.consumed_qty = required_qty rm.description = bom_item.description - if item.batch_no and not rm.batch_no: + if item.batch_no and frappe.db.get_value("Item", rm.rm_item_code, "has_batch_no") and not rm.batch_no: rm.batch_no = item.batch_no # get raw materials rate From e851346b4c0ed398fb4ff83f3512a743b8c9f056 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Tue, 10 Sep 2019 14:08:31 +0530 Subject: [PATCH 06/13] fix: dont make dashboards if company is not set (#18975) * fix: dont make dashboardss if company is not set * fix: function call * Update dashboard_charts.py --- .../setup/setup_wizard/data/dashboard_charts.py | 14 ++++++++++++-- .../setup_wizard/operations/install_fixtures.py | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/erpnext/setup/setup_wizard/data/dashboard_charts.py b/erpnext/setup/setup_wizard/data/dashboard_charts.py index 41cfcb529e..bb8c1319bf 100644 --- a/erpnext/setup/setup_wizard/data/dashboard_charts.py +++ b/erpnext/setup/setup_wizard/data/dashboard_charts.py @@ -3,8 +3,18 @@ from frappe import _ import frappe import json +def get_company_for_dashboards(): + company = frappe.defaults.get_defaults().company + if company: + return company + else: + company_list = frappe.get_list("Company") + if company_list: + return company_list[0].name + return None + def get_default_dashboards(): - company = frappe.get_doc("Company", frappe.defaults.get_defaults().company) + company = frappe.get_doc("Company", get_company_for_dashboards()) income_account = company.default_income_account or get_account("Income Account", company.name) expense_account = company.default_expense_account or get_account("Expense Account", company.name) bank_account = company.default_bank_account or get_account("Bank", company.name) @@ -104,4 +114,4 @@ def get_default_dashboards(): def get_account(account_type, company): accounts = frappe.get_list("Account", filters={"account_type": account_type, "company": company}) if accounts: - return accounts[0].name \ No newline at end of file + return accounts[0].name diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 6dbb89062e..b65716536d 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -501,6 +501,11 @@ def install_defaults(args=None): make_records(records) def add_dashboards(): + from erpnext.setup.setup_wizard.data.dashboard_charts import get_company_for_dashboards + + if not get_company_for_dashboards(): + return + from erpnext.setup.setup_wizard.data.dashboard_charts import get_default_dashboards from frappe.modules.import_file import import_file_by_path From bcda12f4bb90990d50ad84062535f78f73cf91b8 Mon Sep 17 00:00:00 2001 From: Sammish Thundiyil Date: Tue, 10 Sep 2019 11:41:02 +0300 Subject: [PATCH 07/13] modified: erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json (#18829) --- .../mode_of_payment/mode_of_payment.json | 221 +++++------------- 1 file changed, 62 insertions(+), 159 deletions(-) diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json index 9609e3d08b..f3df1f0bc9 100644 --- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json +++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.json @@ -1,171 +1,74 @@ { - "allow_copy": 0, - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:mode_of_payment", - "beta": 0, - "creation": "2012-12-04 17:49:20", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "Setup", - "editable_grid": 0, - "engine": "InnoDB", + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:mode_of_payment", + "creation": "2012-12-04 17:49:20", + "doctype": "DocType", + "document_type": "Setup", + "engine": "InnoDB", + "field_order": [ + "mode_of_payment", + "enabled", + "type", + "accounts" + ], "fields": [ { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "mode_of_payment", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Mode of Payment", - "length": 0, - "no_copy": 0, - "oldfieldname": "mode_of_payment", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, + "fieldname": "mode_of_payment", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Mode of Payment", + "oldfieldname": "mode_of_payment", + "oldfieldtype": "Data", + "reqd": 1, + "unique": 1 + }, { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "type", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 1, - "label": "Type", - "length": 0, - "no_copy": 0, - "options": "Cash\nBank\nGeneral", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, + "fieldname": "type", + "fieldtype": "Select", + "in_standard_filter": 1, + "label": "Type", + "options": "Cash\nBank\nGeneral" + }, { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "accounts", - "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Accounts", - "length": 0, - "no_copy": 0, - "options": "Mode of Payment Account", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 + "fieldname": "accounts", + "fieldtype": "Table", + "label": "Accounts", + "options": "Mode of Payment Account" + }, + { + "default": "1", + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled" } - ], - "hide_heading": 0, - "hide_toolbar": 0, - "icon": "fa fa-credit-card", - "idx": 1, - "image_view": 0, - "in_create": 0, - - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2017-02-17 16:31:34.207683", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Mode of Payment", - "owner": "harshada@webnotestech.com", + ], + "icon": "fa fa-credit-card", + "idx": 1, + "modified": "2019-08-14 14:58:42.079115", + "modified_by": "sammish.thundiyil@gmail.com", + "module": "Accounts", + "name": "Mode of Payment", + "owner": "harshada@webnotestech.com", "permissions": [ { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 1, - "delete": 0, - "email": 1, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Accounts Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "email": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "share": 1, "write": 1 - }, + }, { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 1, - "role": "Accounts User", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 + "read": 1, + "report": 1, + "role": "Accounts User" } - ], - "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 1, - "sort_order": "ASC", - "track_changes": 0, - "track_seen": 0 + ], + "quick_entry": 1, + "show_name_in_global_search": 1, + "sort_field": "modified", + "sort_order": "ASC" } \ No newline at end of file From a2fd1f22daf9805fe7cf967c5b241e4cfc37b752 Mon Sep 17 00:00:00 2001 From: Sahil Khan Date: Tue, 10 Sep 2019 14:58:39 +0550 Subject: [PATCH 08/13] bumped to version 12.1.2 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 106384ade0..cd1545c7e8 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '12.1.1' +__version__ = '12.1.2' def get_default_company(user=None): '''Get default company for user''' From a035428d43e0bce3a8dce8a8ccaaf5ed6867c52f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 10 Sep 2019 14:50:55 +0530 Subject: [PATCH 09/13] fix: handling of key does not exists error --- .../chart_of_accounts_importer/chart_of_accounts_importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py index 4683c7ae46..9bf5887b38 100644 --- a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py +++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py @@ -150,7 +150,7 @@ def validate_accounts(file_name): accounts_dict = {} for account in accounts: accounts_dict.setdefault(account["account_name"], account) - if account["parent_account"] and accounts_dict[account["parent_account"]]: + if account["parent_account"] and accounts_dict.get(account["parent_account"]): accounts_dict[account["parent_account"]]["is_group"] = 1 message = validate_root(accounts_dict) From 358a01a226b914658a2199a236002f2e80006122 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 10 Sep 2019 19:18:30 +0530 Subject: [PATCH 10/13] fix: Quotation Trends report not working for filter group by customer (#18989) --- erpnext/controllers/trends.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py index 0404a1e6b0..da44325a9e 100644 --- a/erpnext/controllers/trends.py +++ b/erpnext/controllers/trends.py @@ -54,6 +54,9 @@ def get_data(filters, conditions): if conditions.get('trans') in ['Sales Order', 'Purchase Order']: cond += " and t1.status != 'Closed'" + if conditions.get('trans') == 'Quotation' and filters.get("group_by") == 'Customer': + cond += " and t1.quotation_to = 'Customer'" + year_start_date, year_end_date = frappe.db.get_value("Fiscal Year", filters.get('fiscal_year'), ["year_start_date", "year_end_date"]) @@ -64,7 +67,7 @@ def get_data(filters, conditions): if filters.get("group_by") == 'Item': sel_col = 't2.item_code' elif filters.get("group_by") == 'Customer': - sel_col = 't1.customer' + sel_col = 't1.party_name' if conditions.get('trans') == 'Quotation' else 't1.customer' elif filters.get("group_by") == 'Supplier': sel_col = 't1.supplier' @@ -225,7 +228,7 @@ def based_wise_columns_query(based_on, trans): elif based_on == "Customer": based_on_details["based_on_cols"] = ["Customer:Link/Customer:120", "Territory:Link/Territory:120"] based_on_details["based_on_select"] = "t1.customer_name, t1.territory, " - based_on_details["based_on_group_by"] = 't1.customer' + based_on_details["based_on_group_by"] = 't1.party_name' if trans == 'Quotation' else 't1.customer' based_on_details["addl_tables"] = '' elif based_on == "Customer Group": From e919388ee69a7b1e23321ccfbf094f1a181039b5 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Wed, 11 Sep 2019 10:07:50 +0530 Subject: [PATCH 11/13] fix: do not cache value while creating item group, in setup wizard it will raise link validation error (#18992) --- erpnext/setup/doctype/item_group/item_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index b309b504e0..5603f17a54 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -29,7 +29,7 @@ class ItemGroup(NestedSet, WebsiteGenerator): super(ItemGroup, self).validate() if not self.parent_item_group and not frappe.flags.in_test: - if frappe.db.exists("Item Group", _('All Item Groups'), cache=True): + if frappe.db.exists("Item Group", _('All Item Groups')): self.parent_item_group = _('All Item Groups') self.make_route() From bb736248a29151f736543c09889a1fa6d5894e09 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Wed, 11 Sep 2019 10:20:49 +0530 Subject: [PATCH 12/13] fix: incorrect qty calculation in the production plan fopr the sub assembely work orders (#18970) --- erpnext/manufacturing/doctype/bom/bom.py | 2 ++ .../doctype/production_plan/production_plan.py | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 22c2f694f5..8eb4c9c28c 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -716,6 +716,8 @@ def get_children(doctype, parent=None, is_root=False, **filters): next(item for item in items if item.get('name') == bom_item.get('item_code')) ) + + bom_item.parent_bom_qty = bom_doc.quantity bom_item.expandable = 0 if bom_item.value in ('', None) else 1 return bom_items diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index 048ce0d6ef..b51420ffdb 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -301,7 +301,6 @@ class ProductionPlan(Document): wo_list.extend(work_orders) frappe.flags.mute_messages = False - if wo_list: wo_list = ["""%s""" % \ (p, p) for p in wo_list] @@ -309,15 +308,16 @@ class ProductionPlan(Document): else : msgprint(_("No Work Orders created")) + def make_work_order_for_sub_assembly_items(self, item): work_orders = [] bom_data = {} - get_sub_assembly_items(item.get("bom_no"), bom_data) + get_sub_assembly_items(item.get("bom_no"), bom_data, item.get("qty")) for key, data in bom_data.items(): data.update({ - 'qty': data.get("stock_qty") * item.get("qty"), + 'qty': data.get("stock_qty"), 'production_plan': self.name, 'company': self.company, 'fg_warehouse': item.get("fg_warehouse"), @@ -708,7 +708,7 @@ def get_item_data(item_code): "description": item_details.get("description") } -def get_sub_assembly_items(bom_no, bom_data): +def get_sub_assembly_items(bom_no, bom_data, qty): data = get_children('BOM', parent = bom_no) for d in data: if d.expandable: @@ -725,6 +725,6 @@ def get_sub_assembly_items(bom_no, bom_data): }) bom_item = bom_data.get(key) - bom_item["stock_qty"] += d.stock_qty + bom_item["stock_qty"] += ((d.stock_qty * qty) / d.parent_bom_qty) - get_sub_assembly_items(bom_item.get("bom_no"), bom_data) + get_sub_assembly_items(bom_item.get("bom_no"), bom_data, bom_item["stock_qty"]) From 7bcb24efbf922b6151bc2e3d11343ba8038c9acf Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Wed, 11 Sep 2019 10:49:33 +0530 Subject: [PATCH 13/13] fix(purchase-invoice): Update paid amount on creation of debit note (#18830) * fix(purchase-invoice): set paid amount for purchase return * fix(purchase-invoice): remove payment schedule on creation of debit note --- erpnext/controllers/accounts_controller.py | 31 ++++++++++--------- .../controllers/sales_and_purchase_return.py | 2 ++ .../public/js/controllers/taxes_and_totals.js | 6 ++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index f6d4eee518..37548ea9b8 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -89,7 +89,7 @@ class AccountsController(TransactionBase): self.validate_currency() if self.doctype == 'Purchase Invoice': - self.validate_paid_amount() + self.calculate_paid_amount() if self.doctype in ['Purchase Invoice', 'Sales Invoice']: pos_check_field = "is_pos" if self.doctype=="Sales Invoice" else "is_paid" @@ -135,22 +135,23 @@ class AccountsController(TransactionBase): else: df.set("print_hide", 1) - def validate_paid_amount(self): + def calculate_paid_amount(self): if hasattr(self, "is_pos") or hasattr(self, "is_paid"): is_paid = self.get("is_pos") or self.get("is_paid") - if cint(is_paid) == 1: - if flt(self.paid_amount) == 0 and flt(self.outstanding_amount) > 0: - if self.cash_bank_account: - self.paid_amount = flt(flt(self.outstanding_amount), self.precision("paid_amount")) - self.base_paid_amount = flt(self.paid_amount * self.conversion_rate, - self.precision("base_paid_amount")) - else: - # show message that the amount is not paid - self.paid_amount = 0 - frappe.throw( - _("Note: Payment Entry will not be created since 'Cash or Bank Account' was not specified")) - else: - frappe.db.set(self, 'paid_amount', 0) + + if is_paid: + if not self.cash_bank_account: + # show message that the amount is not paid + frappe.throw(_("Note: Payment Entry will not be created since 'Cash or Bank Account' was not specified")) + + if cint(self.is_return) and self.grand_total > self.paid_amount: + self.paid_amount = flt(flt(self.grand_total), self.precision("paid_amount")) + + elif not flt(self.paid_amount) and flt(self.outstanding_amount) > 0: + self.paid_amount = flt(flt(self.outstanding_amount), self.precision("paid_amount")) + + self.base_paid_amount = flt(self.paid_amount * self.conversion_rate, + self.precision("base_paid_amount")) def set_missing_values(self, for_validate=False): if frappe.flags.in_test: diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index b713958b1b..859529204b 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -246,6 +246,8 @@ def make_return_doc(doctype, source_name, target_doc=None): elif doc.doctype == 'Purchase Invoice': doc.paid_amount = -1 * source.paid_amount doc.base_paid_amount = -1 * source.base_paid_amount + doc.payment_terms_template = '' + doc.payment_schedule = [] if doc.get("is_return") and hasattr(doc, "packed_items"): for d in doc.get("packed_items"): diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 7cf2181e42..2ece711040 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -44,6 +44,12 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ this.calculate_contribution(); } + // Update paid amount on return/debit note creation + if(this.frm.doc.doctype === "Purchase Invoice" && this.frm.doc.is_return + && (this.frm.doc.grand_total > this.frm.doc.paid_amount)) { + this.frm.doc.paid_amount = flt(this.frm.doc.grand_total, precision("grand_total")); + } + this.frm.refresh_fields(); },