[Fix] Access is pos from sales invoice form.
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index ec0e50c..c6191da 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -30,6 +30,7 @@
return {
'doc': doc,
+ 'default_customer': pos_profile.get('customer'),
'items': get_items(doc, pos_profile),
'customers': get_customers(pos_profile, doc),
'pricing_rules': get_pricing_rules(doc),
@@ -122,9 +123,6 @@
def get_customers(pos_profile, doc):
filters = {'disabled': 0}
customer_list = []
- if pos_profile.get('customer'):
- filters.update({'name': pos_profile.customer})
-
customers = frappe.get_all("Customer", fields=["*"], filters = filters)
for customer in customers:
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 4bc634a..f39c983 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -239,6 +239,32 @@
}
})
}
+ },
+
+ is_pos: function(frm){
+ if(this.frm.doc.is_pos) {
+ if(!this.frm.doc.company) {
+ this.frm.set_value("is_pos", 0);
+ msgprint(__("Please specify Company to proceed"));
+ } else {
+ var me = this;
+ return this.frm.call({
+ doc: me.frm.doc,
+ method: "set_missing_values",
+ callback: function(r) {
+ if(!r.exc) {
+ if(r.message && r.message.print_format) {
+ frm.pos_print_format = r.message.print_format;
+ }
+ me.frm.script_manager.trigger("update_stock");
+ frappe.model.set_default_values(me.frm.doc);
+ me.set_dynamic_labels();
+ me.calculate_taxes_and_totals();
+ }
+ }
+ });
+ }
+ }
}
});
@@ -430,7 +456,14 @@
]
}
}
- }
+
+ if(frm.doc.is_pos){
+ frm.get_field('payments').grid.editable_fields = [
+ {fieldname: 'mode_of_payment', columns: 2},
+ {fieldname: 'amount', columns: 2}
+ ];
+ }
+ },
})
frappe.ui.form.on('Sales Invoice Timesheet', {
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 746209f..af5790f 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -2071,7 +2071,7 @@
{
"allow_on_submit": 0,
"bold": 0,
- "collapsible": 1,
+ "collapsible": 0,
"collapsible_depends_on": "",
"depends_on": "eval:doc.is_pos===1||(doc.advances && doc.advances.length>0)",
"fieldname": "payments_section",
@@ -3676,7 +3676,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2016-07-02 20:10:14.146963",
+ "modified": "2016-07-07 13:40:27.977803",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index bacee7f..1b68a83 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -9,6 +9,7 @@
from erpnext.accounts.party import get_party_account, get_due_date
from erpnext.controllers.stock_controller import update_gl_entries_after
from frappe.model.mapper import get_mapped_doc
+from erpnext.accounts.doctype.sales_invoice.pos import update_multi_mode_option
from erpnext.controllers.selling_controller import SellingController
from erpnext.accounts.utils import get_account_currency
@@ -291,6 +292,10 @@
if self.taxes_and_charges and not len(self.get("taxes")):
self.set_taxes()
+ if not self.get('payments'):
+ pos_profile = frappe.get_doc('POS Profile', pos.name)
+ update_multi_mode_option(self, pos_profile)
+
return pos
def get_company_abbr(self):
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index a1a502a..fcccfb4 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -202,6 +202,7 @@
window.pricing_rules = r.message.pricing_rules;
window.meta = r.message.meta;
window.print_template = r.message.print_template;
+ me.default_customer = r.message.default_customer || null;
me.write_off_account = r.message.write_off_account;
localStorage.setItem('doc', JSON.stringify(r.message.doc));
if(callback){
@@ -301,9 +302,9 @@
make_customer: function() {
var me = this;
- if(this.customers.length == 1){
- this.party_field.$input.val(this.customers[0].name);
- this.frm.doc.customer = this.customers[0].name;
+ if(this.default_customer){
+ this.party_field.$input.val(this.default_customer);
+ this.frm.doc.customer = this.default_customer;
}
this.party_field.$input.autocomplete({