mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 23:49:19 +00:00
[fix] [pos] pos view only for draft docs
This commit is contained in:
@@ -73,8 +73,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
return item.delivery_note ? true : false;
|
return item.delivery_note ? true : false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!from_delivery_note)
|
if(!from_delivery_note) {
|
||||||
cur_frm.appframe.add_primary_action(__('Make Delivery'), cur_frm.cscript['Make Delivery Note'], "icon-truck")
|
cur_frm.appframe.add_primary_action(__('Make Delivery'), cur_frm.cscript['Make Delivery Note'], "icon-truck")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.outstanding_amount!=0) {
|
if(doc.outstanding_amount!=0) {
|
||||||
|
|||||||
@@ -57,27 +57,32 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
|||||||
this.set_dynamic_labels();
|
this.set_dynamic_labels();
|
||||||
|
|
||||||
// Show POS button only if it is enabled from features setup
|
// Show POS button only if it is enabled from features setup
|
||||||
if(cint(sys_defaults.fs_pos_view)===1 && this.frm.doctype!="Material Request" && this.frm.doc.docstatus===0)
|
if(cint(sys_defaults.fs_pos_view)===1 && this.frm.doctype!="Material Request")
|
||||||
this.make_pos_btn();
|
this.make_pos_btn();
|
||||||
},
|
},
|
||||||
|
|
||||||
make_pos_btn: function() {
|
make_pos_btn: function() {
|
||||||
if(!this.pos_active) {
|
|
||||||
var btn_label = __("POS View"),
|
|
||||||
icon = "icon-th";
|
|
||||||
} else {
|
|
||||||
var btn_label = __("Form View"),
|
|
||||||
icon = "icon-file-text";
|
|
||||||
}
|
|
||||||
var me = this;
|
var me = this;
|
||||||
|
if(this.frm.doc.docstatus===0) {
|
||||||
|
if(!this.pos_active) {
|
||||||
|
var btn_label = __("POS View"),
|
||||||
|
icon = "icon-th";
|
||||||
|
} else {
|
||||||
|
var btn_label = __("Form View"),
|
||||||
|
icon = "icon-file-text";
|
||||||
|
}
|
||||||
|
|
||||||
this.$pos_btn = this.frm.appframe.add_primary_action(btn_label, function() {
|
if(erpnext.open_as_pos) {
|
||||||
me.toggle_pos();
|
me.toggle_pos(true);
|
||||||
}, icon, "btn-default");
|
erpnext.open_as_pos = false;
|
||||||
|
}
|
||||||
|
|
||||||
if(erpnext.open_as_pos) {
|
this.$pos_btn = this.frm.appframe.add_primary_action(btn_label, function() {
|
||||||
me.toggle_pos(true);
|
me.toggle_pos();
|
||||||
erpnext.open_as_pos = false;
|
}, icon, "btn-default");
|
||||||
|
} else {
|
||||||
|
// hack: will avoid calling refresh from refresh
|
||||||
|
setTimeout(function() { me.toggle_pos(false); }, 100);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -86,26 +91,27 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
|||||||
var price_list = frappe.meta.has_field(cur_frm.doc.doctype, "selling_price_list") ?
|
var price_list = frappe.meta.has_field(cur_frm.doc.doctype, "selling_price_list") ?
|
||||||
this.frm.doc.selling_price_list : this.frm.doc.buying_price_list;
|
this.frm.doc.selling_price_list : this.frm.doc.buying_price_list;
|
||||||
|
|
||||||
if (!price_list)
|
if((show===true && this.pos_active) || (show===false && !this.pos_active))
|
||||||
msgprint(__("Please select Price List"))
|
return;
|
||||||
else {
|
|
||||||
if((show===true && this.pos_active) || (show===false && !this.pos_active)) return;
|
|
||||||
|
|
||||||
// make pos
|
if(show && !price_list) {
|
||||||
if(!this.frm.pos) {
|
frappe.throw(__("Please select Price List"));
|
||||||
this.frm.layout.add_view("pos");
|
|
||||||
this.frm.pos = new erpnext.POS(this.frm.layout.views.pos, this.frm);
|
|
||||||
}
|
|
||||||
|
|
||||||
// toggle view
|
|
||||||
this.frm.layout.set_view(this.pos_active ? "" : "pos");
|
|
||||||
this.pos_active = !this.pos_active;
|
|
||||||
|
|
||||||
// refresh
|
|
||||||
if(this.pos_active)
|
|
||||||
this.frm.pos.refresh();
|
|
||||||
this.frm.refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make pos
|
||||||
|
if(!this.frm.pos) {
|
||||||
|
this.frm.layout.add_view("pos");
|
||||||
|
this.frm.pos = new erpnext.POS(this.frm.layout.views.pos, this.frm);
|
||||||
|
}
|
||||||
|
|
||||||
|
// toggle view
|
||||||
|
this.frm.layout.set_view(this.pos_active ? "" : "pos");
|
||||||
|
this.pos_active = !this.pos_active;
|
||||||
|
|
||||||
|
// refresh
|
||||||
|
if(this.pos_active)
|
||||||
|
this.frm.pos.refresh();
|
||||||
|
this.frm.refresh();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user