Set target qty 0
If the ordered qty exceeds the quantity in blanket order items, on routing to a new Purchase order or Sales order, set target qty as 0 to avoid negative qty.
This commit is contained in:
parent
e2a8120ef8
commit
18bed504dc
@ -4,6 +4,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import flt
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from erpnext.stock.doctype.item.item import get_item_defaults
|
||||
@ -28,7 +29,8 @@ class BlanketOrder(Document):
|
||||
@frappe.whitelist()
|
||||
def make_sales_order(source_name):
|
||||
def update_item(source, target, source_parent):
|
||||
target.qty = source.get("qty") - source.get("ordered_qty")
|
||||
target_qty = source.get("qty") - source.get("ordered_qty")
|
||||
target.qty = target_qty if not flt(target_qty) < 0 else 0
|
||||
item = get_item_defaults(target.item_code, source_parent.company)
|
||||
if item:
|
||||
target.item_name = item.get("item_name")
|
||||
@ -53,7 +55,8 @@ def make_sales_order(source_name):
|
||||
@frappe.whitelist()
|
||||
def make_purchase_order(source_name):
|
||||
def update_item(source, target, source_parent):
|
||||
target.qty = source.get("qty") - source.get("ordered_qty")
|
||||
target_qty = source.get("qty") - source.get("ordered_qty")
|
||||
target.qty = target_qty if not flt(target_qty) < 0 else 0
|
||||
item = get_item_defaults(target.item_code, source_parent.company)
|
||||
if item:
|
||||
target.item_name = item.get("item_name")
|
||||
|
@ -0,0 +1,23 @@
|
||||
/* eslint-disable */
|
||||
// rename this file from _test_[name] to test_[name] to activate
|
||||
// and remove above this line
|
||||
|
||||
QUnit.test("test: Blanket Order", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new Blanket Order
|
||||
() => frappe.tests.make('Blanket Order', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
]),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.key, 'value');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user