Skip to content

Commit

Permalink
chore: use local deprecation (#44306)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao authored Nov 23, 2024
1 parent 2e04eeb commit f1bd6e4
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 15 deletions.
3 changes: 3 additions & 0 deletions erpnext/controllers/stock_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,9 @@ def get_sl_entries(self, d, args):
self.update_inventory_dimensions(d, sl_dict)

if self.docstatus == 2:
from erpnext.deprecation_dumpster import deprecation_warning

deprecation_warning("unknown", "v16", "No instructions.")
# To handle denormalized serial no records, will br deprecated in v16
for field in ["serial_no", "batch_no"]:
if d.get(field):
Expand Down
6 changes: 6 additions & 0 deletions erpnext/controllers/subcontracting_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,18 @@ def __update_consumed_materials(self, doctype, return_consumed_items=False):

# Will be deprecated in v16
if row.serial_no and not consumed_bundles.serial_nos:
from erpnext.deprecation_dumpster import deprecation_warning

deprecation_warning("unknown", "v16", "No instructions.")
self.available_materials[key]["serial_no"] = list(
set(self.available_materials[key]["serial_no"]) - set(get_serial_nos(row.serial_no))
)

# Will be deprecated in v16
if row.batch_no and not consumed_bundles.batch_nos:
from erpnext.deprecation_dumpster import deprecation_warning

deprecation_warning("unknown", "v16", "No instructions.")
self.available_materials[key]["batch_no"][row.batch_no] -= row.consumed_qty

def get_available_materials(self):
Expand Down
9 changes: 7 additions & 2 deletions erpnext/controllers/taxes_and_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from frappe import _, scrub
from frappe.model.document import Document
from frappe.utils import cint, flt, round_based_on_smallest_currency_fraction
from frappe.utils.deprecations import deprecated

import erpnext
from erpnext.accounts.doctype.journal_entry.journal_entry import get_exchange_rate
Expand All @@ -18,6 +17,7 @@
validate_inclusive_tax,
validate_taxes_and_charges,
)
from erpnext.deprecation_dumpster import deprecated
from erpnext.stock.get_item_details import ItemDetailsCtx, _get_item_tax_template
from erpnext.utilities.regional import temporary_flag

Expand Down Expand Up @@ -567,7 +567,12 @@ def round_off_base_values(self, tax):
tax.base_tax_amount = round(tax.base_tax_amount, 0)
tax.base_tax_amount_after_discount_amount = round(tax.base_tax_amount_after_discount_amount, 0)

@deprecated
@deprecated(
f"{__name__}.calculate_taxes_and_totals.manipulate_grand_total_for_inclusive_tax",
"unknown",
"v16",
"No known instructions.",
)
def manipulate_grand_total_for_inclusive_tax(self):
# for backward compatablility - if in case used by an external application
return self.adjust_grand_total_for_inclusive_tax()
Expand Down
5 changes: 3 additions & 2 deletions erpnext/startup/leaderboard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import frappe
from frappe.utils.deprecations import deprecated

from erpnext.deprecation_dumpster import deprecated


def get_leaderboards():
Expand Down Expand Up @@ -218,7 +219,7 @@ def get_all_sales_person(date_range, company, field=None, limit=0):
)


@deprecated
@deprecated(f"{__name__}.get_date_condition", "unknown", "v16", "No known instructions.")
def get_date_condition(date_range, field):
date_condition = ""
if date_range:
Expand Down
59 changes: 50 additions & 9 deletions erpnext/stock/deprecated_serial_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
import frappe
from frappe.query_builder.functions import CombineDatetime, Sum
from frappe.utils import flt
from frappe.utils.deprecations import deprecated
from pypika import Order

from erpnext.deprecation_dumpster import deprecated


class DeprecatedSerialNoValuation:
@deprecated
@deprecated(
"erpnext.stock.serial_batch_bundle.SerialNoValuation.calculate_stock_value_from_deprecarated_ledgers",
"unknown",
"v16",
"No known instructions.",
)
def calculate_stock_value_from_deprecarated_ledgers(self):
if not has_sle_for_serial_nos(self.sle.item_code):
return
Expand All @@ -35,7 +41,12 @@ def get_filterd_serial_nos(self):

return serial_nos

@deprecated
@deprecated(
"erpnext.stock.serial_batch_bundle.SerialNoValuation.get_incoming_value_for_serial_nos",
"unknown",
"v16",
"No known instructions.",
)
def get_incoming_value_for_serial_nos(self, serial_nos):
from erpnext.stock.utils import get_combine_datetime

Expand Down Expand Up @@ -93,14 +104,24 @@ def has_sle_for_serial_nos(item_code):


class DeprecatedBatchNoValuation:
@deprecated
@deprecated(
"erpnext.stock.serial_batch_bundle.BatchNoValuation.calculate_avg_rate_from_deprecarated_ledgers",
"unknown",
"v16",
"No known instructions.",
)
def calculate_avg_rate_from_deprecarated_ledgers(self):
entries = self.get_sle_for_batches()
for ledger in entries:
self.stock_value_differece[ledger.batch_no] += flt(ledger.batch_value)
self.available_qty[ledger.batch_no] += flt(ledger.batch_qty)

@deprecated
@deprecated(
"erpnext.stock.serial_batch_bundle.BatchNoValuation.get_sle_for_batches",
"unknown",
"v16",
"No known instructions.",
)
def get_sle_for_batches(self):
from erpnext.stock.utils import get_combine_datetime

Expand Down Expand Up @@ -147,7 +168,12 @@ def get_sle_for_batches(self):

return query.run(as_dict=True)

@deprecated
@deprecated(
"erpnext.stock.serial_batch_bundle.BatchNoValuation.calculate_avg_rate_for_non_batchwise_valuation",
"unknown",
"v16",
"No known instructions.",
)
def calculate_avg_rate_for_non_batchwise_valuation(self):
if not self.non_batchwise_valuation_batches:
return
Expand Down Expand Up @@ -185,12 +211,22 @@ def calculate_avg_rate_for_non_batchwise_valuation(self):
},
)

@deprecated
@deprecated(
"erpnext.stock.serial_batch_bundle.BatchNoValuation.set_balance_value_for_non_batchwise_valuation_batches",
"unknown",
"v16",
"No known instructions.",
)
def set_balance_value_for_non_batchwise_valuation_batches(self):
self.set_balance_value_from_sl_entries()
self.set_balance_value_from_bundle()

@deprecated
@deprecated(
"erpnext.stock.serial_batch_bundle.BatchNoValuation.set_balance_value_from_sl_entries",
"unknown",
"v16",
"No known instructions.",
)
def set_balance_value_from_sl_entries(self) -> None:
from erpnext.stock.utils import get_combine_datetime

Expand Down Expand Up @@ -237,7 +273,12 @@ def set_balance_value_from_sl_entries(self) -> None:
self.non_batchwise_balance_qty[d.batch_no] += flt(d.batch_qty)
self.available_qty[d.batch_no] += flt(d.batch_qty)

@deprecated
@deprecated(
"erpnext.stock.serial_batch_bundle.BatchNoValuation.set_balance_value_from_bundle",
"unknown",
"v16",
"No known instructions.",
)
def set_balance_value_from_bundle(self) -> None:
bundle = frappe.qb.DocType("Serial and Batch Bundle")
bundle_child = frappe.qb.DocType("Serial and Batch Entry")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import frappe
from frappe import _
from frappe.utils import add_to_date, cint, flt, get_datetime, get_table_name, getdate
from frappe.utils.deprecations import deprecated
from pypika import functions as fn

from erpnext.deprecation_dumpster import deprecated
from erpnext.stock.doctype.warehouse.warehouse import apply_warehouse_filter

SLE_COUNT_LIMIT = 10_000
Expand Down Expand Up @@ -100,7 +100,7 @@ def get_stock_ledger_entries(filters):
return entries


@deprecated
@deprecated(f"{__name__}.get_stock_ledger_entries_for_batch_no", "unknown", "v16", "No known instructions.")
def get_stock_ledger_entries_for_batch_no(filters):
if not filters.get("from_date"):
frappe.throw(_("'From Date' is required"))
Expand Down

0 comments on commit f1bd6e4

Please sign in to comment.