mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 13:09:17 +00:00
fix(pos): allow validating stock on save
(cherry picked from commit aff7408775)
# Conflicts:
# erpnext/accounts/doctype/pos_invoice/pos_invoice.py
This commit is contained in:
committed by
mergify-bot
parent
3b583c6c48
commit
76f83ea559
@@ -212,11 +212,24 @@ class POSInvoice(SalesInvoice):
|
|||||||
frappe.throw(error_msg, title=_("Invalid Item"), as_list=True)
|
frappe.throw(error_msg, title=_("Invalid Item"), as_list=True)
|
||||||
|
|
||||||
def validate_stock_availablility(self):
|
def validate_stock_availablility(self):
|
||||||
|
<<<<<<< HEAD
|
||||||
if self.is_return or self.docstatus != 1:
|
if self.is_return or self.docstatus != 1:
|
||||||
return
|
return
|
||||||
allow_negative_stock = frappe.db.get_single_value("Stock Settings", "allow_negative_stock")
|
allow_negative_stock = frappe.db.get_single_value("Stock Settings", "allow_negative_stock")
|
||||||
for d in self.get("items"):
|
for d in self.get("items"):
|
||||||
is_service_item = not (frappe.db.get_value("Item", d.get("item_code"), "is_stock_item"))
|
is_service_item = not (frappe.db.get_value("Item", d.get("item_code"), "is_stock_item"))
|
||||||
|
=======
|
||||||
|
if self.is_return:
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.docstatus.is_draft() and not frappe.db.get_value('POS Profile', self.pos_profile, 'validate_stock_on_save'):
|
||||||
|
return
|
||||||
|
|
||||||
|
from erpnext.stock.stock_ledger import is_negative_stock_allowed
|
||||||
|
|
||||||
|
for d in self.get('items'):
|
||||||
|
is_service_item = not (frappe.db.get_value('Item', d.get('item_code'), 'is_stock_item'))
|
||||||
|
>>>>>>> aff7408775 (fix(pos): allow validating stock on save)
|
||||||
if is_service_item:
|
if is_service_item:
|
||||||
return
|
return
|
||||||
if d.serial_no:
|
if d.serial_no:
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"hide_images",
|
"hide_images",
|
||||||
"hide_unavailable_items",
|
"hide_unavailable_items",
|
||||||
"auto_add_item_to_cart",
|
"auto_add_item_to_cart",
|
||||||
|
"validate_stock_on_save",
|
||||||
"column_break_16",
|
"column_break_16",
|
||||||
"update_stock",
|
"update_stock",
|
||||||
"ignore_pricing_rule",
|
"ignore_pricing_rule",
|
||||||
@@ -351,6 +352,12 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "column_break_25",
|
"fieldname": "column_break_25",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "validate_stock_on_save",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Validate Stock on Save"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-cog",
|
"icon": "icon-cog",
|
||||||
@@ -378,10 +385,11 @@
|
|||||||
"link_fieldname": "pos_profile"
|
"link_fieldname": "pos_profile"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-10-14 14:17:00.469298",
|
"modified": "2022-03-21 13:29:28.480533",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "POS Profile",
|
"name": "POS Profile",
|
||||||
|
"naming_rule": "Set by user",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
@@ -404,5 +412,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC"
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
}
|
}
|
||||||
@@ -720,7 +720,14 @@ erpnext.PointOfSale.Controller = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async save_and_checkout() {
|
async save_and_checkout() {
|
||||||
this.frm.is_dirty() && await this.frm.save();
|
if (this.frm.is_dirty()) {
|
||||||
this.payment.checkout();
|
// only move to payment section if save is successful
|
||||||
|
frappe.route_hooks.after_save = () => this.payment.checkout();
|
||||||
|
return this.frm.save(
|
||||||
|
null, null, null, () => this.cart.toggle_checkout_btn(true) // show checkout button on error
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.payment.checkout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ erpnext.PointOfSale.Payment = class {
|
|||||||
frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => {
|
frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => {
|
||||||
if (frm.doc.coupon_code && !frm.applying_pos_coupon_code) {
|
if (frm.doc.coupon_code && !frm.applying_pos_coupon_code) {
|
||||||
if (!frm.doc.ignore_pricing_rule) {
|
if (!frm.doc.ignore_pricing_rule) {
|
||||||
frm.applying_pos_coupon_code = true
|
frm.applying_pos_coupon_code = true;
|
||||||
frappe.run_serially([
|
frappe.run_serially([
|
||||||
() => frm.doc.ignore_pricing_rule=1,
|
() => frm.doc.ignore_pricing_rule=1,
|
||||||
() => frm.trigger('ignore_pricing_rule'),
|
() => frm.trigger('ignore_pricing_rule'),
|
||||||
|
|||||||
Reference in New Issue
Block a user