From 2705af488d4316b003907d40e47ae0f2bc5a048e Mon Sep 17 00:00:00 2001 From: Zarrar Date: Wed, 5 Sep 2018 17:20:07 +0530 Subject: [PATCH 1/6] [Minor] [Staging] POS Profile (#15321) * update modified date to load field display_items_in_stock * stop dialog from popping up if no loyalty program found * warehouse not used for not is_pos type invoice --- erpnext/accounts/doctype/pos_profile/pos_profile.json | 2 +- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 2 +- .../report/sales_payment_summary/sales_payment_summary.py | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json index cc0b93272e..610ed51dd7 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.json +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json @@ -1585,7 +1585,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-16 22:43:37.272875", + "modified": "2018-09-05 12:43:37.272875", "modified_by": "Administrator", "module": "Accounts", "name": "POS Profile", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 619776c674..305019d257 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -237,7 +237,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte "customer": this.frm.doc.customer }, callback: function(r) { - if(r.message) { + if(r.message.length) { select_loyalty_program(me.frm, r.message); } } diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py index 2ad41d6f30..05c8fb78de 100644 --- a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py @@ -37,7 +37,6 @@ def get_columns(filters): _("Sales and Returns") + ":Currency/currency:120", _("Taxes") + ":Currency/currency:120", _("Payments") + ":Currency/currency:120", - _("Warehouse") + ":Data:200" ] From 1b37186460d55199f9d1f4577963e622db418155 Mon Sep 17 00:00:00 2001 From: Zarrar Date: Thu, 6 Sep 2018 13:25:52 +0530 Subject: [PATCH 2/6] set POS Invoice format only if its enabled (#15326) --- erpnext/accounts/doctype/sales_invoice/pos.py | 4 ++-- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 6 +++++- erpnext/selling/page/point_of_sale/point_of_sale.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index a14c2344fe..4ec97c4446 100755 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -12,7 +12,7 @@ from erpnext.setup.utils import get_exchange_rate from erpnext.stock.get_item_details import get_pos_profile from frappe import _ from frappe.core.doctype.communication.email import make -from frappe.utils import nowdate +from frappe.utils import nowdate, cint from six import string_types, iteritems @@ -514,7 +514,7 @@ def make_email_queue(email_queue): name = frappe.db.get_value('Sales Invoice', {'offline_pos_name': key}, 'name') data = json.loads(data) sender = frappe.session.user - print_format = "POS Invoice" + print_format = "POS Invoice" if not cint(frappe.db.get_value('Print Format', 'POS Invoice', 'disabled')) else None attachments = [frappe.attach_print('Sales Invoice', name, print_format=print_format)] make(subject=data.get('subject'), content=data.get('content'), recipients=data.get('recipients'), diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 53d0fda1fc..2688b4ff01 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -289,9 +289,13 @@ class SalesInvoice(SellingController): super(SalesInvoice, self).set_missing_values(for_validate) + print_format = pos.get("print_format_for_online") + if not print_format and not cint(frappe.db.get_value('Print Format', 'POS Invoice', 'disabled')): + print_format = 'POS Invoice' + if pos: return { - "print_format": pos.get("print_format_for_online"), + "print_format": print_format, "allow_edit_rate": pos.get("allow_user_to_edit_rate"), "allow_edit_discount": pos.get("allow_user_to_edit_discount") } diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js index da72dc570f..a6f7a287be 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -519,7 +519,7 @@ erpnext.pos.PointOfSale = class PointOfSale { this.frm.cscript.calculate_taxes_and_totals(); if (r.message) { - this.frm.meta.default_print_format = r.message.print_format || 'POS Invoice'; + this.frm.meta.default_print_format = r.message.print_format || ""; this.frm.allow_edit_rate = r.message.allow_edit_rate; this.frm.allow_edit_discount = r.message.allow_edit_discount; } From 203baa9a3a144be665c198e168ef9b39604915e7 Mon Sep 17 00:00:00 2001 From: Zarrar Date: Thu, 6 Sep 2018 17:46:11 +0530 Subject: [PATCH 3/6] update modified date to load blanket order field (#15332) --- .../buying/doctype/purchase_order_item/purchase_order_item.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json index 0423588d05..52ec89c72d 100755 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json @@ -2341,7 +2341,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-08-06 05:16:58.258276", + "modified": "2018-09-06 15:14:18.663409", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order Item", From 7737620ff4e1ff3eaaa524e8c8a68665a0986e8f Mon Sep 17 00:00:00 2001 From: Zarrar Date: Fri, 7 Sep 2018 13:19:33 +0530 Subject: [PATCH 4/6] [Staging] Patch fix - Shopify Settings (#15338) * keep enable_shopify in Shopify Settings disabled by default * patch fix for shopify refactor * minor fallback fix --- .../doctype/sales_invoice/sales_invoice.py | 2 +- .../shopify_settings/shopify_settings.json | 7 ++++--- erpnext/patches.txt | 2 +- .../patches/v11_0/refactor_erpnext_shopify.py | 17 ++++++++++++++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 2688b4ff01..1227d3b64d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -289,7 +289,7 @@ class SalesInvoice(SellingController): super(SalesInvoice, self).set_missing_values(for_validate) - print_format = pos.get("print_format_for_online") + print_format = pos.get("print_format_for_online") if pos else None if not print_format and not cint(frappe.db.get_value('Print Format', 'POS Invoice', 'disabled')): print_format = 'POS Invoice' diff --git a/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json b/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json index cf1c0adc11..a7040f2f27 100644 --- a/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json +++ b/erpnext/erpnext_integrations/doctype/shopify_settings/shopify_settings.json @@ -49,7 +49,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "1", + "default": "", "fieldname": "enable_shopify", "fieldtype": "Check", "hidden": 0, @@ -1219,7 +1219,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2018-04-11 19:04:53.396557", + "modified": "2018-09-07 09:11:49.403176", "modified_by": "Administrator", "module": "ERPNext Integrations", "name": "Shopify Settings", @@ -1253,5 +1253,6 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 0, - "track_seen": 0 + "track_seen": 0, + "track_views": 0 } \ No newline at end of file diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 512e33bdb5..4d79bd5f0a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -538,7 +538,7 @@ erpnext.patches.v11_0.make_location_from_warehouse erpnext.patches.v11_0.make_asset_finance_book_against_old_entries erpnext.patches.v11_0.check_buying_selling_in_currency_exchange erpnext.patches.v11_0.move_item_defaults_to_child_table_for_multicompany #02-07-2018 -erpnext.patches.v11_0.refactor_erpnext_shopify +erpnext.patches.v11_0.refactor_erpnext_shopify #2018-09-07 erpnext.patches.v11_0.rename_overproduction_percent_field erpnext.patches.v11_0.update_backflush_subcontract_rm_based_on_bom erpnext.patches.v10_0.update_status_in_purchase_receipt diff --git a/erpnext/patches/v11_0/refactor_erpnext_shopify.py b/erpnext/patches/v11_0/refactor_erpnext_shopify.py index 68a37d5fd8..a91fda72fb 100644 --- a/erpnext/patches/v11_0/refactor_erpnext_shopify.py +++ b/erpnext/patches/v11_0/refactor_erpnext_shopify.py @@ -19,15 +19,26 @@ def execute(): frappe.db.sql("truncate `tabShopify Log`") setup_app_type() + else: + disable_shopify() def setup_app_type(): try: shopify_settings = frappe.get_doc("Shopify Settings") shopify_settings.app_type = 'Private' - shopify_settings.update_price_in_erpnext_price_list = 0 if getattr(shopify_settings, 'push_prices_to_shopify', None) else 1 + shopify_settings.update_price_in_erpnext_price_list = 0 if getattr(shopify_settings, 'push_prices_to_shopify', None) else 1 shopify_settings.flags.ignore_mandatory = True shopify_settings.ignore_permissions = True shopify_settings.save() except Exception: - frappe.db.set_value("Shopify Shopify", None, "enable_shopify", 0) - frappe.log_error(frappe.get_traceback()) \ No newline at end of file + frappe.db.set_value("Shopify Settings", None, "enable_shopify", 0) + frappe.log_error(frappe.get_traceback()) + +def disable_shopify(): + # due to frappe.db.set_value wrongly written and enable_shopify being default 1 + # Shopify Settings isn't properly configured and leads to error + shopify = frappe.get_doc('Shopify Settings') + + if shopify.app_type == "Public" or shopify.app_type == None or \ + (shopify.enable_shopify and not (shopify.shopify_url or shopify.api_key)): + frappe.db.set_value("Shopify Settings", None, "enable_shopify", 0) From ce6a09ca54c3378d70c0bdd1c968791369a710f8 Mon Sep 17 00:00:00 2001 From: Zarrar Date: Wed, 12 Sep 2018 10:54:18 +0530 Subject: [PATCH 5/6] [Staging] Stock Reconciliation (#15382) * optimize query and some fixes * add get_query to filter warehouses based on company * minor changes --- .../stock_reconciliation.js | 9 +++++- .../stock_reconciliation.py | 31 +++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index ce32e01d33..4d34d962d3 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -42,7 +42,14 @@ frappe.ui.form.on("Stock Reconciliation", { }, get_items: function(frm) { - frappe.prompt({label:"Warehouse", fieldtype:"Link", options:"Warehouse", reqd: 1}, + frappe.prompt({label:"Warehouse", fieldtype:"Link", options:"Warehouse", reqd: 1, + "get_query": function() { + return { + "filters": { + "company": frm.doc.company, + } + } + }}, function(data) { frappe.call({ method:"erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_items", diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 58255d4fad..5ec1db1993 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -271,28 +271,27 @@ class StockReconciliation(StockController): @frappe.whitelist() def get_items(warehouse, posting_date, posting_time, company): - items = [d.item_code for d in frappe.get_list("Bin", fields=["item_code"], filters={"warehouse": warehouse})] + items = frappe.db.sql('''select i.name, i.item_name from `tabItem` i, `tabBin` bin where i.name=bin.item_code + and i.disabled=0 and bin.warehouse=%s''', (warehouse), as_dict=True) - items += frappe.db.sql_list('''select i.name from `tabItem` i, `tabItem Default` id where i.name = id.parent + items += frappe.db.sql('''select i.name, i.item_name from `tabItem` i, `tabItem Default` id where i.name = id.parent and i.is_stock_item=1 and i.has_serial_no=0 and i.has_batch_no=0 and i.has_variants=0 and i.disabled=0 - and id.default_warehouse=%s and id.company=%s''', (warehouse, company)) + and id.default_warehouse=%s and id.company=%s group by i.name''', (warehouse, company), as_dict=True) res = [] - for item in set(items): - stock_bal = get_stock_balance(item[0], warehouse, posting_date, posting_time, + for item in items: + qty, rate = get_stock_balance(item.name, warehouse, posting_date, posting_time, with_valuation_rate=True) - if frappe.db.get_value("Item",item[0],"disabled") == 0: - - res.append({ - "item_code": item[0], - "warehouse": warehouse, - "qty": stock_bal[0], - "item_name": frappe.db.get_value('Item', item[0], 'item_name'), - "valuation_rate": stock_bal[1], - "current_qty": stock_bal[0], - "current_valuation_rate": stock_bal[1] - }) + res.append({ + "item_code": item.name, + "warehouse": warehouse, + "qty": qty, + "item_name": item.item_name, + "valuation_rate": rate, + "current_qty": qty, + "current_valuation_rate": rate + }) return res From 2b6584a2967e8e14d101f8853fa248b870cd05a6 Mon Sep 17 00:00:00 2001 From: Zarrar Date: Wed, 12 Sep 2018 11:14:24 +0530 Subject: [PATCH 6/6] accounts table should be mandatory in budget (#15386) --- erpnext/accounts/doctype/budget/budget.json | 9 +++++---- erpnext/accounts/doctype/budget/budget.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/budget/budget.json b/erpnext/accounts/doctype/budget/budget.json index ef8db86577..a803b65583 100644 --- a/erpnext/accounts/doctype/budget/budget.json +++ b/erpnext/accounts/doctype/budget/budget.json @@ -735,7 +735,7 @@ "read_only": 0, "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 0, + "reqd": 1, "search_index": 0, "set_only_once": 0, "translatable": 0, @@ -752,7 +752,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-06-15 17:09:01.430292", + "modified": "2018-09-12 11:02:41.825923", "modified_by": "Administrator", "module": "Accounts", "name": "Budget", @@ -785,6 +785,7 @@ "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", - "track_changes": 0, - "track_seen": 0 + "track_changes": 1, + "track_seen": 0, + "track_views": 0 } \ No newline at end of file diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py index b02126ff23..c83249b90c 100644 --- a/erpnext/accounts/doctype/budget/budget.py +++ b/erpnext/accounts/doctype/budget/budget.py @@ -36,7 +36,7 @@ class Budget(Document): b.name, ba.account from `tabBudget` b, `tabBudget Account` ba where ba.parent = b.name and b.docstatus < 2 and b.company = %s and %s=%s and - b.fiscal_year=%s and b.name != %sand ba.account in (%s) """ + b.fiscal_year=%s and b.name != %s and ba.account in (%s) """ % ('%s', budget_against_field, '%s', '%s', '%s', ','.join(['%s'] * len(accounts))), (self.company, budget_against, self.fiscal_year, self.name) + tuple(accounts), as_dict=1)