[fix] [refactor] pos hangs in multi-company, if company is not set
This commit is contained in:
parent
e7b37af525
commit
88655890be
@ -23,7 +23,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
this.frm.set_value("is_pos", 1);
|
||||
this.is_pos(function() {
|
||||
if (cint(frappe.defaults.get_user_defaults("fs_pos_view"))===1)
|
||||
erpnext.pos.toggle(me.frm);
|
||||
erpnext.pos.toggle(me.frm, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -75,7 +75,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
}
|
||||
|
||||
// Show buttons only when pos view is active
|
||||
if (doc.docstatus===0 && !this.pos_active) {
|
||||
if (doc.docstatus===0 && !cur_frm.page.current_view_name!=="pos") {
|
||||
cur_frm.cscript.sales_order_btn();
|
||||
cur_frm.cscript.delivery_note_btn();
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ erpnext.pos.PointOfSale = Class.extend({
|
||||
},
|
||||
set_primary_action: function() {
|
||||
var me = this;
|
||||
if (!this.frm.pos_active) return;
|
||||
if (this.frm.page.current_view_name==="main") return;
|
||||
|
||||
if (this.frm.doctype == "Sales Invoice" && this.frm.doc.docstatus===0) {
|
||||
if (!this.frm.doc.is_pos) {
|
||||
@ -342,7 +342,6 @@ erpnext.pos.PointOfSale = Class.extend({
|
||||
});
|
||||
} else if (this.frm.doc.docstatus===1) {
|
||||
this.frm.page.set_primary_action(__("New"), function() {
|
||||
me.frm.pos_active = false;
|
||||
erpnext.open_as_pos = true;
|
||||
new_doc(me.frm.doctype);
|
||||
});
|
||||
@ -498,8 +497,8 @@ erpnext.pos.make_pos_btn = function(frm) {
|
||||
erpnext.pos.toggle(frm) });
|
||||
}
|
||||
|
||||
if(erpnext.open_as_pos && !frm.pos_active) {
|
||||
erpnext.pos.toggle(frm);
|
||||
if(erpnext.open_as_pos && frm.page.current_view_name !== "pos") {
|
||||
erpnext.pos.toggle(frm, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -508,12 +507,24 @@ erpnext.pos.toggle = function(frm, show) {
|
||||
var price_list = frappe.meta.has_field(cur_frm.doc.doctype, "selling_price_list") ?
|
||||
frm.doc.selling_price_list : frm.doc.buying_price_list;
|
||||
|
||||
if((show===true && frm.pos_active) || (show===false && !frm.pos_active)) {
|
||||
return;
|
||||
if(show!==undefined) {
|
||||
if((show===true && frm.page.current_view_name === "pos")
|
||||
|| (show===false && frm.page.current_view_name === "main")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(show && !price_list) {
|
||||
frappe.throw(__("Please select Price List"));
|
||||
console.log(frm.page.current_view_name);
|
||||
|
||||
if(frm.page.current_view_name!=="pos") {
|
||||
// before switching, ask for pos name
|
||||
if(!price_list) {
|
||||
frappe.throw(__("Please select Price List"));
|
||||
}
|
||||
|
||||
if(!frm.doc.company) {
|
||||
frappe.throw(__("Please select Company"));
|
||||
}
|
||||
}
|
||||
|
||||
// make pos
|
||||
@ -523,14 +534,13 @@ erpnext.pos.toggle = function(frm, show) {
|
||||
}
|
||||
|
||||
// toggle view
|
||||
frm.page.set_view(frm.pos_active ? "main" : "pos");
|
||||
frm.pos_active = !frm.pos_active;
|
||||
frm.page.set_view(frm.page.current_view_name==="pos" ? "main" : "pos");
|
||||
|
||||
frm.toolbar.current_status = null;
|
||||
frm.refresh();
|
||||
|
||||
// refresh
|
||||
if(frm.pos_active) {
|
||||
if(frm.page.current_view_name==="pos") {
|
||||
frm.pos.refresh();
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,8 @@
|
||||
</div>
|
||||
{% if(actual_qty != null) { %}
|
||||
<div style="margin-top: 5px;" class="text-muted small text-right">
|
||||
<span title="{%= __("In Stock") %}">{%= actual_qty %}<span>
|
||||
<span title="{%= __("Projected") %}">({%= projected_qty %})<span>
|
||||
<span title="{%= __("In Stock") %}">{%= actual_qty || 0 %}<span>
|
||||
<span title="{%= __("Projected") %}">({%= projected_qty || 0 %})<span>
|
||||
</div>
|
||||
{% } %}
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user