diff --git a/erpnext/manufacturing/doctype/blanket_order/blanket_order.py b/erpnext/manufacturing/doctype/blanket_order/blanket_order.py index 5381abfe0a..822c7fcc1a 100644 --- a/erpnext/manufacturing/doctype/blanket_order/blanket_order.py +++ b/erpnext/manufacturing/doctype/blanket_order/blanket_order.py @@ -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") diff --git a/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.js b/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.js new file mode 100644 index 0000000000..51a0d94841 --- /dev/null +++ b/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.js @@ -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() + ]); + +});