[Fix] Customer delete, customer edit functionality, added country field in the pos profile
diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json
index a25dd51..9232cd3 100644
--- a/erpnext/accounts/doctype/pos_profile/pos_profile.json
+++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"autoname": "hash",
@@ -21,7 +22,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Applicable for User",
"length": 0,
"no_copy": 0,
@@ -50,7 +53,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Series",
"length": 0,
"no_copy": 1,
@@ -81,7 +86,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Update Stock",
"length": 0,
"no_copy": 0,
@@ -108,7 +115,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Warehouse",
"length": 0,
"no_copy": 0,
@@ -137,7 +146,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Campaign",
"length": 0,
"no_copy": 0,
@@ -165,7 +176,9 @@
"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,
@@ -191,7 +204,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Customer",
"length": 0,
"no_copy": 0,
@@ -220,7 +235,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Company",
"length": 0,
"no_copy": 0,
@@ -243,13 +260,45 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fieldname": "country",
+ "fieldtype": "Read Only",
+ "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": "Country",
+ "length": 0,
+ "no_copy": 0,
+ "options": "company.country",
+ "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_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,
@@ -278,7 +327,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Ignore Pricing Rule",
"length": 0,
"no_copy": 0,
@@ -305,7 +356,9 @@
"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,
@@ -332,7 +385,9 @@
"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,
@@ -359,7 +414,9 @@
"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,
@@ -385,7 +442,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Sales Invoice Payment",
"length": 0,
"no_copy": 0,
@@ -413,7 +472,9 @@
"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,
@@ -439,7 +500,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Item Groups",
"length": 0,
"no_copy": 0,
@@ -467,7 +530,9 @@
"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,
@@ -493,7 +558,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Customer Groups",
"length": 0,
"no_copy": 0,
@@ -521,7 +588,9 @@
"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,
@@ -548,7 +617,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Print Format",
"length": 0,
"no_copy": 0,
@@ -576,7 +647,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Letter Head",
"length": 0,
"no_copy": 0,
@@ -605,7 +678,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Print Heading",
"length": 0,
"no_copy": 0,
@@ -634,7 +709,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Terms and Conditions",
"length": 0,
"no_copy": 0,
@@ -663,7 +740,9 @@
"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,
"oldfieldtype": "Column Break",
@@ -690,7 +769,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Territory",
"length": 0,
"no_copy": 0,
@@ -719,7 +800,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Price List",
"length": 0,
"no_copy": 0,
@@ -748,7 +831,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Apply Discount",
"length": 0,
"no_copy": 0,
@@ -777,7 +862,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Apply Discount On",
"length": 0,
"no_copy": 0,
@@ -805,7 +892,9 @@
"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,
@@ -832,7 +921,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Write Off Account",
"length": 0,
"no_copy": 0,
@@ -860,7 +951,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Write Off Cost Center",
"length": 0,
"no_copy": 0,
@@ -888,7 +981,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Account for Change Amount",
"length": 0,
"no_copy": 0,
@@ -916,7 +1011,9 @@
"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,
@@ -945,7 +1042,9 @@
"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,
@@ -971,7 +1070,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Income Account",
"length": 0,
"no_copy": 0,
@@ -1001,7 +1102,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Expense Account",
"length": 0,
"no_copy": 0,
@@ -1028,7 +1131,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Cost Center",
"length": 0,
"no_copy": 0,
@@ -1047,18 +1152,18 @@
"unique": 0
}
],
+ "has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "icon-cog",
"idx": 1,
"image_view": 0,
"in_create": 0,
- "in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-12-28 15:14:59.411457",
+ "modified": "2017-03-10 16:53:56.390210",
"modified_by": "rohit@erpnext.com",
"module": "Accounts",
"name": "POS Profile",
@@ -1074,7 +1179,6 @@
"export": 0,
"if_owner": 0,
"import": 0,
- "is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
@@ -1095,7 +1199,6 @@
"export": 0,
"if_owner": 0,
"import": 0,
- "is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
@@ -1110,8 +1213,10 @@
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
+ "show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "user",
+ "track_changes": 0,
"track_seen": 0
}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index d24df3a..cfbd1b2 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -63,6 +63,8 @@
def update_pos_profile_data(doc, pos_profile, company_data):
doc.campaign = pos_profile.get('campaign')
+ if not pos_profile.get('country'):
+ pos_profile["country"] = company_data.country
doc.write_off_account = pos_profile.get('write_off_account') or \
company_data.write_off_account
@@ -273,17 +275,17 @@
return pricing_rules
@frappe.whitelist()
-def make_invoice(doc_list, email_queue_list, customers_list):
+def make_invoice(doc_list={}, email_queue_list={}, customers_list={}):
if isinstance(doc_list, basestring):
doc_list = json.loads(doc_list)
if isinstance(email_queue_list, basestring):
- email_queue = json.loads(email_queue_list)
+ email_queue_list = json.loads(email_queue_list)
if isinstance(customers_list, basestring):
- customers = json.loads(customers_list)
+ customers_list = json.loads(customers_list)
- customers = make_customer_and_address(customers)
+ customers = make_customer_and_address(customers_list)
name_list = []
for docs in doc_list:
for name, doc in docs.items():
@@ -297,7 +299,7 @@
else:
name_list.append(name)
- email_queue = make_email_queue(email_queue)
+ email_queue = make_email_queue(email_queue_list)
return {
'invoice': name_list,
'email_queue': email_queue,
@@ -330,8 +332,6 @@
def make_address(args, customer):
if args.get('name'):
address = frappe.get_doc('Address', args.get('name'))
- address.is_primary_address = 1
- address.is_shipping_address = 1
else:
address = frappe.new_doc('Address')
address.country = frappe.db.get_value('Company', args.get('company'), 'country')
@@ -340,6 +340,8 @@
'link_name': customer
})
+ address.is_primary_address = 1
+ address.is_shipping_address = 1
address.update(args)
address.save(ignore_permissions = True)
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 3dfe680..f3d311b 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -558,7 +558,7 @@
{'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 330}]
invoice_data = [{'09052016142': pos}]
- si = make_invoice(invoice_data)
+ si = make_invoice(invoice_data).get('invoice')
self.assertEquals(si[0], '09052016142')
sales_invoice = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': '09052016142', 'docstatus': 1})
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index 299e34a..b86f9e1 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -166,11 +166,6 @@
dialog_actions: function () {
var me = this;
- $(this.list_body).find('.list-column').click(function () {
- me.name = $(this).parents().attr('invoice-name')
- me.edit_record();
- })
-
$(this.list_body).find('.list-select-all').click(function () {
me.removed_items = [];
$(me.list_body).find('.list-delete').prop("checked", $(this).is(":checked"))
@@ -182,7 +177,7 @@
})
}
- me.toggle_primary_action();
+ me.toggle_delete_button();
})
$(this.list_body).find('.list-delete').click(function () {
@@ -193,7 +188,7 @@
me.removed_items.pop(me.name)
}
- me.toggle_primary_action();
+ me.toggle_delete_button();
})
},
@@ -212,19 +207,32 @@
delete_records: function () {
var me = this;
+ this.validate_list()
this.remove_doc_from_localstorage()
this.update_localstorage();
- this.dialog_actions();
- this.toggle_primary_action();
+ // this.dialog_actions();
+ this.toggle_delete_button();
},
- toggle_primary_action: function () {
+ validate_list: function() {
var me = this;
- if(this.frm.doc.allow_delete) {
+ this.si_docs = this.get_submitted_invoice()
+ $.each(this.removed_items, function(index, name){
+ $.each(me.si_docs, function(key, data){
+ if(me.si_docs[key][name] && me.si_docs[key][name].offline_pos_name == name ){
+ frappe.throw(__("Submitted orders can not be deleted"))
+ }
+ })
+ })
+ },
+
+ toggle_delete_button: function () {
+ var me = this;
+ if(this.pos_profile_data["allow_delete"]) {
if (this.removed_items && this.removed_items.length > 0) {
- $(this.wrapper).find('.btn-danger').show();
+ $(this.page.wrapper).find('.btn-danger').show();
} else {
- $(this.wrapper).find('.btn-danger').hide();
+ $(this.page.wrapper).find('.btn-danger').hide();
}
}
},
@@ -348,7 +356,6 @@
},
setup: function () {
- this.frm.doc.allow_delete = this.pos_profile_data["allow_delete"];
this.make();
this.set_primary_action();
this.party_field.$input.attr('disabled', false);
@@ -403,18 +410,6 @@
}, 1000);
});
- // this.search_item_group = frappe.ui.form.make_control({
- // df: {
- // "fieldtype": "Select",
- // "options": me.item_groups,
- // "label": __("Item Group"),
- // "fieldname": "item_group",
- // "placeholder": __("Item Group")
- // },
- // parent: this.wrapper.find(".search-item-group"),
- // only_input: true,
- // });
-
this.search_item_group = this.wrapper.find('.search-item-group');
var dropdown_html = me.item_groups.map(function(item_group) {
@@ -432,13 +427,6 @@
me.make_item_list();
})
- // this.search_item_group.make_input();
- // this.search_item_group.$input.on("change", function () {
- // me.page_len = 20;
- // me.items = me.get_items();
- // me.make_item_list();
- // });
-
me.toggle_more_btn();
this.wrapper.on("click", ".btn-more", function() {
@@ -499,17 +487,17 @@
$(this).toggleClass("view_customer");
if($(this).hasClass("view_customer")) {
me.render_list_customers();
- me.bind_delete_event()
- me.party_field.$input.attr('disabled', true);
me.list_customers.show();
me.pos_bill.hide();
me.numeric_keypad.hide();
+ me.toggle_delete_button()
} else {
if(me.frm.doc.docstatus == 0) {
me.party_field.$input.attr('disabled', false);
}
me.pos_bill.show();
me.toggle_totals_area(false);
+ me.toggle_delete_button()
me.list_customers.hide();
if(me.frm.doc.items.length > 0) {
me.numeric_keypad.show();
@@ -544,7 +532,7 @@
me.numeric_val += me.val;
me.selected_field.val(flt(me.numeric_val))
me.selected_field.trigger("change")
- me.render_selected_item()
+ // me.render_selected_item()
}
if(me.numeric_id && $(this).hasClass('pos-operation')) {
@@ -561,7 +549,7 @@
me.numeric_val = cstr(flt(me.selected_field.val())).slice(0, -1);
me.selected_field.val(me.numeric_val);
me.selected_field.trigger("change")
- me.render_selected_item()
+ // me.render_selected_item()
})
$(this.numeric_keypad).find('.pos-pay').click(function(){
@@ -578,27 +566,28 @@
this.removed_items = [];
// this.list_customers.empty();
this.si_docs = this.get_doc_from_localstorage();
-
if (!this.si_docs.length) {
return;
}
var html = "";
- this.si_docs.forEach(function (data, i) {
- for (key in data) {
- html += frappe.render_template("pos_invoice_list", {
- sr: i + 1,
- name: key,
- customer: data[key].customer,
- paid_amount: format_currency(data[key].paid_amount, me.frm.doc.currency),
- grand_total: format_currency(data[key].grand_total, me.frm.doc.currency),
- data: me.get_doctype_status(data[key])
- });
- }
- });
+ if(this.si_docs.length) {
+ this.si_docs.forEach(function (data, i) {
+ for (key in data) {
+ html += frappe.render_template("pos_invoice_list", {
+ sr: i + 1,
+ name: key,
+ customer: data[key].customer,
+ paid_amount: format_currency(data[key].paid_amount, me.frm.doc.currency),
+ grand_total: format_currency(data[key].grand_total, me.frm.doc.currency),
+ data: me.get_doctype_status(data[key])
+ });
+ }
+ });
+ }
this.list_customers.find('.list-customers-table').html(html);
- this.list_customers.find('.list-column').click(function () {
+ this.list_customers.on('click', '.customer-row', function () {
me.list_customers.hide();
me.numeric_keypad.show();
me.list_customers_btn.toggleClass("view_customer");
@@ -620,7 +609,7 @@
});
}
- me.toggle_primary_action();
+ me.toggle_delete_button();
});
$(this.wrapper).find('.list-delete').click(function () {
@@ -631,16 +620,17 @@
me.removed_items.pop(me.name)
}
- me.toggle_primary_action();
+ me.toggle_delete_button();
});
},
bind_delete_event: function() {
var me = this;
- $(this.wrapper).find('.btn-danger').click(function(){
+ $(this.page.wrapper).on('click', '.btn-danger', function(){
frappe.confirm(__("Delete permanently?"), function () {
me.delete_records();
+ me.list_customers.find('.list-customers-table').html("");
me.render_list_customers();
})
})
@@ -660,7 +650,7 @@
if(!this.party_field) {
if(this.page.wrapper.find('.pos-bill-toolbar').length === 0) {
$(frappe.render_template('customer_toolbar', {
- allow_delete: this.frm.doc.allow_delete
+ allow_delete: this.pos_profile_data["allow_delete"]
})).insertAfter(this.page.$title_area.hide());
}
@@ -678,6 +668,7 @@
this.party_field.make_input();
setTimeout(this.set_focus.bind(this), 500);
+ me.toggle_delete_button();
}
if (this.default_customer && !this.frm.doc.customer) {
@@ -817,6 +808,12 @@
"fieldtype": "Section Break"
},
{
+ "label": __("Address Name"),
+ "read_only": 1,
+ "fieldname": "name",
+ "fieldtype": "Data"
+ },
+ {
"label": __("Address Line 1"),
"fieldname": "address_line1",
"fieldtype": "Data"
@@ -827,11 +824,6 @@
"fieldtype": "Data"
},
{
- "label": __("Fax"),
- "fieldname": "fax",
- "fieldtype": "Data"
- },
- {
"fieldtype": "Column Break"
},
{
@@ -848,12 +840,6 @@
"label": __("ZIP Code"),
"fieldname": "pincode",
"fieldtype": "Data"
- },
- {
- "label": __("ZIP Code"),
- "hidden": 1,
- "fieldname": "name",
- "fieldtype": "Data"
}
]
})
@@ -870,15 +856,10 @@
render_address_data: function() {
var me = this;
this.address_data = this.address[this.frm.doc.customer] || this.get_address_from_localstorage();
- prompt_obj = me.customer_doc.fields_dict;
- $.each(this.address_data, function(key, value){
- if(prompt_obj[key] && key!='name') {
- prompt_obj[key].$input.val(value)
- }
- })
+ this.customer_doc.set_values(this.address_data)
- if(!prompt_obj.full_name.$input.val()) {
- prompt_obj.full_name.$input.val(this.frm.doc.customer)
+ if(!this.customer_doc.fields_dict.full_name.$input.val()) {
+ this.customer_doc.set_value("full_name", this.frm.doc.customer)
}
},
@@ -889,6 +870,7 @@
make_offline_customer: function() {
this.frm.doc.customer = this.frm.doc.customer || this.customer_doc.get_values().full_name;
+ this.customer_details = this.get_customers_details();
this.customer_details[this.frm.doc.customer] = this.get_prompt_details();
this.party_field.$input.val(this.frm.doc.customer);
this.customers.push({
@@ -902,7 +884,7 @@
get_prompt_details: function() {
this.prompt_details = this.customer_doc.get_values();
- this.prompt_details['country'] = this.frm.doc.country;
+ this.prompt_details['country'] = this.pos_profile_data.country;
return JSON.stringify(this.prompt_details)
},
@@ -1066,6 +1048,7 @@
var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code");
var qty = $(this).val();
me.update_qty(item_code, qty)
+ me.render_selected_item()
})
$(this.wrapper).find("[data-action='increase-qty']").on("click", function () {
@@ -1084,6 +1067,7 @@
var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code");
var discount = $(this).val();
me.update_discount(item_code, discount)
+ me.render_selected_item()
})
},
@@ -1100,6 +1084,8 @@
me.add_to_cart();
}
});
+
+ me.bind_delete_event()
},
update_qty: function (item_code, qty) {
@@ -1173,7 +1159,6 @@
var me = this;
idx = 0
this.items = []
- idx = 0
$.each(this.frm.doc["items"] || [], function (i, d) {
if (!in_list(me.remove_item, d.idx)) {
d.idx = idx;
@@ -1374,39 +1359,31 @@
set_primary_action: function () {
var me = this;
- this.page.set_primary_action(__("New Order"), function () {
- me.save_previous_entry();
- me.create_new();
- me.refresh();
- me.toggle_input_field();
- me.set_focus();
+ this.page.set_primary_action(__("New Cart"), function () {
+ me.make_new_cart()
}, "fa fa-plus")
- if (this.frm.doc.docstatus == 0) {
- // this.page.set_primary_action(__("Pay"), function () {
- // me.validate();
- // me.update_paid_amount_status(true);
- // me.create_invoice();
- // me.make_payment();
- // }, "fa fa-credit-card");
- } else if (this.frm.doc.docstatus == 1) {
+
+ if (this.frm.doc.docstatus == 1) {
this.page.set_secondary_action(__("Print"), function () {
html = frappe.render(me.print_template_data, me.frm.doc)
me.print_document(html)
})
- } else {
- this.page.clear_primary_action()
}
+ },
- // this.page.set_secondary_action(__("New"), function () {
- // me.save_previous_entry();
- // me.create_new();
- // }, "fa fa-plus").addClass("btn-primary");
+ make_new_cart: function (){
+ this.save_previous_entry();
+ this.create_new();
+ this.refresh();
+ this.toggle_input_field();
+ this.render_list_customers();
+ this.set_focus();
},
print_dialog: function () {
var me = this;
- msgprint = frappe.msgprint(format('<a class="btn btn-primary print_doc" \
+ this.msgprint = frappe.msgprint(format('<a class="btn btn-primary print_doc" \
style="margin-right: 5px;">{0}</a>\
<a class="btn btn-default new_doc">{1}</a>', [
__('Print'), __('New')
@@ -1418,8 +1395,8 @@
})
$('.new_doc').click(function () {
- msgprint.hide()
- me.create_new();
+ me.msgprint.hide()
+ me.make_new_cart()
})
},
@@ -1456,6 +1433,8 @@
$(this.wrapper).find('select').attr("disabled", disabled);
$(this.wrapper).find('input').attr("disabled", disabled);
$(this.wrapper).find('select').attr("disabled", disabled);
+ $(this.wrapper).find('button').attr("disabled", disabled);
+ this.party_field.$input.attr('disabled', disabled);
if (this.frm.doc.docstatus == 1) {
pointer_events = 'none';
@@ -1527,7 +1506,7 @@
this.email_queue_list = this.get_email_queue() || {};
this.customers_list = this.get_customers_details() || {};
- if (this.si_docs.length || this.email_queue_list) {
+ if (this.si_docs.length || this.email_queue_list || this.customers_list) {
frappe.call({
method: "erpnext.accounts.doctype.sales_invoice.pos.make_invoice",
args: {
@@ -1580,6 +1559,7 @@
}
}
})
+ this.removed_items = [];
this.si_docs = this.new_si_docs;
this.update_localstorage();
}
diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css
index a51472f..697c078 100644
--- a/erpnext/public/css/erpnext.css
+++ b/erpnext/public/css/erpnext.css
@@ -327,3 +327,4 @@
body[data-route="pos"] .collapse-btn {
cursor: pointer;
}
+
diff --git a/erpnext/public/js/pos/customer_toolbar.html b/erpnext/public/js/pos/customer_toolbar.html
index a2cd834..3ba5ccb 100644
--- a/erpnext/public/js/pos/customer_toolbar.html
+++ b/erpnext/public/js/pos/customer_toolbar.html
@@ -10,7 +10,7 @@
<i class="octicon octicon-organization"></i>
</button>
</button> {% if (allow_delete) { %}
- <button class="btn btn-default btn-danger" style="margin: 0 5px 0 5px;display:none">
+ <button class="btn btn-default btn-danger" style="margin: 0 5px 0 5px">
<i class="octicon octicon-trashcan"></i>
</button> {% } %}
</div>
\ No newline at end of file
diff --git a/erpnext/public/js/pos/pos_invoice_list.html b/erpnext/public/js/pos/pos_invoice_list.html
index 9680cd5..13aa520 100644
--- a/erpnext/public/js/pos/pos_invoice_list.html
+++ b/erpnext/public/js/pos/pos_invoice_list.html
@@ -1,9 +1,9 @@
<div class="pos-list-row" invoice-name = "{{name}}">
- <div class="list-column cell subject">
- <input class="list-delete" type="checkbox">
- <a class="grey list-id" title="{{ customer }}">{%= customer %}</a>
+ <div class="list-column cell subject" invoice-name = "{{name}}">
+ <input class="list-delete text-left" type="checkbox" style = "margin-right:5px">
+ <a class="grey list-id text-left customer-row" title="{{ customer }}">{%= customer %}</a>
</div>
- <div class="list-column cell text-left"><span class="indicator {{data.indicator}}">{{ data.status }}</span></div>
- <div class="list-column cell text-right">{%= paid_amount %}</div>
- <div class="list-column cell text-right">{%= grand_total %}</div>
+ <div class="list-column cell text-left customer-row"><span class="indicator {{data.indicator}}">{{ data.status }}</span></div>
+ <div class="list-column cell text-right customer-row">{%= paid_amount %}</div>
+ <div class="list-column cell text-right customer-row">{%= grand_total %}</div>
</div>