Code cleanup online POS (#12985)
This commit is contained in:
parent
a5003f8f5b
commit
554f2de23d
@ -32,7 +32,7 @@ class POSProfile(Document):
|
||||
.format(res[0][0], row.user), raise_exception=1)
|
||||
elif not row.default and not res:
|
||||
msgprint(_("User {0} doesn't have any default POS Profile. Check Default at Row {1} for this User.")
|
||||
.format(row.user, row.idx), raise_exception=1)
|
||||
.format(row.user, row.idx))
|
||||
|
||||
def validate_all_link_fields(self):
|
||||
accounts = {"Account": [self.income_account,
|
||||
|
@ -106,6 +106,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
on_submit: function(doc, dt, dn) {
|
||||
var me = this;
|
||||
|
||||
if (frappe.get_route()[0] != 'Sales Invoice') {
|
||||
return
|
||||
}
|
||||
|
||||
$.each(doc["items"], function(i, row) {
|
||||
if(row.delivery_note) frappe.model.clear_doc("Delivery Note", row.delivery_note)
|
||||
})
|
||||
|
@ -256,17 +256,22 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
if (field == 'qty' && value < 0) {
|
||||
frappe.msgprint(__("Quantity must be positive"));
|
||||
value = item.qty;
|
||||
} else {
|
||||
item[field] = value;
|
||||
if (field == "serial_no" && value) {
|
||||
let serial_nos = value.split("\n");
|
||||
item["qty"] = serial_nos.filter(d => {
|
||||
return d!=="";
|
||||
}).length;
|
||||
}
|
||||
}
|
||||
|
||||
if (field) {
|
||||
return frappe.model.set_value(item.doctype, item.name, field, value)
|
||||
.then(() => this.frm.script_manager.trigger('qty', item.doctype, item.name))
|
||||
.then(() => {
|
||||
if (field === 'qty' && item.qty === 0) {
|
||||
frappe.model.clear_doc(item.doctype, item.name);
|
||||
}
|
||||
})
|
||||
}
|
||||
return this.frm.script_manager.trigger('qty', item.doctype, item.name)
|
||||
.then(() => {
|
||||
if (field === 'qty' && item.qty === 0) {
|
||||
frappe.model.clear_doc(item.doctype, item.name);
|
||||
}
|
||||
})
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
@ -283,20 +288,13 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
}
|
||||
|
||||
submit_sales_invoice() {
|
||||
|
||||
frappe.confirm(__("Permanently Submit {0}?", [this.frm.doc.name]), () => {
|
||||
frappe.call({
|
||||
method: 'erpnext.selling.page.point_of_sale.point_of_sale.submit_invoice',
|
||||
freeze: true,
|
||||
args: {
|
||||
doc: this.frm.doc
|
||||
}
|
||||
}).then(r => {
|
||||
if(r.message) {
|
||||
this.frm.doc = r.message;
|
||||
this.frm.savesubmit()
|
||||
.then((r) => {
|
||||
if (r && r.doc) {
|
||||
this.frm.doc.docstatus = r.doc.docstatus;
|
||||
frappe.show_alert({
|
||||
indicator: 'green',
|
||||
message: __(`Sales invoice ${r.message.name} created succesfully`)
|
||||
message: __(`Sales invoice ${r.doc.name} created succesfully`)
|
||||
});
|
||||
|
||||
this.toggle_editing();
|
||||
@ -304,21 +302,22 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
this.set_primary_action_in_modal();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
set_primary_action_in_modal() {
|
||||
this.frm.msgbox = frappe.msgprint(
|
||||
`<a class="btn btn-primary" onclick="cur_frm.print_preview.printit(true)" style="margin-right: 5px;">
|
||||
${__('Print')}</a>
|
||||
<a class="btn btn-default">
|
||||
${__('New')}</a>`
|
||||
);
|
||||
if (!this.frm.msgbox) {
|
||||
this.frm.msgbox = frappe.msgprint(
|
||||
`<a class="btn btn-primary" onclick="cur_frm.print_preview.printit(true)" style="margin-right: 5px;">
|
||||
${__('Print')}</a>
|
||||
<a class="btn btn-default">
|
||||
${__('New')}</a>`
|
||||
);
|
||||
|
||||
$(this.frm.msgbox.body).find('.btn-default').on('click', () => {
|
||||
this.frm.msgbox.hide();
|
||||
this.make_new_invoice();
|
||||
})
|
||||
$(this.frm.msgbox.body).find('.btn-default').on('click', () => {
|
||||
this.frm.msgbox.hide();
|
||||
this.make_new_invoice();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
change_pos_profile() {
|
||||
@ -487,11 +486,6 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
//
|
||||
// }).addClass('visible-xs');
|
||||
|
||||
this.page.add_menu_item(__("Form View"), function () {
|
||||
frappe.model.sync(me.frm.doc);
|
||||
frappe.set_route("Form", me.frm.doc.doctype, me.frm.doc.name);
|
||||
});
|
||||
|
||||
this.page.add_menu_item(__("POS Profile"), function () {
|
||||
frappe.set_route('List', 'POS Profile');
|
||||
});
|
||||
@ -589,6 +583,7 @@ class POSCart {
|
||||
this.$taxes_and_totals.html(this.get_taxes_and_totals());
|
||||
this.numpad && this.numpad.reset_value();
|
||||
this.customer_field.set_value("");
|
||||
this.frm.msgbox = "";
|
||||
|
||||
this.$discount_amount.find('input:text').val('');
|
||||
this.wrapper.find('.grand-total-value').text(
|
||||
|
@ -87,19 +87,6 @@ def get_conditions(item_code, serial_no, batch_no, barcode):
|
||||
|
||||
return '%%%s%%'%(frappe.db.escape(item_code)), condition
|
||||
|
||||
@frappe.whitelist()
|
||||
def submit_invoice(doc):
|
||||
if isinstance(doc, basestring):
|
||||
args = json.loads(doc)
|
||||
|
||||
doc = frappe.new_doc('Sales Invoice')
|
||||
doc.update(args)
|
||||
doc.run_method("set_missing_values")
|
||||
doc.run_method("calculate_taxes_and_totals")
|
||||
doc.submit()
|
||||
|
||||
return doc
|
||||
|
||||
def get_item_group_condition(pos_profile):
|
||||
cond = "and 1=1"
|
||||
item_groups = get_item_groups(pos_profile)
|
||||
|
Loading…
x
Reference in New Issue
Block a user