[Fix] Access is pos from sales invoice form.

This commit is contained in:
Rohit Waghchaure 2016-07-07 16:44:40 +05:30
parent 621ef1ea5c
commit 539e913b46
5 changed files with 46 additions and 9 deletions

View File

@ -30,6 +30,7 @@ def get_pos_data():
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_items(doc, pos_profile):
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:

View File

@ -239,6 +239,32 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
}
})
}
},
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 @@ frappe.ui.form.on('Sales Invoice', {
]
}
}
}
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', {

View File

@ -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",

View File

@ -9,6 +9,7 @@ from frappe import _, msgprint, throw
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 @@ class SalesInvoice(SellingController):
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):

View File

@ -202,6 +202,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
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 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
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({