stock_rbnb fix
This commit is contained in:
parent
7e3980589a
commit
5d8941843f
|
|
@ -47,7 +47,10 @@ doc_events = {
|
||||||
"jey_erp.custom.sales_order_vat.set_vat_fields_permissions"
|
"jey_erp.custom.sales_order_vat.set_vat_fields_permissions"
|
||||||
],
|
],
|
||||||
"before_save": "jey_erp.custom.sales_order_vat.set_vat_fields_permissions"
|
"before_save": "jey_erp.custom.sales_order_vat.set_vat_fields_permissions"
|
||||||
}
|
},
|
||||||
|
"Purchase Receipt": {
|
||||||
|
"before_submit": "jey_erp.patches.purchase_receipt.disable_stock_rbnb_entries"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
after_migrate = "jey_erp.hooks.after_migrate_combined"
|
after_migrate = "jey_erp.hooks.after_migrate_combined"
|
||||||
|
|
@ -60,8 +63,6 @@ def after_migrate_combined():
|
||||||
show_item_tax_template_in_sales_invoice()
|
show_item_tax_template_in_sales_invoice()
|
||||||
from jey_erp.custom.vat_calculations import patch_sales_documents
|
from jey_erp.custom.vat_calculations import patch_sales_documents
|
||||||
patch_sales_documents()
|
patch_sales_documents()
|
||||||
from jey_erp.patches.purchase_receipt import stock_received_but_not_billed_skip_patch
|
|
||||||
stock_received_but_not_billed_skip_patch()
|
|
||||||
|
|
||||||
|
|
||||||
fixtures = [
|
fixtures = [
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,13 @@
|
||||||
import frappe
|
import frappe
|
||||||
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import PurchaseReceipt
|
|
||||||
from erpnext.accounts.general_ledger import process_gl_map
|
|
||||||
from erpnext.accounts.utils import get_account_currency
|
|
||||||
from frappe.utils import flt
|
|
||||||
from frappe import _
|
|
||||||
|
|
||||||
def stock_received_but_not_billed_skip_patch():
|
def disable_stock_rbnb_entries(doc, method):
|
||||||
"""Применяем monkey patch для Purchase Receipt"""
|
"""Отключаем создание GL entries для stock received but not billed"""
|
||||||
# Сохраняем оригинальный метод
|
|
||||||
original_make_item_gl_entries = PurchaseReceipt.make_item_gl_entries
|
|
||||||
|
|
||||||
def patched_make_item_gl_entries(self, gl_entries, warehouse_account=None):
|
original_make_item_gl_entries = doc.make_item_gl_entries
|
||||||
# Весь оригинальный код метода, но с изменением stock_asset_rbnb = None
|
|
||||||
from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import get_purchase_document_details
|
def patched_make_item_gl_entries(gl_entries, warehouse_account=None):
|
||||||
|
# Просто ничего не делаем - полностью пропускаем GL entries
|
||||||
provisional_accounting_for_non_stock_items = frappe.db.get_value(
|
frappe.msgprint("GL entries для Purchase Receipt отключены", alert=True)
|
||||||
"Company", self.company, "enable_provisional_accounting_for_non_stock_items"
|
|
||||||
)
|
|
||||||
|
|
||||||
exchange_rate_map, net_rate_map = get_purchase_document_details(self)
|
|
||||||
|
|
||||||
def validate_account(account_type):
|
|
||||||
frappe.throw(_("{0} account not found while submitting purchase receipt").format(account_type))
|
|
||||||
|
|
||||||
# ГЛАВНОЕ ИЗМЕНЕНИЕ: Заменяем проблемную логику
|
|
||||||
stock_asset_rbnb = None # Отключаем проверку счета
|
|
||||||
|
|
||||||
# Остальная логика остается как в оригинале...
|
|
||||||
stock_items = self.get_stock_items()
|
|
||||||
warehouse_with_no_account = []
|
|
||||||
|
|
||||||
for d in self.get("items"):
|
|
||||||
if (provisional_accounting_for_non_stock_items
|
|
||||||
and d.item_code not in stock_items
|
|
||||||
and flt(d.qty)
|
|
||||||
and d.get("provisional_expense_account")
|
|
||||||
and not d.is_fixed_asset):
|
|
||||||
self.add_provisional_gl_entry(d, gl_entries, self.posting_date, d.get("provisional_expense_account"))
|
|
||||||
|
|
||||||
# Пропускаем создание GL entries если stock_asset_rbnb = None
|
|
||||||
elif flt(d.qty) and (flt(d.valuation_rate) or self.is_return) and stock_asset_rbnb is not None:
|
|
||||||
# Оригинальная логика создания GL entries
|
|
||||||
pass
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Заменяем метод
|
doc.make_item_gl_entries = patched_make_item_gl_entries
|
||||||
PurchaseReceipt.make_item_gl_entries = patched_make_item_gl_entries
|
|
||||||
Loading…
Reference in New Issue