mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
Repost gle for future transactions if update stock checked in back dated purchase invoice
This commit is contained in:
@@ -301,7 +301,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
asset.flags.ignore_validate_update_after_submit = True
|
asset.flags.ignore_validate_update_after_submit = True
|
||||||
asset.save()
|
asset.save()
|
||||||
|
|
||||||
def make_gl_entries(self, repost_future_gle=False):
|
def make_gl_entries(self, repost_future_gle=True):
|
||||||
self.auto_accounting_for_stock = \
|
self.auto_accounting_for_stock = \
|
||||||
cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
|
cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class StockController(AccountsController):
|
|||||||
|
|
||||||
gl_list = []
|
gl_list = []
|
||||||
warehouse_with_no_account = []
|
warehouse_with_no_account = []
|
||||||
|
|
||||||
for detail in voucher_details:
|
for detail in voucher_details:
|
||||||
sle_list = sle_map.get(detail.name)
|
sle_list = sle_map.get(detail.name)
|
||||||
if sle_list:
|
if sle_list:
|
||||||
@@ -266,10 +267,9 @@ def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for
|
|||||||
voucher_obj = frappe.get_doc(voucher_type, voucher_no)
|
voucher_obj = frappe.get_doc(voucher_type, voucher_no)
|
||||||
expected_gle = voucher_obj.get_gl_entries(warehouse_account)
|
expected_gle = voucher_obj.get_gl_entries(warehouse_account)
|
||||||
if expected_gle:
|
if expected_gle:
|
||||||
if not existing_gle or not compare_existing_and_expected_gle(existing_gle,
|
if not existing_gle or not compare_existing_and_expected_gle(existing_gle, expected_gle):
|
||||||
expected_gle):
|
_delete_gl_entries(voucher_type, voucher_no)
|
||||||
_delete_gl_entries(voucher_type, voucher_no)
|
voucher_obj.make_gl_entries(repost_future_gle=False)
|
||||||
voucher_obj.make_gl_entries(repost_future_gle=False)
|
|
||||||
else:
|
else:
|
||||||
_delete_gl_entries(voucher_type, voucher_no)
|
_delete_gl_entries(voucher_type, voucher_no)
|
||||||
|
|
||||||
|
|||||||
@@ -308,4 +308,5 @@ erpnext.patches.v7_0.remove_old_earning_deduction_doctypes
|
|||||||
erpnext.patches.v7_0.make_guardian
|
erpnext.patches.v7_0.make_guardian
|
||||||
erpnext.patches.v7_0.update_refdoc_in_landed_cost_voucher
|
erpnext.patches.v7_0.update_refdoc_in_landed_cost_voucher
|
||||||
erpnext.patches.v7_0.set_material_request_type_in_item
|
erpnext.patches.v7_0.set_material_request_type_in_item
|
||||||
erpnext.patches.v7_0.rename_examination_to_assessment
|
erpnext.patches.v7_0.rename_examination_to_assessment
|
||||||
|
erpnext.patches.v7_0.repost_future_gle_for_purchase_invoice
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
from frappe.utils import cint
|
||||||
|
from erpnext.controllers.stock_controller import get_warehouse_account, update_gl_entries_after
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
|
||||||
|
return
|
||||||
|
|
||||||
|
wh_account = get_warehouse_account()
|
||||||
|
|
||||||
|
for pi in frappe.get_all("Purchase Invoice", filters={"docstatus": 1, "update_stock": 1}):
|
||||||
|
pi_doc = frappe.get_doc("Purchase Invoice", pi.name)
|
||||||
|
items, warehouses = pi_doc.get_items_and_warehouses()
|
||||||
|
update_gl_entries_after(pi_doc.posting_date, pi_doc.posting_time, warehouses, items, wh_account)
|
||||||
|
|
||||||
|
frappe.db.commit()
|
||||||
Reference in New Issue
Block a user