[Fix] Auto batch creation not working for purchase invoice is update stock is enabled (#10348)
This commit is contained in:
parent
353956a864
commit
5999ade43a
@ -53,6 +53,9 @@ class PurchaseInvoice(BuyingController):
|
||||
if (self.is_paid == 1):
|
||||
self.validate_cash()
|
||||
|
||||
if self._action=="submit" and self.update_stock:
|
||||
self.make_batches('warehouse')
|
||||
|
||||
self.check_conversion_rate()
|
||||
self.validate_credit_to_acc()
|
||||
self.clear_unallocated_advances("Purchase Invoice Advance", "advances")
|
||||
|
@ -403,6 +403,27 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertEquals(expected_gl_entries[gle.account][1], gle.debit)
|
||||
self.assertEquals(expected_gl_entries[gle.account][2], gle.credit)
|
||||
|
||||
def test_auto_batch(self):
|
||||
item_code = frappe.db.get_value('Item',
|
||||
{'has_batch_no': 1, 'create_new_batch':1}, 'name')
|
||||
|
||||
if not item_code:
|
||||
doc = frappe.get_doc({
|
||||
'doctype': 'Item',
|
||||
'is_stock_item': 1,
|
||||
'item_code': 'test batch item',
|
||||
'item_group': 'Products',
|
||||
'has_batch_no': 1,
|
||||
'create_new_batch': 1
|
||||
}).insert(ignore_permissions=True)
|
||||
item_code = doc.name
|
||||
|
||||
pi = make_purchase_invoice(update_stock=1, posting_date=frappe.utils.nowdate(),
|
||||
posting_time=frappe.utils.nowtime(), item_code=item_code)
|
||||
|
||||
self.assertTrue(frappe.db.get_value('Batch',
|
||||
{'item': item_code, 'reference_name': pi.name}))
|
||||
|
||||
def test_update_stock_and_purchase_return(self):
|
||||
actual_qty_0 = get_qty_after_transaction()
|
||||
|
||||
|
@ -261,7 +261,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
var item = frappe.get_doc(cdt, cdn);
|
||||
var update_stock = 0, show_batch_dialog = 0;
|
||||
|
||||
if(['Sales Invoice', 'Purchase Invoice'].includes(this.frm.doc.doctype)) {
|
||||
if(['Sales Invoice'].includes(this.frm.doc.doctype)) {
|
||||
update_stock = cint(me.frm.doc.update_stock);
|
||||
show_batch_dialog = update_stock;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user