Skip to content

Commit

Permalink
fix: skip rate validation for return DN Items with Moving Average
Browse files Browse the repository at this point in the history
… valuation (backport #39242) (#39265)

* fix: skip rate validation for return `DN Items` with `Moving Average` valuation

(cherry picked from commit e0ad52b)

# Conflicts:
#	erpnext/controllers/sales_and_purchase_return.py

* chore: `conflicts`

---------

Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
  • Loading branch information
mergify[bot] and s-aga-r authored Jan 10, 2024
1 parent a3146c3 commit f42e93b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions erpnext/controllers/sales_and_purchase_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from frappe.utils import flt, format_datetime, get_datetime

import erpnext
from erpnext.stock.utils import get_incoming_rate
from erpnext.stock.utils import get_incoming_rate, get_valuation_method


class StockOverReturnError(frappe.ValidationError):
Expand Down Expand Up @@ -116,7 +116,12 @@ def validate_returned_items(doc):
ref = valid_items.get(d.item_code, frappe._dict())
validate_quantity(doc, d, ref, valid_items, already_returned_items)

if ref.rate and doc.doctype in ("Delivery Note", "Sales Invoice") and flt(d.rate) > ref.rate:
if (
ref.rate
and flt(d.rate) > ref.rate
and doc.doctype in ("Delivery Note", "Sales Invoice")
and get_valuation_method(ref.item_code) != "Moving Average"
):
frappe.throw(
_("Row # {0}: Rate cannot be greater than the rate used in {1} {2}").format(
d.idx, doc.doctype, doc.return_against
Expand Down

0 comments on commit f42e93b

Please sign in to comment.