[fix] Repost only distinct purchase receipts and invoices

This commit is contained in:
Nabin Hait 2016-08-19 16:39:33 +05:30
parent e4fb7b1b2f
commit 3b6dc141c6
2 changed files with 5 additions and 5 deletions

View File

@ -204,10 +204,10 @@ class StockController(AccountsController):
from erpnext.stock.stock_ledger import make_sl_entries from erpnext.stock.stock_ledger import make_sl_entries
make_sl_entries(sl_entries, is_amended, allow_negative_stock, via_landed_cost_voucher) make_sl_entries(sl_entries, is_amended, allow_negative_stock, via_landed_cost_voucher)
def make_gl_entries_on_cancel(self): def make_gl_entries_on_cancel(self, repost_future_gle=True):
if frappe.db.sql("""select name from `tabGL Entry` where voucher_type=%s if frappe.db.sql("""select name from `tabGL Entry` where voucher_type=%s
and voucher_no=%s""", (self.doctype, self.name)): and voucher_no=%s""", (self.doctype, self.name)):
self.make_gl_entries() self.make_gl_entries(repost_future_gle)
def get_serialized_items(self): def get_serialized_items(self):
serialized_items = [] serialized_items = []
@ -261,7 +261,7 @@ def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for
future_stock_vouchers = get_future_stock_vouchers(posting_date, posting_time, for_warehouses, for_items) future_stock_vouchers = get_future_stock_vouchers(posting_date, posting_time, for_warehouses, for_items)
gle = get_voucherwise_gl_entries(future_stock_vouchers, posting_date) gle = get_voucherwise_gl_entries(future_stock_vouchers, posting_date)
for voucher_type, voucher_no in future_stock_vouchers: for voucher_type, voucher_no in future_stock_vouchers:
existing_gle = gle.get((voucher_type, voucher_no), []) existing_gle = gle.get((voucher_type, voucher_no), [])
voucher_obj = frappe.get_doc(voucher_type, voucher_no) voucher_obj = frappe.get_doc(voucher_type, voucher_no)

View File

@ -84,7 +84,7 @@ class LandedCostVoucher(Document):
self.update_landed_cost() self.update_landed_cost()
def update_landed_cost(self): def update_landed_cost(self):
for d in self.get("items"): for d in self.get("purchase_receipts"):
doc = frappe.get_doc(d.receipt_document_type, d.receipt_document) doc = frappe.get_doc(d.receipt_document_type, d.receipt_document)
# set landed cost voucher amount in pr item # set landed cost voucher amount in pr item
@ -103,7 +103,7 @@ class LandedCostVoucher(Document):
# update stock & gl entries for cancelled state of PR # update stock & gl entries for cancelled state of PR
doc.docstatus = 2 doc.docstatus = 2
doc.update_stock_ledger(allow_negative_stock=True, via_landed_cost_voucher=True) doc.update_stock_ledger(allow_negative_stock=True, via_landed_cost_voucher=True)
doc.make_gl_entries_on_cancel() doc.make_gl_entries_on_cancel(repost_future_gle=False)
# update stock & gl entries for submit state of PR # update stock & gl entries for submit state of PR