[fix] [pos] pos view only for draft docs
This commit is contained in:
parent
3a97739f83
commit
23607f91cd
@ -73,8 +73,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
if(doc.outstanding_amount!=0) {
|
||||
|
@ -57,27 +57,32 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
this.set_dynamic_labels();
|
||||
|
||||
// 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();
|
||||
},
|
||||
|
||||
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;
|
||||
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() {
|
||||
me.toggle_pos();
|
||||
}, icon, "btn-default");
|
||||
if(erpnext.open_as_pos) {
|
||||
me.toggle_pos(true);
|
||||
erpnext.open_as_pos = false;
|
||||
}
|
||||
|
||||
if(erpnext.open_as_pos) {
|
||||
me.toggle_pos(true);
|
||||
erpnext.open_as_pos = false;
|
||||
this.$pos_btn = this.frm.appframe.add_primary_action(btn_label, function() {
|
||||
me.toggle_pos();
|
||||
}, 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") ?
|
||||
this.frm.doc.selling_price_list : this.frm.doc.buying_price_list;
|
||||
|
||||
if (!price_list)
|
||||
msgprint(__("Please select Price List"))
|
||||
else {
|
||||
if((show===true && this.pos_active) || (show===false && !this.pos_active)) return;
|
||||
if((show===true && this.pos_active) || (show===false && !this.pos_active))
|
||||
return;
|
||||
|
||||
// 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();
|
||||
if(show && !price_list) {
|
||||
frappe.throw(__("Please select Price List"));
|
||||
}
|
||||
|
||||
// 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();
|
||||
},
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user