From 3f0dfd720fb9457422d76e6649725bced97ee3ab Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Fri, 27 Oct 2017 15:20:33 +0530 Subject: [PATCH 1/8] set the pos profile in the sales invoice --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 1c4fe3d084..888520ac76 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -305,6 +305,7 @@ class SalesInvoice(SellingController): self.account_for_change_amount = frappe.db.get_value('Company', self.company, 'default_cash_account') if pos: + self.pos_profile = pos.name if not for_validate and not self.customer: self.customer = pos.customer self.mode_of_payment = pos.mode_of_payment From b1616a0cb3d7ff078044204ddcf8dd3b054b2bb5 Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Fri, 27 Oct 2017 16:18:21 +0530 Subject: [PATCH 2/8] changes in thepos profile --- .../doctype/pos_profile/pos_profile.json | 324 ++++++++++++------ 1 file changed, 210 insertions(+), 114 deletions(-) diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json index 187454ef33..8136c98686 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.json +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json @@ -3,7 +3,7 @@ "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, - "autoname": "hash", + "autoname": "field:pos_profile_name", "beta": 0, "creation": "2013-05-24 12:15:51", "custom": 0, @@ -11,6 +11,96 @@ "doctype": "DocType", "editable_grid": 0, "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "0", + "fieldname": "disabled", + "fieldtype": "Check", + "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": "Disabled", + "length": 0, + "no_copy": 0, + "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 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "section_break_2", + "fieldtype": "Section Break", + "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, + "length": 0, + "no_copy": 0, + "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 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "pos_profile_name", + "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": "POS Profile Name", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "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 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -112,9 +202,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "depends_on": "update_stock", - "fieldname": "warehouse", - "fieldtype": "Link", + "fieldname": "ignore_pricing_rule", + "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -122,13 +211,11 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Warehouse", + "label": "Ignore Pricing Rule", "length": 0, "no_copy": 0, - "oldfieldname": "warehouse", - "oldfieldtype": "Link", - "options": "Warehouse", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -145,8 +232,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "campaign", - "fieldtype": "Link", + "fieldname": "allow_delete", + "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -154,10 +241,39 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Campaign", + "label": "Allow Delete", + "length": 0, + "no_copy": 0, + "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 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "allow_user_to_edit_rate", + "fieldtype": "Check", + "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": "Allow user to edit Rate", "length": 0, "no_copy": 0, - "options": "Campaign", "permlevel": 0, "precision": "", "print_hide": 0, @@ -300,7 +416,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "currency", + "depends_on": "update_stock", + "fieldname": "warehouse", "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, @@ -309,19 +426,19 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Currency", + "label": "Warehouse", "length": 0, "no_copy": 0, - "oldfieldname": "currency", - "oldfieldtype": "Select", - "options": "Currency", + "oldfieldname": "warehouse", + "oldfieldtype": "Link", + "options": "Warehouse", "permlevel": 0, "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 1, + "reqd": 0, "search_index": 0, "set_only_once": 0, "unique": 0 @@ -332,8 +449,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "ignore_pricing_rule", - "fieldtype": "Check", + "fieldname": "campaign", + "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -341,69 +458,10 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Ignore Pricing Rule", - "length": 0, - "no_copy": 0, - "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 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "allow_delete", - "fieldtype": "Check", - "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": "Allow Delete", - "length": 0, - "no_copy": 0, - "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 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "allow_user_to_edit_rate", - "fieldtype": "Check", - "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": "Allow user to edit Rate", + "label": "Campaign", "length": 0, "no_copy": 0, + "options": "Campaign", "permlevel": 0, "precision": "", "print_hide": 0, @@ -422,6 +480,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "depends_on": "", "fieldname": "section_break_11", "fieldtype": "Section Break", "hidden": 0, @@ -482,6 +541,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "depends_on": "", "fieldname": "section_break_14", "fieldtype": "Section Break", "hidden": 0, @@ -602,6 +662,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "depends_on": "", "fieldname": "section_break_16", "fieldtype": "Section Break", "hidden": 0, @@ -882,6 +943,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "depends_on": "", "fieldname": "offline_pos_section", "fieldtype": "Section Break", "hidden": 0, @@ -1037,6 +1099,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "depends_on": "", "fieldname": "section_break_19", "fieldtype": "Section Break", "hidden": 0, @@ -1046,6 +1109,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, + "label": "Accounting", "length": 0, "no_copy": 0, "permlevel": 0, @@ -1060,6 +1124,38 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "currency", + "fieldtype": "Link", + "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": "Currency", + "length": 0, + "no_copy": 0, + "oldfieldname": "currency", + "oldfieldtype": "Select", + "options": "Currency", + "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 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -1154,38 +1250,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "taxes_and_charges", - "fieldtype": "Link", - "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": "Taxes and Charges", - "length": 0, - "no_copy": 0, - "oldfieldname": "charge", - "oldfieldtype": "Link", - "options": "Sales Taxes and Charges Template", - "permlevel": 0, - "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 - }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -1309,6 +1373,38 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "taxes_and_charges", + "fieldtype": "Link", + "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": "Taxes and Charges", + "length": 0, + "no_copy": 0, + "oldfieldname": "charge", + "oldfieldtype": "Link", + "options": "Sales Taxes and Charges Template", + "permlevel": 0, + "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 } ], "has_web_view": 0, @@ -1322,7 +1418,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-09-01 15:55:14.890452", + "modified": "2017-10-27 06:45:32.957674", "modified_by": "Administrator", "module": "Accounts", "name": "POS Profile", From 40ef7e70392237d7d3e4d50669cb020f100588a0 Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Thu, 2 Nov 2017 16:04:16 +0530 Subject: [PATCH 3/8] patch for renaming the pos profile and setting the pos profile name --- erpnext/patches.txt | 1 + erpnext/patches/v9_0/set_pos_profile_name.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 erpnext/patches/v9_0/set_pos_profile_name.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index fd7a1b4da6..486cd7cbed 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -455,3 +455,4 @@ erpnext.patches.v9_0.add_healthcare_domain erpnext.patches.v9_0.set_variant_item_description erpnext.patches.v9_0.set_uoms_in_variant_field erpnext.patches.v9_0.copy_old_fees_field_data +erpnext.patches.v9_0.set_pos_profile_name diff --git a/erpnext/patches/v9_0/set_pos_profile_name.py b/erpnext/patches/v9_0/set_pos_profile_name.py new file mode 100644 index 0000000000..bc6e50e6b3 --- /dev/null +++ b/erpnext/patches/v9_0/set_pos_profile_name.py @@ -0,0 +1,19 @@ +# Copyright (c) 2017, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + doctype = 'POS Profile' + frappe.reload_doctype(doctype) + + for pos in frappe.get_all(doctype): + doc = frappe.get_doc(doctype, pos.name) + + if not doc.user: continue + + doc.pos_profile_name = doc.user + ' - ' + doc.company + doc.save() + + frappe.rename_doc(doctype, doc.name, doc.pos_profile_name, force=True) \ No newline at end of file From 57cc924d29988a9e9de5b4a31375261e184c279e Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 6 Nov 2017 18:42:37 +0530 Subject: [PATCH 4/8] [Fix] Fast clicking on an item, showing invalid grand total and quantity in the POS cart --- erpnext/selling/page/point_of_sale/point_of_sale.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 196bb960df..a0f8598ef8 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -43,6 +43,7 @@ erpnext.pos.PointOfSale = class PointOfSale { make() { return frappe.run_serially([ + () => frappe.dom.freeze(), () => { this.prepare_dom(); this.prepare_menu(); @@ -55,6 +56,7 @@ erpnext.pos.PointOfSale = class PointOfSale { frappe.timeout(1); this.make_items(); this.bind_events(); + frappe.dom.unfreeze(); }, () => this.page.set_title(__('Point of Sale')) ]); @@ -156,6 +158,7 @@ erpnext.pos.PointOfSale = class PointOfSale { } update_item_in_cart(item_code, field='qty', value=1) { + frappe.dom.freeze(); if(this.cart.exists(item_code)) { const item = this.frm.doc.items.find(i => i.item_code === item_code); frappe.flags.hide_serial_batch_dialog = false; @@ -220,6 +223,7 @@ erpnext.pos.PointOfSale = class PointOfSale { this.cart.add_item(item); this.cart.update_taxes_and_totals(); this.cart.update_grand_total(); + frappe.dom.unfreeze(); } update_item_in_frm(item, field, value) { @@ -232,8 +236,6 @@ erpnext.pos.PointOfSale = class PointOfSale { return frappe.model.set_value(item.doctype, item.name, field, value) .then(() => this.frm.script_manager.trigger('qty', item.doctype, item.name)) .then(() => { - console.log(item.qty, item.amount); - if (field === 'qty' && item.qty === 0) { frappe.model.clear_doc(item.doctype, item.name); } From 35fc45eff939b515ef07feadafa034a5d1eea798 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 6 Nov 2017 22:52:41 +0530 Subject: [PATCH 5/8] [fix] POS Profile test cases --- erpnext/accounts/doctype/pos_profile/test_pos_profile.py | 1 + erpnext/accounts/page/pos/test_pos.js | 1 + 2 files changed, 2 insertions(+) diff --git a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py index 803ee8e6c6..1e431739b5 100644 --- a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py @@ -41,6 +41,7 @@ def make_pos_profile(): "expense_account": "_Test Account Cost for Goods Sold - _TC", "income_account": "Sales - _TC", "name": "_Test POS Profile", + "pos_profile_name": "_Test POS Profile", "naming_series": "_T-POS Profile-", "selling_price_list": "_Test Price List", "territory": "_Test Territory", diff --git a/erpnext/accounts/page/pos/test_pos.js b/erpnext/accounts/page/pos/test_pos.js index 8913a9e1cc..e5524a2d92 100644 --- a/erpnext/accounts/page/pos/test_pos.js +++ b/erpnext/accounts/page/pos/test_pos.js @@ -6,6 +6,7 @@ QUnit.test("test:Sales Invoice", function(assert) { () => { return frappe.tests.make("POS Profile", [ {naming_series: "SINV"}, + {pos_profile_name: "_Test POS Profile"}, {country: "India"}, {currency: "INR"}, {write_off_account: "Write Off - FT"}, From f688af3809f9a763859fd3e8590032ef989a969e Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Wed, 8 Nov 2017 11:33:39 +0530 Subject: [PATCH 6/8] [fix] Offline pos name is not defined issue in the POS (#11469) --- erpnext/accounts/doctype/sales_invoice/pos.py | 1 + .../doctype/sales_invoice/sales_invoice.py | 7 -- erpnext/accounts/page/pos/pos.js | 80 +++++++------------ 3 files changed, 28 insertions(+), 60 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index 6856f62d0c..36c2365357 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -92,6 +92,7 @@ def update_pos_profile_data(doc, pos_profile, company_data): doc.customer_group = pos_profile.get('customer_group') or get_root('Customer Group') doc.territory = pos_profile.get('territory') or get_root('Territory') doc.terms = frappe.db.get_value('Terms and Conditions', pos_profile.get('tc_name'), 'terms') or doc.terms or '' + doc.offline_pos_name = '' def get_root(table): root = frappe.db.sql(""" select name from `tab%(table)s` having diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 888520ac76..995a333eba 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -70,7 +70,6 @@ class SalesInvoice(SellingController): self.clear_unallocated_advances("Sales Invoice Advance", "advances") self.add_remarks() self.validate_write_off_account() - self.validate_duplicate_offline_pos_entry() self.validate_account_for_change_amount() self.validate_fixed_asset() self.set_income_account_for_fixed_assets() @@ -464,12 +463,6 @@ class SalesInvoice(SellingController): if flt(self.write_off_amount) and not self.write_off_account: msgprint(_("Please enter Write Off Account"), raise_exception=1) - def validate_duplicate_offline_pos_entry(self): - if self.is_pos and self.offline_pos_name \ - and frappe.db.get_value('Sales Invoice', - {'offline_pos_name': self.offline_pos_name, 'docstatus': 1}): - frappe.throw(_("Duplicate offline pos sales invoice {0}").format(self.offline_pos_name)) - def validate_account_for_change_amount(self): if flt(self.change_amount) and not self.account_for_change_amount: msgprint(_("Please enter Account for Change Amount"), raise_exception=1) diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index c442062ab6..6b58033526 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -179,41 +179,12 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ } }, - dialog_actions: function () { - var me = this; - - $(this.list_body).find('.list-select-all').click(function () { - me.removed_items = []; - $(me.list_body).find('.list-delete').prop("checked", $(this).is(":checked")) - if ($(this).is(":checked")) { - $.each(me.si_docs, function (index, data) { - for (key in data) { - me.removed_items.push(key) - } - }) - } - - me.toggle_delete_button(); - }) - - $(this.list_body).find('.list-delete').click(function () { - me.name = $(this).parent().parent().attr('invoice-name'); - if ($(this).is(":checked")) { - me.removed_items.push(me.name); - } else { - me.removed_items.pop(me.name) - } - - me.toggle_delete_button(); - }) - }, - edit_record: function () { var me = this; doc_data = this.get_invoice_doc(this.si_docs); if (doc_data) { - this.frm.doc = doc_data[0][this.name]; + this.frm.doc = doc_data[0][this.frm.doc.offline_pos_name]; this.set_missing_values(); this.refresh(false); this.toggle_input_field(); @@ -226,16 +197,15 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.validate_list() this.remove_doc_from_localstorage() this.update_localstorage(); - // this.dialog_actions(); this.toggle_delete_button(); }, validate_list: function() { var me = this; this.si_docs = this.get_submitted_invoice() - $.each(this.removed_items, function(index, name){ + $.each(this.removed_items, function(index, pos_name){ $.each(me.si_docs, function(key, data){ - if(me.si_docs[key][name] && me.si_docs[key][name].offline_pos_name == name ){ + if(me.si_docs[key][pos_name] && me.si_docs[key][pos_name].offline_pos_name == pos_name ){ frappe.throw(__("Submitted orders can not be deleted")) } }) @@ -294,7 +264,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ return $.grep(this.si_docs, function (data) { for (key in data) { - return key == me.name + return key == me.frm.doc.offline_pos_name; } }) }, @@ -348,7 +318,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ create_new: function () { var me = this; this.frm = {} - this.name = null; this.load_data(true); this.setup(); this.set_default_customer() @@ -362,6 +331,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ if (load_doc) { this.frm.doc = JSON.parse(localStorage.getItem('doc')); + this.frm.doc.offline_pos_name = null; } $.each(this.meta, function (i, data) { @@ -629,6 +599,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ // this.list_customers.empty(); this.si_docs = this.get_doc_from_localstorage(); if (!this.si_docs.length) { + this.list_customers.find('.list-customers-table').html(""); return; } @@ -655,7 +626,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ me.list_customers_btn.toggleClass("view_customer"); me.pos_bill.show(); me.list_customers_btn.show(); - me.name = $(this).parents().attr('invoice-name') + me.frm.doc.offline_pos_name = $(this).parents().attr('invoice-name') me.edit_record(); }) @@ -675,11 +646,11 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ }); $(this.wrapper).find('.list-delete').click(function () { - me.name = $(this).parent().parent().attr('invoice-name'); + me.frm.doc.offline_pos_name = $(this).parent().parent().attr('invoice-name'); if ($(this).is(":checked")) { - me.removed_items.push(me.name); + me.removed_items.push(me.frm.doc.offline_pos_name); } else { - me.removed_items.pop(me.name) + me.removed_items.pop(me.frm.doc.offline_pos_name) } me.toggle_delete_button(); @@ -1435,7 +1406,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ }, update_paid_amount_status: function (update_paid_amount) { - if (this.name) { + if (this.frm.doc.offline_pos_name) { update_paid_amount = update_paid_amount ? false : true; } @@ -1643,18 +1614,17 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ create_invoice: function () { var me = this; - var invoice_data = {} + var invoice_data = {}; this.si_docs = this.get_doc_from_localstorage(); - if (this.name) { - this.update_invoice() + if (this.frm.doc.offline_pos_name) { + this.update_invoice(); } else { - this.name = $.now(); - this.frm.doc.offline_pos_name = this.name; + this.frm.doc.offline_pos_name = $.now(); this.frm.doc.posting_date = frappe.datetime.get_today(); this.frm.doc.posting_time = frappe.datetime.now_time(); this.frm.doc.pos_profile = this.pos_profile_data['name']; - invoice_data[this.name] = this.frm.doc - this.si_docs.push(invoice_data) + invoice_data[this.frm.doc.offline_pos_name] = this.frm.doc; + this.si_docs.push(invoice_data); this.update_localstorage(); this.set_primary_action(); } @@ -1666,12 +1636,12 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.si_docs = this.get_doc_from_localstorage(); $.each(this.si_docs, function (index, data) { for (var key in data) { - if (key == me.name) { + if (key == me.frm.doc.offline_pos_name) { me.si_docs[index][key] = me.frm.doc; me.update_localstorage(); } } - }) + }); }, update_localstorage: function () { @@ -1710,6 +1680,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ freeze_screen = this.freeze_screen || false; if ((this.si_docs.length || this.email_queue_list || this.customers_list) && !this.freeze) { + this.freeze = true; + frappe.call({ method: "erpnext.accounts.doctype.sales_invoice.pos.make_invoice", freeze: freeze_screen, @@ -1720,17 +1692,19 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ }, callback: function (r) { if (r.message) { + me.freeze = false; me.customers = r.message.synced_customers_list; me.address = r.message.synced_address; me.contacts = r.message.synced_contacts; me.removed_items = r.message.invoice; - me.removed_email = r.message.email_queue - me.removed_customers = r.message.customers + me.removed_email = r.message.email_queue; + me.removed_customers = r.message.customers; me.remove_doc_from_localstorage(); me.remove_email_queue_from_localstorage(); me.remove_customer_from_localstorage(); - me.prepare_customer_mapper() - me.autocomplete_customers() + me.prepare_customer_mapper(); + me.autocomplete_customers(); + me.render_list_customers(); } } }) From acc8995c482f91c60f571de7842758bfb56eb531 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 31 Oct 2017 16:16:42 +0530 Subject: [PATCH 7/8] [enhance] In item variants settings added provision, do not update the fields of variants from the template but will copy the value while making new variant aginst the template --- erpnext/stock/doctype/item/item.py | 3 +- .../item_variant_settings.json | 64 ++++++++++++++++++- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index bf8eaba0a2..844d62bd17 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -624,7 +624,8 @@ class Item(WebsiteGenerator): template_item.save() def update_variants(self): - if self.flags.dont_update_variants: + if self.flags.dont_update_variants or \ + frappe.db.get_single_value('Item Variant Settings', 'do_not_update_variants'): return if self.has_variants: updated = [] diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json index a29137c762..8bdd46c72d 100644 --- a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json +++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json @@ -12,6 +12,66 @@ "editable_grid": 1, "engine": "InnoDB", "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "section_break_3", + "fieldtype": "Section Break", + "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, + "length": 0, + "no_copy": 0, + "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 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "description": "If enabled then system will not update the fields of variants from the template but will copy the data of below mentioned fields while making new variant", + "fieldname": "do_not_update_variants", + "fieldtype": "Check", + "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": "Do not Update Variants", + "length": 0, + "no_copy": 0, + "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 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -84,8 +144,8 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2017-09-11 12:05:16.288601", - "modified_by": "rohit@erpnext.com", + "modified": "2017-11-08 11:38:12.821404", + "modified_by": "Administrator", "module": "Stock", "name": "Item Variant Settings", "name_case": "", From db781e607ab0c2fee3d7b4d7d4ab6f2b540a5bbd Mon Sep 17 00:00:00 2001 From: Saurabh Date: Wed, 8 Nov 2017 12:42:37 +0600 Subject: [PATCH 8/8] bumped to version 9.2.5 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 2812fa7a0b..c5d99719f7 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -4,7 +4,7 @@ import inspect import frappe from erpnext.hooks import regional_overrides -__version__ = '9.2.4' +__version__ = '9.2.5' def get_default_company(user=None): '''Get default company for user'''